ePages 7.48.0 - DE_EPAGES/USPS/API/WebServices/Base/ServicesInterface.pm

Package DE_EPAGES::USPS::API::WebServices::Base::ServicesInterface

It manages operations from XMLrequest and XMLresponse modules, required operate with USPS Web Services

Functions

callWebService
constructor
createCaller
createRequest
getCaller
getErrorResponseDescriptionOrEmpty
getErrorResponseHelpContextOrEmpty
getErrorResponseHelpFileOrEmpty
getErrorResponseNumberOrEmpty
getErrorResponseSourceOrEmpty
getRequest
getRequestNodeContentOrError
getResponse
getResponseArrayNodesContentOrEmpty
getResponseErrorNodeContentOrEmpty
getResponseNodeContentOrEmpty
getResponseNodeContentOrError
getResponseNodesOrEmpty
isErrorResponse
isValidRequestOrError
isValidResponse
isValidResponseOrError
requestToString
responseToString
setCaller
setRequestNodeAttributeOrError
setRequestNodeBooleanValueOrError
setRequestNodeEnumValueOrError

callWebService

If request is well validated, it calls USPS web service and gets the answer.

Syntax
$self->callWebService();
Input
$LogFilterCode (code ref)
code to hide sensitive data

constructor

Creates a new Service Interface object .

Syntax
$ServicesInterface = $self->constructor($ShippingFulfillmentMethod,$APItag,$RequestFilePath,$Client);
Input
$ShippingFulfillmentMethod (object)
Shipping Fulfillment Method
$APItag (object)
Tag of the required API
$RequestFilePath (object)
File Pathe of the XML constructor
$Client (object)
Client object -only used for mocking-
Return
$ServiceInterface (object)
ServicesInterface object

createCaller

It creates and returns the Caller object.

Syntax
$Caller = $self->createCaller();
Input
$APIcallDll (string)
DLL string to be used for the web service
$APItag (string)
API tag for the web service
$URLtoBeCalled (string)
web server URL for the web service
$Client (object)
Remote Client object -only used for mocking-
Return
$Caller (object)
Caller object

createRequest

It creates and returns the XMLrequest object.

Syntax
$XMLrequest = $self->createRequest();
Input
$RequestFilePath
string
Return
$XMLrequest (object)
XMLrequest object

getCaller

It returns the Caller object.

Syntax
$Caller = $self->getCaller();
Return
$Caller (object)
Caller object

getErrorResponseDescriptionOrEmpty

It checks that the response is of APItag type, that the node name exists for the response and returns the content. It returns an empty string if no node can be found.

Syntax
getErrorResponseDescriptionOrEmpty(  );
Return
$ErrorDescription (String)
Error description

getErrorResponseHelpContextOrEmpty

It checks that the response is of APItag type, that the node name exists for the response and returns the content. It returns an empty string if no node can be found.

Syntax
getErrorResponseHelpContextOrEmpty(  );
Return
$HelpContext (String)
Error Help Context

getErrorResponseHelpFileOrEmpty

It checks that the response is of APItag type, that the node name exists for the response and returns the content. It returns an empty string if no node can be found.

Syntax
getErrorResponseHelpFileOrEmpty(  );
Return
$HelpFile (String)
Error Help File

getErrorResponseNumberOrEmpty

It checks that the response is of APItag type, that the node name exists for the response and returns the content. It returns an empty string if no node can be found.

Syntax
getErrorResponseNumberOrEmpty(  );
Return
$ErrorNumber (String)
Error Number

getErrorResponseSourceOrEmpty

It checks that the response is of APItag type, that the node name exists for the response and returns the content. It returns an empty string if no node can be found.

Syntax
getErrorResponseSourceOrEmpty(  );
Return
$ErrorSource (String)
Error Source

getRequest

It returns the XMLrequest object.

Syntax
$XMLrequest = $self->getRequest();
Return
$XMLrequest (object)
XMLrequest object

getRequestNodeContentOrError

It checks that the node name exists for the request and returns the content. It throws an error if no node can be found.

Syntax
$nodeContent = $self->getRequestNodeContentOrError($nodeName);
Input
$nodeName
string
Return
(string)
$nodeContent

getResponse

It returns the XMLresponse object.

Syntax
$XMLresponse = $self->getResponse();
Return
$XMLresponse (object)
XMLresponse object

getResponseArrayNodesContentOrEmpty

It checks that the response is of APItag type, that the node name exists for the response and returns the array content of all nodes with that node name. It returns an empty array if no node can be found.

Syntax
@NodesContent = $self->getResponseArrayNodesContentOrEmpty($APItag, $nodeName);
Input
$APItag (string)
API type name
$nodeName
string
Return
(array)
@NodesContent

getResponseErrorNodeContentOrEmpty

It checks that the node name exists for the response and returns the content. It returns an empty string if no node can be found.

Syntax
$nodeContent = $self->getResponseErrorNodeContentOrEmpty($nodeName);
Input
$nodeName
string
Return
(string)
$nodeContent

getResponseNodeContentOrEmpty

It checks that the response is of APItag type, that the node name exists for the response and returns the content. It returns an empty string if no node can be found.

Syntax
$nodeContent = $self->getResponseNodeContentOrEmpty($APItag, $nodeName);
Input
$APItag (string)
API type name
$nodeName
string
Return
(string)
$nodeContent

getResponseNodeContentOrError

It checks that the response is of APItag type, that the node name exists for the response and returns the content. It throws an error if node can't be found.

Syntax
$nodeContent = $self->getResponseNodeContentOrError($APItag, $nodeName);
Input
$APItag (string)
API type name
$nodeName
string
Return
(string)
$nodeContent

getResponseNodesOrEmpty

It checks that the response is of APItag type, that the node name exists for the response and returns an array including all nodes with that node name. It returns an empty array if no node can be found.

Syntax
@Nodes = $self->getResponseNodesOrEmpty($APItag, $nodeName);
Input
$APItag (string)
API type name
$nodeName
string
Return
@Nodes (array)
array of nodes object

isErrorResponse

It checks that the response is an error response.

Syntax
$isError = $self->isErrorResponse();
Return
(boolean)
$isError

isValidRequestOrError

It checks validity of the request based on documented (already known) requirements. It returns 1 (true) or throws an error.

Syntax
$isValid = $self->isValidRequestOrError();
Return
(boolean)
$isValid

isValidResponse

It checks that the response is a valid API type response or not.

Syntax
$isValid = $self->isValidResponse($APItag);
Input
$APItag (string)
API type name
Return
(boolean)
$isValid

isValidResponseOrError

It checks that the response is of API web service type. If it's not, it throws an error.

Syntax
$isValid = $self->isValidResponseOrError($APItag);
Input
$APItag (string)
API tag name
Return
(boolean)
$isValid

requestToString

It returns the request XML structure as a string.

Syntax
$XML = $self->requestToString();
Return
$XML (string)
XML string

responseToString

It returns the response XML structure as a string.

Syntax
$XML = $self->responseToString();
Return
$XML (string)
XML string

setCaller

It returns the Caller object.

Syntax
$self->setCaller($Caller);
Input
$Caller (object)
Caller object

setRequestNodeAttributeOrError

It sets the provided attribute value into the also provided attribute name for the specified XML node.

Syntax
$self->setRequestNodeAttributeOrError($nodeName, $attributeName, $attributeValue);
Input
$nodeName (string)
node name from request object
$attributeName (string)
attribute name from node
$attributeValue (string)
value to be set

setRequestNodeBooleanValueOrError

It sets the boolean provided value ('true' or 'false') into the XML booleanAttribute structure of the web service object. It throws an error if booleanAttribute is not found or booleanValue is not defined or not valid.

Syntax
$self->setRequestNodeBooleanValueOrError($booleanAttribute, $booleanValue);
Input
$booleanAttribute (string)
XML attribute
$booleanValue (integer)
integer number (1 / 0)

setRequestNodeEnumValueOrError

It sets the provided enumValue into the enumAttribute for the request XML structure of the web service object. It throws an error if enumAttribute is not found or enumValue is not defined or not valid.

Syntax
$self->setRequestNodeEnumValueOrError($enumAttribute, $enumValue);
Input
$enumAttribute (string)
XML attribute
$enumValue (string)
enumerated value