WebService::Hexonet::Connector::ResponseTemplate - Library that provides basic functionality to access API response data.
This module is internally used by the WebService::Hexonet::Connector::Response module as described below. To be used in the way:
# specify the API plain-text response (this is just an example that won't fit to the command above)
$plain = "[RESPONSE]\r\nCODE=200\r\nDESCRIPTION=Command completed successfully\r\nEOF\r\n";
# create a new instance
$r = WebService::Hexonet::Connector::ResponseTemplate->new($plain);
The difference of this library and the Response library is simply that this library
HEXONET Backend API always responds in plain-text format that needs to get parsed into a useful data structure. This module manages all this: parsing data into hash format. It provides different methods to access the data to fit your needs. It is used as base class for WebService::Hexonet::Connector::Response. We internally use this module also in our automated tests to play with hardcoded API responses.
new( $plain )Returns a new WebService::Hexonet::Connector::ResponseTemplate instance. Specify the plain-text API response as $plain.
getCodeReturns the API response code as int.
getDescriptionReturns the API response description as string.
getPlainReturns the plain-text API response as string.
getQueuetimeReturns the Queuetime of the API response as decimal.
getHashReturns the API response as Hash.
getRuntimeReturns the Runtime of the API response code as decimal.
isErrorChecks if the API response code represents an error case. 500 <= Code <= 599 Returns boolean 0 or 1.
isSuccessChecks if the API response code represents a success case. 200 <= Code <= 299 Returns boolean 0 or 1.
isTmpErrorChecks if the API response code represents a temporary error case. 400 <= Code <= 499 Returns boolean 0 or 1.
isPendingChecks if current operation is returned as pending. Returns boolean 0 or 1.
This program is licensed under the MIT License.
Hey! The above document had some coding errors, which are explained below:
=over should be: '=over' or '=over positive_number'
You forgot a '=back' before '=head1'