Akado-Account
view release on metacpan or search on metacpan
151617181920212223242526272829303132333435
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
131415161718192021222324252627282930313233use
LWP;
use
XML::XPath;
sub
new {
my
(
$class
,
$self
) =
@_
;
croak
'No login specified, stopped'
unless
$self
->{login};
croak
'No password specified, stopped'
unless
$self
->{password};
bless
(
$self
,
$class
);
return
$self
;
}
sub
get_balance {
my
(
$self
) =
@_
;
lib/Akado/Account.pm view on Meta::CPAN
585960616263646566676869707172737475767778sub
_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
979899100101102103104105106107108109110111112113114115sub
_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
207208209210211212213214215216217218219220221222223224225226227=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 )