Akado-Account
view release on metacpan or search on metacpan
lib/Akado/Account.pm view on Meta::CPAN
package Akado::Account;
{
$Akado::Account::VERSION = '1.2.0';
}
# ABSTRACT: get internet provider Akado account info
use strict;
use warnings FATAL => 'all';
use utf8;
use Carp;
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) = @_;
my $data = $self->_get_cached_parsed_data();
return $data->{balance};
}
sub get_next_month_payment {
my ($self) = @_;
my $data = $self->_get_cached_parsed_data();
return $data->{next_month_payment};
}
sub _get_cached_parsed_data {
my ($self) = @_;
if (not defined $self->{_parsed_data}) {
my $xml = $self->_get_full_account_info_xml();
$self->{_parsed_data} = $self->_parse_xml($xml);
}
return $self->{_parsed_data};
}
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);
( run in 1.967 second using v1.01-cache-2.11-cpan-8f98c5d2c55 )