Akado-Account

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN

15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
    Every module method dies in case of error.
 
METHODS
  new
    This a constuctor. It creates object. The constractor will not access
    the account site. All network interaction is made in the methods that
    return data.
 
        my $aa = Akado::Account->new({
            login => $login,
            password => $password,
        });
 
  get_balance
    It will return number. The number is the sum of money that is left on
    the user account. The currencty is RUB (Russian rouble).
 
        say $aa->get_balance();     # will print '749.82', or something like this
 
    If the object hasn't accessed the Akado account site
    https://office.akado.ru/ since the object was created, the method will

lib/Akado/Account.pm  view on Meta::CPAN

13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
use Digest::MD5 qw(md5_hex);
use LWP;
 
 
sub new {
    my ($class, $self) = @_;
 
    croak 'No login specified, stopped' unless $self->{login};
    croak 'No password specified, stopped' unless $self->{password};
 
    $self->{site} ||= 'https://office.akado.ru/';
 
    bless($self, $class);
    return $self;
}
 
 
sub get_balance {
    my ($self) = @_;

lib/Akado/Account.pm  view on Meta::CPAN

58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
 
sub _get_full_account_info_xml {
    my ($self) = @_;
 
    my $browser = LWP::UserAgent->new;
    $browser->agent("Akado::Account/$Akado::Account::VERSION");
    $browser->cookie_jar( {} );
 
    # At first we need to login to the site.
    # Here we POST login/password and recieve session cookies that are stored
    # in the UserAgent cookie_jar.
    my $auth_response = $self->_get_auth_response($browser);
 
    # Here we get account data using session cookies that we got at the
    # previous step
    my $data_response = $self->_get_data_response($browser);
 
    my $xml = $data_response->decoded_content;
 
    return $xml;

lib/Akado/Account.pm  view on Meta::CPAN

97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
 
sub _get_auth_response {
    my ($self, $browser) = @_;
 
    my $url = $self->{site} . "/user/login.xml";
 
    my $request = POST($url,
        Content => [
            login    => $self->{login},
            password => $self->{password},
        ]
    );
 
    my $response = $browser->request($request);
    $self->_check_response($response);
 
    return $response;
}

lib/Akado/Account.pm  view on Meta::CPAN

207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
=head1 METHODS
 
=head2 new
 
This a constuctor. It creates object. The constractor will not access the
account site. All network interaction is made in the methods that return data.
 
    my $aa = Akado::Account->new({
        login => $login,
        password => $password,
    });
 
=head2 get_balance
 
It will return number. The number is the sum of money that is left on the
user account. The currencty is RUB (Russian rouble).
 
    say $aa->get_balance();     # will print '749.82', or something like this
 
If the object hasn't accessed the Akado account site



( run in 0.267 second using v1.01-cache-2.11-cpan-a9ef4e587e4 )