API-Intis

 view release on metacpan or  search on metacpan

API/Intis/LICENSE  view on Meta::CPAN

not include anything that is normally distributed (in either source or binary form)
with the major components (compiler, kernel, and so on) of the operating system
on which the executable runs, unless that component itself accompanies the
executable.

If distribution of executable or object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the source
code from the same place counts as distribution of the source code, even though
third parties are not compelled to copy the source along with the object code.

4. You may not copy, modify, sublicense, or distribute the Program except as
expressly provided under this License. Any attempt otherwise to copy, modify,
sublicense or distribute the Program is void, and will automatically terminate
your rights under this License. However, parties who have received copies, or
rights, from you under this License will not have their licenses terminated so long
as such parties remain in full compliance.

5. You are not required to accept this License, since you have not signed it.
However, nothing else grants you permission to modify or distribute the Program
or its derivative works. These actions are prohibited by law if you do not accept
this License. Therefore, by modifying or distributing the Program (or any work
based on the Program), you indicate your acceptance of this License to do so,
and all its terms and conditions for copying, distributing or modifying the
Program or works based on it.

6. Each time you redistribute the Program (or any work based on the Program),
the recipient automatically receives a license from the original licensor to copy,
distribute or modify the Program subject to these terms and conditions. You
may not impose any further restrictions on the recipients' exercise of the rights
granted herein. You are not responsible for enforcing compliance by third parties
to this License.

7. If, as a consequence of a court judgment or allegation of patent infringement
or for any other reason (not limited to patent issues), conditions are imposed on
you (whether by court order, agreement or otherwise) that contradict the
conditions of this License, they do not excuse you from the conditions of this
License. If you cannot distribute so as to satisfy simultaneously your obligations
under this License and any other pertinent obligations, then as a consequence

API/Intis/LICENSE  view on Meta::CPAN

charge a fee for this Package itself. However, you may distribute this Package in
aggregate with other (possibly commercial) programs as part of a larger
(possibly commercial) software distribution provided that you do not advertise
this Package as a product of your own.

6. The scripts and library files supplied as input to or produced as output from
the programs of this Package do not automatically fall under the copyright of this
Package, but belong to whomever generated them, and may be sold
commercially, and may be aggregated with this Package.

7. C or perl subroutines supplied by you and linked into this Package shall not
be considered part of this Package.

8. Aggregation of this Package with a commercial distribution is always permitted
provided that the use of this Package is embedded; that is, when no overt attempt
is made to make this Package's interfaces visible to the end user of the
commercial distribution. Such use shall not be construed as a distribution of
this Package.

9. The name of the Copyright Holder may not be used to endorse or promote
products derived from this software without specific prior written permission.

API/Intis/lib/API/Intis.pm  view on Meta::CPAN


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};
    my $APIkey = delete $params{APIkey};
    my @ssignature;
    foreach my $key(sort keys %params){
        say "$key => $params{$key}";
        push @ssignature, $params{$key};
    };
    return md5_hex join('', @ssignature).$APIkey;
};

sub connect {
    my ($method, $other_params) = @_;
    my $ua = WWW::Mechanize->new(ssl_opts => { verify_hostname => 0 } );
    $ua->cookie_jar(HTTP::Cookies->new());
    $ua->agent_alias('Linux Mozilla');
    my %config = &readConfig();
    my $timestamp = $ua->get('https://go.intistele.com/external/get/timestamp.php')->content( raw => 1 );
    my %timestamp = (timestamp => $timestamp);
    my $output_format;
    if ($other_params ne '') {
        my %other_params = %{$other_params};

API/Intis/lib/API/Intis.pm  view on Meta::CPAN

    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',

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'; }
        case "1"         { $descr = 'Signature not specified';  }
        case "2"         { $descr = 'Login not specified';  }
        case "3"         { $descr = 'Text not specified';  }
        case "4"         { $descr = 'Phone number not specified';  }



( run in 1.620 second using v1.01-cache-2.11-cpan-88abd93f124 )