API-Intis
view release on metacpan or search on metacpan
API/Intis/README.mkdn view on Meta::CPAN
The response object contains the following attributes:
* Request is in the form of JSON
```perl
$ballance->{request_json};
```
* Request is in the form of XML
```perl
$ballance->{request_xml};
```
* Requested text description of the error
```perl
$ballance->{error};
```
* Requested hash
```perl
$ballance->{request_object};
```
* Requested outgoing format
```perl
$ballance->{out_format};
```
* Requested method
API/Intis/lib/API/Intis.pm view on Meta::CPAN
@EXPORT_OK = qw();
%EXPORT_TAGS = ();
}
package API::Intis::APIGrab;
use YAML::Tiny;
use WWW::Mechanize;
use Crypt::SSLeay;
use Digest::Perl::MD5 'md5_hex';
use JSON;
use error_codes;
sub readConfig {
my $conf = YAML::Tiny->read( 'config.yaml' );
return (login => $conf->[0]->{APIconnector}->{login}, APIkey => $conf->[0]->{APIconnector}->{APIkey}, host => $conf->[0]->{APIconnector}->{host});
};
sub build_signature {
my (%params) = @_;
delete $params{host};
API/Intis/lib/API/Intis.pm view on Meta::CPAN
while((my $key, my $value) = each %config){
say "$key => $value\n";
next if $key eq 'host' || $key eq 'login' || $key eq 'APIkey';
$url .= "&$key=$value";
};
my $request = $ua->get("$url&return=$format")->decoded_content(charset => 'utf-8', raw => 1);
$request_json = $request if $format eq 'json';
$request_xml = $request if $format eq 'xml';
};
my $r = from_json($request_json);
my @error;
if ($r->{error}) {
@error = &error_codes::get_name_from_code($r->{error});
} else {
@error = &error_codes::get_name_from_code();
};
return (request_json => $request_json, error => \@error, request_xml => $request_xml, request_object => \%{$r}, out_format => !defined $output_format ? 'json' : $output_format );
};
package API::Intis::APIRequest;
use JSON;
sub new {
my($class, $method, $other_params) = @_;
my %request_params;
if (defined $other_params) {
%request_params = &API::Intis::APIGrab::connect($method, $other_params);
} else {
%request_params = &API::Intis::APIGrab::connect($method, '');
};
my $self = {
name => 'API::Intis::APIRequest',
version => '1.0',
method => $method,
request_json => $request_params{request_json},
error => $request_params{error},
request_xml => $request_params{request_xml},
request_object => $request_params{request_object},
out_format => $request_params{out_format},
};
bless $self, $class;
return $self;
};
1;
# The preceding line will help the module return a true value
API/Intis/lib/API/error_codes.pm view on Meta::CPAN
package error_codes;
use Modern::Perl;
use Switch;
sub get_name_from_code {
my $code = shift;
my $descr;
switch ($code // "")
{
# code keys
case "000" { $descr = 'Service unavailable'; }
( run in 0.329 second using v1.01-cache-2.11-cpan-65fba6d93b7 )