View on
MetaCPAN
Tim Keefer > eBay-API-0.25 > eBay::API::XML::BaseCall

Download:
eBay-API-0.25.tar.gz

Dependencies

Annotate this POD

CPAN RT

New  3
Open  0
View/Report Bugs
Source  

NAME ^

eBay::API::XML::BaseCall

INHERITANCE ^

eBay::API::XML::BaseCall inherits from the eBay::API::XML::BaseCallGen class

Methods ^

new()

See the parent constructor for detailed docs about object instantiation

reset()

Use 'reset' method in cases when you want to reuse a Call instance

execute()

Executes the current API call

getHttpRequestAsString()

Arguments: 1 [O] - isPrettyPrint - if set then XML is pretty printed

Returns: string Method returning a textual representation of the request (request type, url, query string, header and content).

getRequestDataType()

Returns the RequestDataType object,

getResponseDataType()

Returnst the ResponseDataType object

isHttpRequestSubmitted()

Tells to a programmer whether a request has been submitted or not. This method is mainly used in Session in sequential mode.

getHttpResponseAsString()

Method returning a textual representation of the response

  Arguments: 1 [O] - isPrettyPrint - if set then XML is pretty printed
  Returns: string

getResponseRawXml()

Method returning the raw XML reponse

getXmlSimpleDataStructure()

Returns XML::Simple data structure for a given path. Path is defined as a reference to an array of node names, starting with the top level node and ending with lowest level node.

Path IS NOT an XPATH string!!!!

Path examples for VerifyAddItem call:

  @path = ( 'Fees','Fee' );   # Returns fees as an XML::Simple data structure
  @path = ( 'Errors' );       # Returns Response errors as an XML::Simple 
                              #    data structure
  @path = ( 'Errors-xxxx' );  # Will not find anything

Notice that root node is not being specified. The reason for that is that we XML::Simple is configured not to put root node into its data structure (that is a default behaviour for XML::Simple).

If path is not submitted return the whole XML::Simple data structure

isResponseValidXml()

Access: public Returns: true (1) if a response is a valid XML document or not. false (0) if a response is NOT a valid XML document or not. Note: It allows us to differentiate cases the following cases: a) Response is a valid XML with API errors b) Response is not a valid XML document at all or HTTP connection failed. Most likely it should not be used a lot.

hasErrors()

If an API call return errors (API, HTTP connection or XML parsing errors) the application should stop normal processing and return a "system error" message to an application user. The only things that it makes sense to read from ResponseDataType objects are: errors and rawResponse (which in this case might not even be a valid XML document).

hasWarnings()

Return true if the API has errors.

getErrors()

Returns: a reference to an array of errors (it can retu This method overrides BaseCallGen::getErrors method, while _getResponseErrors is basically the same method that exists in BaseCallGen

getWarnings()

Return a reference to an array of warnings

getErrorsAndWarnings()

Returns: reference to an array

Array contains all errors returned by API call, regardless of SeverityCode Includes both SeverityCodes: 'Error' and 'Warning'

hasError()

Arguments: [0] [R] - errorCode

Returns: 1 - if an error with the given error code is found 0 - if no error with the given error code is returned

  my $boolean = $self->hasError( '304' );

getEBayOfficialTime()

Returns the officaial eBay time.

  2008-07-03T23:46:36.234Z

setRequestRawXml()

Method for setting some raw xml content to be used for the request.

  my $call = new eBay::API::XML::Call::FetchToken(
      site_id => 0,
      proxy   => __API_URL__,
      dev_id  => __DEVELOPER_ID__,
      app_id  => __APPLICATION_ID__,
      cert_id => __CERT_ID__,
      user_auth_token => __AUTH_TOKEN__, 
  );
  
  $call->setRequestRawXml('<?xml version="1.0" encoding="UTF-8"?>
      <FetchTokenRequest xmlns="urn:ebay:apis:eBLBaseComponents">
      <SecretID>
        R2n6MQr@LDMAABeDFY8.1025449191.1198127665.563330
      </SecretID>
      <RequesterCredentials><Username>__USERNAME__</Username>
      </RequesterCredentials>
      </FetchTokenRequest>'
  );

  $call->execute();
  print $call->getResponseRawXml();

getRequestRawXml()

Method returning the raw XML request content

forceError()

This method is used to force a given error when a call is being executed. If the forced error is set, then that error is being returned by the call without executing the call (sending request to the API Server and receiving the response.

This method is used for test purposes when a programmer wants to test how the application handles an API error.

Arguments: This method uses named argument calling style that looks like this:

  $self->forceError ( sErrorCode => '1025', sShortMsg => 'Test API error', ... );

       Required arguments
           1 - sErrorCode - API error code
           2 - sShortMsg  - short error message
           3 - sLongMsg   - long error message
       Optional arguments
           4 - sSeverityCode - severity code
                 default severity code:
                     eBay::API::XML::DataType::Enum::SeverityCodeType::Error
           5 - sErrorClassificationCode - error classification code
                 default error classification code
                     eBay::API::XML::DataType::Enum::ErrorClassificationCodeType::SystemError

Example:

  $call->forceError (
    'sErrorCode' => '1025'
    ,'sShortMsg' => 'Test error short message'
    ,'sLongMsg' => 'Test error long message'
  );

processResponse()

Method resonsible for process the http response when it arrives.

ABSTRACT METHODS ^

Methods that HAVE TO BE IMPLEMENTED IN each specific API CALL

getApiCallName()

An abstract method - it has to be implemented in a class extending BaseCall class

getRequestDataTypeFullPackage()

An abstract method - it has to be implemented in a class extending BaseCall class

getResponseDataTypeFullPackage()

An abstract method - it has to be implemented in a class extending BaseCall class

syntax highlighting: