ePages 7.19.0 - DE_EPAGES/EPagesJ/API/Object/RestClient.pm

Package DE_EPAGES::EPagesJ::API::Object::RestClient

Base Webservice class for index / search and suggest webservice clients.

Functions

create
decodeResponse
encodeRequest
new

create

Webservice client factory method

Syntax
DE_EPAGES::EPagesJ::API::Object::RestClient->create( $Object, $hArgs );
Input
$Object (object)
This context object will be used for initializing
Resource parameters for the webservice client.
$hArgs (ref.hash.*)
Constructor arguments. See new for list of valid keys
Return
$Object (DE_EPAGES::EPagesJ::API::Object::RestClient)
new object

decodeResponse

Decodes the response. By default this is decode_json($Content). An alternative behaviour can be set by passing ResponseDecoderSub in in the constructor.

Syntax
my $DecodedContent = $Client->decodeResponse( $Content );
Input
$Content (string)
HTTP response content
Return
$DecodedContent (any)
decoded content

encodeRequest

encodes the request. By default this is encode_json($Content). An alternative behaviour can be set by passing RequestEncoderSub in in the constructor.

Syntax
my $EncodedContent = $Client->encodeRequest( $Content );
Input
$Content (any)
HTTP request content
Return
$EncodedContent (any)
encoded content

new

Webservice client constructor

Syntax
DE_EPAGES::EPagesJ::API::Object::RestClient->new( %args );
Input
%args (hash.*)
Constructor arguments. Valid keys are:
  • DefaultHeaders - default http headers (optional)
    default values: { 'Content-type' => 'application/json', 'Accept' => 'application/json' } - ref.hash
  • HttpClient - injected HTTP client (optional) - DE_EPAGES::EPagesJ::API::Object::HTTPClient
  • ResponseDecoderSub - closure for decoding content from webservice (optional) - ref.code
  • RequestEncoderSub - closure for encoding content for webservice (optional) - ref.code
  • You may also add parameters for the communication logger. see DE_EPAGES::EPagesJ::API::Object::HTTPClient::new
Return
$Object (DE_EPAGES::EPagesJ::API::Object::RestClient)
new object