-
-
14 Sep 2020 11:44:05 UTC
- Distribution: Regru-API
- Module version: 0.051
- Source (raw)
- Browse (raw)
- Changes
- Homepage
- How to Contribute
- Repository
- Issues (0)
- Testers (259 / 7 / 0)
- Kwalitee
Bus factor: 5- 89.78% Coverage
- License: perl_5
- Perl: v5.8.9
- Activity
24 month- Tools
- Download (49.7KB)
- MetaCPAN Explorer
- Permissions
- Subscribe to distribution
- Permalinks
- This version
- Latest version
and 2 contributors-
Polina Shubina
-
Anton Gerasimov
NAME
Regru::API::Response - REG.API v2 response wrapper
VERSION
version 0.051
SYNOPSIS
my $resp = Regru::API::Response->new( response => $response, );
ATTRIBUTES
is_service_fail
Flag to show whether or not the most last answer from the API service has not been finished with code HTTP 200.
$resp = $client->bill->nop(bill_id => 123213); if ($resp->is_success) { print "It works!"; } elsif ($resp->is_service_fail) { print "Reg.ru API is gone :("; } else { print "Error code: ". $resp->error_code; }
is_success
Flag to show whether or not the most last API request has been successful.
See example for "is_service_fail".
response
Contains a HTTP::Response object for the most last API request.
if ($resp->is_service_fail) { print "HTTP code: " . $resp->response->code; }
answer
Contains decoded answer for the most last successful API request.
if ($resp->is_success) { print Dumper($resp->answer); }
This is useful for debugging;
error_code
Contains error code for the most last API request if it has not been successful.
Full list error codes list is available at REG.API Common error codes.
error_text
Contains common error text for the most last API request if it has not been successful.
Default language is enlish. Language can be changed by passing option
lang
to the Regru::API constructor.error_params
Contains additional parameters included into the common error text.
$error_params = $resp->error_params; print "Details: " . $error_params->{error_detail};
debug
A few messages will be printed to STDERR. Default value is 0 (suppressed debug activity).
METHODS
new
Creates a response object from REG.API response. Available options:
- response
-
Required. This should be a result of HTTP request to REG.API. In general, is a HTTP::Response object returned by LWP::UserAgent.
- debug
-
Not required. Print some debugging messages to STDERR. Default value is 0. Because of this contructor invoked from Regru::API::Role::Client mainly so this option sets to the value which passed to Regru::API constructor.
get
Gets a value from stored in answer.
$resp = $client->user->get_statistics; print "Account balance: " . $resp->get("balance_total");
SEE ALSO
BUGS
Please report any bugs or feature requests on the bugtracker website https://github.com/regru/regru-api-perl/issues
When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.
AUTHORS
Polina Shubina <shubina@reg.ru>
Anton Gerasimov <a.gerasimov@reg.ru>
COPYRIGHT AND LICENSE
This software is copyright (c) 2013 by REG.RU LLC.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
Module Install Instructions
To install Regru::API, copy and paste the appropriate command in to your terminal.
cpanm Regru::API
perl -MCPAN -e shell install Regru::API
For more information on module installation, please visit the detailed CPAN module installation guide.