NAME
HTTP::API::Client - API Client
USAGE
use HTTP::API::Client;
my $ua1 = HTTP::API::Client->new;
my $ua2 = HTTP::API::Client->new(base_url => URI->new( $url ) );
my $ua3 = HTTP::API::Client->new(base_url => URI->new( $url ) );
$ua->send( $method, $url, \%data, \%header );
Send short hand methods - get, post, head, put and delete
Example:
$ua->get( $url ) same as $ua->send( GET, $url );
$ua->post( $url, \%data, \%headers ) same as $ua->send( GET, $url, \%data, \%headers );
Get Json Data - grab the content body from the response and json decode
my $data = $ua->json_response;
At the moment, only support query string and json data in and out
ENVIRONMENT VARIABLES
These enviornment variables expose the control without changing the existing code.
HTTP VARIABLES
HTTP_USERNAME - basic auth username
HTTP_PASSWORD - basic auth password
HTTP_AUTH_TOKEN - basic auth token string
HTTP_CHARSET - content type charset. default utf8
HTTP_TIMEOUT - timeout the request for ??? seconds. default 60 seconds.
SSL_VERIFY - verify ssl url. default is off
DEBUG VARIABLES
DEBUG_IN_OUT - print out request and response in string to STDERR
DEBUG_SEND_OUT - print out request in string to STDERR
DEBUG_RESPONSE - print out response in string to STDERR
DEBUG_RESPONSE_HEADER_ONLY - print out response header only without the body
DEBUG_RESPONSE_IF_FAIL - only print out response in string if fail.
RETRY VARIABLES
RETRY_FAIL_RESPONSE - number of time to retry if resposne comes back is failed. default 0 retry
RETRY_FAIL_STATUS - only retry if specified status code. e.g. 500,404
RETRY_DELAY - retry with wait time of ??? seconds in between