The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Marketplace::Ebay::Response - Generic response parser for ebay api calls

SYNOPSIS

  my $ebay = Marketplace::Ebay->new(...);
  my $res = $ebay->api_call('GeteBayOfficialTime', {});
  if (defined($res)) {
      my $parsed = Marketplace::Ebay::Response->new(struct => $res);
      print "OK" if $parsed->is_success;
      if (defined $parsed->fees) {
          print "Total fees are " . $parsed->total_fees;
      }
  }

ACCESSORS

The constructor asks for a struct key where the api_call return value should be saved. This module provide some convenience routines.

struct

The XML data deserialized into a perl hashref. It should be the return value of Marketplace::Ebay's api_call, if defined.

SHORTCUTS

Given that we can't know beforehand which kind of response we have, depending on the API version and on the used XSD, the convention for all these shortcuts is to return undef when we can't reliably provide an answer (this is true for booleans as well, which return 0 or 1). undef means that we don't know, so you're recommend to inspect the struct yourself to make sense of the unknown, if you're expecting something.

is_success

Boolean.

version

The API version of the remote site.

item_id

The ItemID (if any) of the response

ack

The Ack key of the response (acknowledge)

start_time

The StartTime (if any) of the response (auction start time)

start_time_dt

The StartTime (if any) of the response (auction start time) as a DateTime object.

end_time

The EndTime (if any) of the response (auction end time)

end_time_dt

The EndTime (if any) as a DateTime object

timestamp

The timestamp of the response.

timestamp_dt

The timestamp of the response as a DateTime object.

errors

The unmodified Errors structure

errors_count

The number of errors

is_error_code($code)

Check if the error has the code passed as argument. It checks if all the errors reported have this code.

has_error_code($code)

Check if the error code passed as argument is present in the response and return the count of the matching errors.

error_codes

Return a plain list of error codes found in the response.

errors_as_string

A single string with the errors found in the response. If you need more detailed info, you have to inspect errors yourself.

is_failure

Return true if the acknowledge says Failure or PartialFailure.

is_warning

Return true if the acknowledge says Warning.

request_ok

Return true if the response was successful or just with warnings.

sku

The SKU key of the response data.

fees

The fees detail returned by an add_item (or equivalent) call.

total_listing_fee

As per documentation: The total cost of all listing features is found in the Fees container whose Name is ListingFee. This does not reflect the full cost of listing and selling an item on eBay, for the Final Value Fee cannot be calculated by eBay until the listing has ended, when a final sale price is known. Total cost is then the sum of the Final Value Fee and the Fee corresponding to ListingFee.

http://developer.ebay.com/DevZone/guides/ebayfeatures/Development/Listing-Fees.html