ePages 6.14.0 - DE_EPAGES/RemoteSearch/API/Object/WebserviceClient.pm

Package DE_EPAGES::RemoteSearch::API::Object::WebserviceClient

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

Functions

create
decodeResponse
encodeRequest
indexBaseUrl
indexOperationUrl
new
ping

create

Webservice client factory method

Syntax
DE_EPAGES::RemoteSearch::API::Object::WebserviceClient->create( $Shop, $hArgs );
Input
$SearchIndex (object)
This context object will be used for initializing BaseURL
and Resource parameters for the webservice client.
$hArgs (ref.hash.*)
Constructor arguments. See new for list of valid keys
Return
$Object (DE_EPAGES::RemoteSearch::API::Object::WebserviceClient)
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

indexBaseUrl

Returns absolute BaseURL of the webservice

Syntax
my $URL = $Client->indexBaseUrl();
Return
$BaseURL (URI::URL)
base url

indexOperationUrl

returns the absolute webservice url based on the operation passed (e.g. suggest) and the base URL passed in the constructor.

Syntax
my $URL = $Client->indexOperationUrl( $Operation );
Input
$Operation (string)
index operation
Return
$URL (URI::URL)
absolute URL

new

Webservice client constructor

Syntax
DE_EPAGES::RemoteSearch::API::Object::WebserviceClient->new( %args );
Input
%args (hash.*)
Constructor arguments. Valid keys are:
  • BaseURL - base url of webservice - string
  • Datasource - store used in webservice calls - string
  • Resource - guid of current object for use in webservice call - string
  • DefaultHeaders - default http headers (optional)
    default values: { 'Content-type' => 'application/json', 'Accept' => 'application/json' } - ref.hash
  • HttpClient - injected HTTP client (optional) - DE_EPAGES::RemoteSearch::API::Object::HTTPClient
  • ResponseDecoderSub - closure for decoding content from webservice (optional) - ref.code
  • RequestEncoderSub - closure for encoding content for webservice (optional) - ref.code
  • RsBasePath - alternative remote webservice base path (optional) - string
  • You may also add parameters for the communication logger. see DE_EPAGES::RemoteSearch::API::Object::HTTPClient::new
Return
$Object (DE_EPAGES::RemoteSearch::API::Object::WebserviceClient)
new object

ping

Checks if remote server is reachable via Net::Ping (ICMP) See DE_EPAGES::RemoteSearch::API::Object::HTTPClient::ping

Syntax
$Client->ping();
Return
$IsReachable (boolean)
true only if host remote response in time