NAME

Regru::API::Response - object wrapper for service answer.

METHODS

is_success

Returns 1 if API call is succeeded, 0 otherwise.

error_text

Returns error text if an error occured, default language for error messages is english. Language can be set in Regru::API constructor with lang option.

error_code

Returns error code if an error occured. Full list error codes list is available at https://www.reg.ru/support/help/API-version2#std_error_codes.

error_params

Params for error text.

my $error_params = $response->error_params;
my $detail = $error_params->{ error_detail };

is_service_fail

Returns true if API service answer code isn't 200.

my $response = $client->bill->nop(bill_id => 123213);
if ($response->is_success) {
    print "It works";
}
elsif ($response->is_service_fail) {
    print "Reg.ru API is gone :("
}
else {
    die "Error code: ". $response->error_code;
}

response

Returns HTTP::Response object with API response.

if ($api_response->is_service_fail) {
    print "HTTP code: ".$api_response->response->code;
}

get

my $value = $response->get($param_name);

Returns param value from API response, if API call is succeeded.

my $response = $client->user->get_statistics;
say "Total balance: " . $response->get("balance_total");

L<https://www.reg.ru/support/help/API-version2#user_get_statistics>

...

my $bills_answer = $client->bill->nop(bill_id => 1235);
if ($bills_answer->is_success) {
    say $bills_answer->get('bills')->[0]->{ bill_id };
}

L<https://www.reg.ru/support/help/API-version2#bill_nop>