Akado-Account

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN

    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

use Digest::MD5 qw(md5_hex);
use HTTP::Request::Common;
use 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};

    $self->{site} ||= 'https://office.akado.ru/';

    bless($self, $class);
    return $self;
}


sub get_balance {
    my ($self) = @_;

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



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



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


=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 1.210 second using v1.01-cache-2.11-cpan-49f99fa48dc )