| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
=head1 MODULE FOR SALE |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
I am not planning to make any changes to this module as I have not been a |
|
4
|
|
|
|
|
|
|
customer of TMobile for over a year. If someone would like to take over |
|
5
|
|
|
|
|
|
|
maintenance/development of this module please get in touch. |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 ANTI-TMOBILE RANT |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
TMobile's lax fraud prevention procedures allowed a random person in a random |
|
10
|
|
|
|
|
|
|
part of the UK to buy a mobile phone contract at my parents address. TMobile |
|
11
|
|
|
|
|
|
|
then started to demand money from my parents and ignored initial attempts to |
|
12
|
|
|
|
|
|
|
explain that the person has a different name from the residents and has never |
|
13
|
|
|
|
|
|
|
lived at their address. TMobile eventually, after much chasing, agreed to stop |
|
14
|
|
|
|
|
|
|
demanding money that my family did not owe them, but they to date have not |
|
15
|
|
|
|
|
|
|
properly apologied for their actions or explained how on earth this person was |
|
16
|
|
|
|
|
|
|
able to setup the phone contract in the first place. |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
I encourage people not to use T-Mobile. |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head1 NAME |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
Business::Billing::TMobile::UK - The fantastic new Business::Billing::TMobile::UK! |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
use Business::Billing::TMobile::UK |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
An interface to TMobile UK's website for getting allowance and billing |
|
31
|
|
|
|
|
|
|
information. |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=cut |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
package Business::Billing::TMobile::UK; |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# pragmata |
|
38
|
1
|
|
|
1
|
|
24738
|
use strict; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
42
|
|
|
39
|
1
|
|
|
1
|
|
6
|
use vars qw($VERSION); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
53
|
|
|
40
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
28
|
|
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# Standard Perl Library and CPAN modules |
|
43
|
1
|
|
|
1
|
|
6
|
use Carp; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
113
|
|
|
44
|
1
|
|
|
1
|
|
1121
|
use Encode qw(from_to); |
|
|
1
|
|
|
|
|
13250
|
|
|
|
1
|
|
|
|
|
130
|
|
|
45
|
1
|
|
|
1
|
|
1434
|
use HTML::TreeBuilder; |
|
|
1
|
|
|
|
|
46523
|
|
|
|
1
|
|
|
|
|
42
|
|
|
46
|
1
|
|
|
1
|
|
1479
|
use WWW::Mechanize; |
|
|
1
|
|
|
|
|
233431
|
|
|
|
1
|
|
|
|
|
666
|
|
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
$VERSION = '0.16'; |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head1 CLASS METHODS |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head2 new |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
new(username => $username, password => $password) |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=cut |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub new { |
|
60
|
1
|
|
|
1
|
1
|
21
|
my($class, %options) = @_; |
|
61
|
|
|
|
|
|
|
|
|
62
|
1
|
|
|
|
|
3
|
foreach my $opt (qw(username password)){ |
|
63
|
2
|
50
|
|
|
|
8
|
croak "Option $opt not provided\n" unless $options{$opt}; |
|
64
|
|
|
|
|
|
|
} |
|
65
|
|
|
|
|
|
|
|
|
66
|
1
|
|
|
|
|
7
|
my $self = { |
|
67
|
|
|
|
|
|
|
username => $options{username}, |
|
68
|
|
|
|
|
|
|
password => $options{password}, |
|
69
|
|
|
|
|
|
|
}; |
|
70
|
|
|
|
|
|
|
|
|
71
|
1
|
|
|
|
|
3
|
bless $self, $class; |
|
72
|
1
|
|
|
|
|
5
|
return $self; |
|
73
|
|
|
|
|
|
|
} |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head1 OBJECT METHODS |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head2 get_allowances |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
get_allowances() |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
Logs into the My Account section of the T-Mobile website and parses out the |
|
82
|
|
|
|
|
|
|
Allowance information if available. |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=cut |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub get_allowances { |
|
87
|
0
|
|
|
0
|
1
|
0
|
my($self) = @_; |
|
88
|
|
|
|
|
|
|
|
|
89
|
0
|
|
|
|
|
0
|
my $content = $self->_login(); |
|
90
|
|
|
|
|
|
|
|
|
91
|
0
|
|
|
|
|
0
|
return $self->_parse_allowances($content); |
|
92
|
|
|
|
|
|
|
} |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
# PRIVATE METHODS |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
sub _login { |
|
97
|
0
|
|
|
0
|
|
0
|
my($self) = @_; |
|
98
|
|
|
|
|
|
|
|
|
99
|
0
|
|
|
|
|
0
|
my $agent = WWW::Mechanize->new(); |
|
100
|
0
|
|
|
|
|
0
|
$agent->get('http://www.t-mobile.co.uk/Dispatcher'); |
|
101
|
0
|
|
|
|
|
0
|
$agent->form_name('login'); |
|
102
|
0
|
|
|
|
|
0
|
$agent->current_form->value('username', $self->{username}); |
|
103
|
0
|
|
|
|
|
0
|
$agent->current_form->value('password', $self->{password}); |
|
104
|
0
|
|
|
|
|
0
|
$agent->submit(); |
|
105
|
0
|
|
|
|
|
0
|
return $agent->content; |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
} |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
sub _logout { |
|
110
|
0
|
|
|
0
|
|
0
|
croak "Not implemented yet\n"; |
|
111
|
|
|
|
|
|
|
} |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
sub _parse_allowances { |
|
114
|
1
|
|
|
1
|
|
214
|
my($self, $html) = @_; |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
# Build Tree |
|
117
|
1
|
|
|
|
|
13
|
my $tree = HTML::TreeBuilder->new_from_content($html); |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
# Find the td tag with the news stories in it |
|
120
|
|
|
|
|
|
|
# Thankfully it has a width which no other |
|
121
|
1
|
|
|
|
|
119530
|
my @tags = $tree->look_down(_tag => 'tr', id=> 'allwValueRow'); |
|
122
|
|
|
|
|
|
|
|
|
123
|
1
|
50
|
|
|
|
8725
|
croak "Allowances not found on T-Mobile site at present time\n" unless @tags; |
|
124
|
|
|
|
|
|
|
|
|
125
|
1
|
|
|
|
|
4
|
my @text = grep {!/^$/ } map {$_->as_text; } @tags; |
|
|
2
|
|
|
|
|
43
|
|
|
|
2
|
|
|
|
|
51
|
|
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
|
|
128
|
1
|
|
|
|
|
3
|
my @allowances; |
|
129
|
|
|
|
|
|
|
|
|
130
|
1
|
|
|
|
|
2
|
foreach my $text (@text) { |
|
131
|
2
|
|
|
|
|
11
|
from_to($text, 'utf8', 'iso-8859-1'); |
|
132
|
|
|
|
|
|
|
# There seems to be some weird encoding. Most of it dissappears with the conversion from UTF-8 but there are also stray ? chars |
|
133
|
2
|
|
|
|
|
145
|
$text =~ s/^(\d+)[?](\D+)$/$1 $2/; |
|
134
|
2
|
|
|
|
|
7
|
push @allowances, $text; |
|
135
|
|
|
|
|
|
|
} |
|
136
|
|
|
|
|
|
|
|
|
137
|
1
|
|
|
|
|
330
|
return \@allowances; |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
} |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
1; |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=head1 INSTALLATION |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
This module uses Module::Build for its installation. To install this module type |
|
146
|
|
|
|
|
|
|
the following: |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
perl Build.PL |
|
149
|
|
|
|
|
|
|
./Build |
|
150
|
|
|
|
|
|
|
./Build test |
|
151
|
|
|
|
|
|
|
./Build install |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
If you do not have Module::Build type: |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
perl Makefile.PL |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
to fetch it. Or use CPAN or CPANPLUS and fetch it "manually". |
|
159
|
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=head1 DEPENDENCIES |
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
This module requires these other modules and libraries: |
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
Test::More |
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
Test::More is only required for testing purposes |
|
167
|
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
This module has these optional dependencies: |
|
169
|
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
Test::Distribution |
|
171
|
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
This is just requried for testing purposes. |
|
173
|
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
=head1 TODO |
|
175
|
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
If find this module useful please do let me know and I'll spend more effort on |
|
177
|
|
|
|
|
|
|
expanding/improving it. All enhancement requests are welcome. |
|
178
|
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
=over |
|
180
|
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=item * |
|
182
|
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
_logout method (just to be nice) |
|
184
|
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
=back |
|
186
|
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
=head1 BUGS |
|
188
|
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
To report a bug or request an enhancement use CPAN's excellent Request Tracker, |
|
190
|
|
|
|
|
|
|
either via the web: |
|
191
|
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
L |
|
193
|
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
or via email: |
|
195
|
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
C |
|
197
|
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
=head1 SOURCE AVAILABILITY |
|
199
|
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
This source is part of a SourceForge project which always has the |
|
201
|
|
|
|
|
|
|
latest sources in svn. |
|
202
|
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
http://sourceforge.net/projects/sagar-r-shah/ |
|
204
|
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
=head1 AUTHOR |
|
206
|
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
Sagar R. Shah, C<< >> |
|
208
|
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
=head1 COPYRIGHT |
|
210
|
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
Copyright 2005 Sagar R. Shah, All Rights Reserved. |
|
212
|
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
|
214
|
|
|
|
|
|
|
under the same terms as Perl itself. |
|
215
|
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
=cut |