| 1 | package Marketplace::Ebay; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 4 | ▶ | use 5.010001; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 4 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 4 | ▶ | use warnings FATAL => 'all'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 4 | ▶ | use HTTP::Thin; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 4 | ▶ | use HTTP::Request; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 4 | ▶ | use HTTP::Headers; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 4 | ▶ | use XML::LibXML; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 4 | ▶ | use XML::Compile::Schema; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | 4 | ▶ | use XML::Compile::Util qw/pack_type/; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | 4 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | 4 | ▶ | use XML::LibXML::Simple; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | 4 | ▶ | use Marketplace::Ebay::Response; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 16 | 4 | ▶ | use Marketplace::Ebay::Order; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 4 | ▶ | use Moo; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 19 | 4 | ▶ | use MooX::Types::MooseLike::Base qw(:all); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 20 | 4 | ▶ | use namespace::clean; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | =head1 NAME | ||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | Marketplace::Ebay - Making API calls to eBay (with XSD validation) | ||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | =head1 VERSION | ||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | Version 0.17 | ||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | =cut | ||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | 4 | our $VERSION = '0.17'; | |||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | my $ebay = Marketplace::Ebay->new( | ||||||||||||||||||||||||||||
| 37 | production => 0, | ||||||||||||||||||||||||||||
| 38 | site_id => 77, | ||||||||||||||||||||||||||||
| 39 | developer_key => '1234', | ||||||||||||||||||||||||||||
| 40 | application_key => '6789', | ||||||||||||||||||||||||||||
| 41 | certificate_key => '6666', | ||||||||||||||||||||||||||||
| 42 | token => 'asd12348', | ||||||||||||||||||||||||||||
| 43 | xsd_file => 'ebay.xsd', | ||||||||||||||||||||||||||||
| 44 | ); | ||||||||||||||||||||||||||||
| 45 | my $res = $ebay->api_call('GeteBayOfficialTime', {}); | ||||||||||||||||||||||||||||
| 46 | print Dumper($res); | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | L<http://developer.ebay.com/Devzone/XML/docs/Concepts/MakingACall.html> | ||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | =head2 International Selling | ||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | Products propagate from your local selling account to all Ebay sites | ||||||||||||||||||||||||||||
| 56 | where you are going to ship your items to: | ||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | L<http://sellercentre.ebay.co.uk/advanced-international-selling> | ||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | =head1 ACCESSORS | ||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | =head2 Credentials | ||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | The following are required for a successful API call. | ||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | =head3 developer_key | ||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | =head3 application_key | ||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | =head3 certificate_key | ||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | =head3 token | ||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | =head3 site_id | ||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | The id of the site. E.g., Germany is 77. | ||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | L<https://developer.ebay.com/DevZone/merchandising/docs/Concepts/SiteIDToGlobalID.html> | ||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | =head3 xsd_file | ||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | Path to the XSD file with the eBay definitions. | ||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | http://developer.ebay.com/webservices/latest/ebaySvc.xsd | ||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | =head3 production | ||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | Boolean. Default to false. | ||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | By default, the API calls are done against the sandbox. Set it to true | ||||||||||||||||||||||||||||
| 91 | in production. | ||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | =head3 endpoint | ||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | Set lazily by the class depending on the C<production> value. | ||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||
| 97 | =head3 compatibility_level | ||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||
| 99 | The version of API and XSD used. Please keep this in sync with the XSD. | ||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | =head3 last_response | ||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||
| 103 | You can get the HTTP::Response object of the last call using this | ||||||||||||||||||||||||||||
| 104 | accessor. | ||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | =head2 last_request | ||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | You can get the HTTP::Request object of the last call using this | ||||||||||||||||||||||||||||
| 109 | accessor. | ||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||
| 111 | =head3 last_parsed_response | ||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||
| 113 | Return a L<Marketplace::Ebay::Response> object (or undef on failure) | ||||||||||||||||||||||||||||
| 114 | out of the return value of the last C<api_call>. | ||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||
| 116 | =head3 log_file | ||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||
| 118 | A filename where to log requests and responses. | ||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||
| 120 | =cut | ||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||
| 122 | 4 | has developer_key => (is => 'ro', required => 1); | |||||||||||||||||||||||||||
| 123 | 4 | has application_key => (is => 'ro', required => 1); | |||||||||||||||||||||||||||
| 124 | 4 | has certificate_key => (is => 'ro', required => 1); | |||||||||||||||||||||||||||
| 125 | 4 | has token => (is => 'ro', required => 1); | |||||||||||||||||||||||||||
| 126 | 4 | has site_id => (is => 'ro', required => 1); | |||||||||||||||||||||||||||
| 127 | 4 | has site_code => (is => 'lazy'); | |||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||
| 129 | sub _build_site_code { | ||||||||||||||||||||||||||||
| 130 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
_build_site_code: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 131 | 0 | my $code = $self->ebay_sites_id_to_name->{$self->site_id}; | |||||||||||||||||||||||||||
| 132 | 0 | ▶ | die $self->site_id . " doesn't map to a site name!" unless $code; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 133 | 0 | return $code; | |||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||
| 136 | # totally random, as per Net::eBay | ||||||||||||||||||||||||||||
| 137 | has compatibility_level => (is => 'ro', | ||||||||||||||||||||||||||||
| 138 | 2 | ▶ | default => sub { '655' }); | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||
| 140 | 4 | has session_certificate => (is => 'lazy'); | |||||||||||||||||||||||||||
| 141 | 0 | ▶ | has production => (is => 'ro', default => sub { 0 }); | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||
| 142 | 4 | has endpoint => (is => 'lazy'); | |||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||
| 144 | 4 | has last_response => (is => 'rwp'); | |||||||||||||||||||||||||||
| 145 | 4 | has last_parsed_response => (is => 'rwp'); | |||||||||||||||||||||||||||
| 146 | 4 | has last_request => (is => 'rwp'); | |||||||||||||||||||||||||||
| 147 | 4 | has log_file => (is => 'rw'); | |||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||
| 149 | sub _build_endpoint { | ||||||||||||||||||||||||||||
| 150 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
_build_endpoint: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 151 | 0 | ▶ | if ($self->production) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 152 | 0 | return 'https://api.ebay.com/ws/api.dll'; | |||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||
| 154 | else { | ||||||||||||||||||||||||||||
| 155 | 0 | return 'https://api.sandbox.ebay.com/ws/api.dll'; | |||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||
| 159 | sub _build_session_certificate { | ||||||||||||||||||||||||||||
| 160 | 1 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
_build_session_certificate: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 161 | 1 | return join(';', | |||||||||||||||||||||||||||
| 162 | $self->developer_key, | ||||||||||||||||||||||||||||
| 163 | $self->application_key, | ||||||||||||||||||||||||||||
| 164 | $self->certificate_key); | ||||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||
| 167 | 4 | has xsd_file => (is => 'ro', required => 1); | |||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||
| 169 | 4 | has schema => (is => 'lazy'); | |||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||
| 171 | sub _build_schema { | ||||||||||||||||||||||||||||
| 172 | 2 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
_build_schema: called CC=2 SCAR=7.6
| |||||||||||||||||||||||||||||
| 173 | 2 | my $xsd_file = $self->xsd_file; | |||||||||||||||||||||||||||
| 174 | 2 | ▶ | die "$xsd_file is not a file" unless -f $xsd_file; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 175 | 0 | return XML::Compile::Schema->new($self->xsd_file); | |||||||||||||||||||||||||||
| 176 | } | ||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||
| 179 | =head1 METHODS | ||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||
| 181 | =head2 api_call($name, \%data, \%options) | ||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||
| 183 | Do the API call $name with payload in %data. Return the data structure | ||||||||||||||||||||||||||||
| 184 | of the L<Marketplace::Ebay::Response> object. In case of failure, | ||||||||||||||||||||||||||||
| 185 | return nothing. In this case, you can inspect the details of the | ||||||||||||||||||||||||||||
| 186 | failure inspecting, e.g., | ||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||
| 188 | $self->last_response->status_line; | ||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||
| 190 | With option C<requires_struct> set to a true value, the method doesn't | ||||||||||||||||||||||||||||
| 191 | return the object, but a plain hashref with the structure returned | ||||||||||||||||||||||||||||
| 192 | (old behaviour). | ||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||
| 194 | With an option C<no_validate>, the XML is parsed using XMLin, not the | ||||||||||||||||||||||||||||
| 195 | schema, so the result could be unstable, but on the other hand, you | ||||||||||||||||||||||||||||
| 196 | get something out of XML which doesn't comply with the schema. | ||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||
| 198 | =head2 prepare_xml($name, \%data) | ||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||
| 200 | Create the XML document to send for the API call $name. | ||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||
| 202 | =head2 show_xml_template($call, $call_type) | ||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||
| 204 | Utility for development. Show the expected structure for the API call | ||||||||||||||||||||||||||||
| 205 | $call. The second argument is optional, and may be Request or | ||||||||||||||||||||||||||||
| 206 | Response, defaulting to Request. | ||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||
| 208 | =head2 log_event(@data) | ||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||
| 210 | Append the arguments to the C<log_file>, if it was defined. | ||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||
| 212 | =cut | ||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||
| 214 | sub api_call { | ||||||||||||||||||||||||||||
| 215 | 0 | ▶ | my ($self, $call, $data, $options) = @_; | ||||||||||||||||||||||||||
|
Subroutine
api_call: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||
| 216 | 0 | ▶ | $options ||= {}; | ||||||||||||||||||||||||||
|
Condition0%0/2
$options ||= {}
MC/DC0%0/1
$options ||= {}
$options
Truth table0%0/2
A
A= $options
| |||||||||||||||||||||||||||||
| 217 | 0 | $self->log_event("Preparing call to $call for " . Dumper($data)); | |||||||||||||||||||||||||||
| 218 | 0 | my $xml = $self->prepare_xml($call, $data); | |||||||||||||||||||||||||||
| 219 | 0 | my $headers = $self->_prepare_headers($call); | |||||||||||||||||||||||||||
| 220 | 0 | my $request = HTTP::Request->new(POST => $self->endpoint, $headers, $xml); | |||||||||||||||||||||||||||
| 221 | 0 | $self->_set_last_request($request); | |||||||||||||||||||||||||||
| 222 | 0 | $self->log_event("Doing $call request\n" . $request->as_string); | |||||||||||||||||||||||||||
| 223 | 0 | my $response = HTTP::Thin->new->request($request); | |||||||||||||||||||||||||||
| 224 | 0 | $self->_set_last_response($response); | |||||||||||||||||||||||||||
| 225 | 0 | $self->log_event("Retrieving $call response\n" . $response->as_string); | |||||||||||||||||||||||||||
| 226 | 0 | $self->_set_last_parsed_response(undef); | |||||||||||||||||||||||||||
| 227 | 0 | ▶ | if ($response->is_success) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 228 | 0 | my $struct; | |||||||||||||||||||||||||||
| 229 | 0 | ▶ | if ($options->{no_validate}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 230 | 0 | $struct = XMLin($response->decoded_content); | |||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||
| 232 | else { | ||||||||||||||||||||||||||||
| 233 | 0 | $struct = $self->_parse_response($call, $response->decoded_content) | |||||||||||||||||||||||||||
| 234 | } | ||||||||||||||||||||||||||||
| 235 | 0 | ▶ | if ($struct) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 236 | 0 | my $obj = Marketplace::Ebay::Response->new(struct => $struct); | |||||||||||||||||||||||||||
| 237 | 0 | $self->_set_last_parsed_response($obj); | |||||||||||||||||||||||||||
| 238 | 0 | $self->log_event("Got response:" . Dumper($struct)); | |||||||||||||||||||||||||||
| 239 | 0 | ▶ | if ($options->{requires_struct}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 240 | 0 | return $struct; | |||||||||||||||||||||||||||
| 241 | } | ||||||||||||||||||||||||||||
| 242 | else { | ||||||||||||||||||||||||||||
| 243 | 0 | return $obj; | |||||||||||||||||||||||||||
| 244 | } | ||||||||||||||||||||||||||||
| 245 | } | ||||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||
| 247 | 0 | return; | |||||||||||||||||||||||||||
| 248 | } | ||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||
| 250 | sub _parse_response { | ||||||||||||||||||||||||||||
| 251 | 1 | ▶ | my ($self, $call, $xml) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_parse_response: called CC=1 SCAR=2.6
| |||||||||||||||||||||||||||||
| 252 | 1 | my $reader = $self->schema->compile(READER => $self->_xml_type($call, | |||||||||||||||||||||||||||
| 253 | 'Response')); | ||||||||||||||||||||||||||||
| 254 | 0 | my $struct; | |||||||||||||||||||||||||||
| 255 | 0 | eval { | |||||||||||||||||||||||||||
| 256 | 0 | $struct = $reader->($xml); | |||||||||||||||||||||||||||
| 257 | }; | ||||||||||||||||||||||||||||
| 258 | 0 | return $struct; | |||||||||||||||||||||||||||
| 259 | } | ||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||
| 261 | sub log_event { | ||||||||||||||||||||||||||||
| 262 | 0 | ▶ | my ($self, @strings) = @_; | ||||||||||||||||||||||||||
|
Subroutine
log_event: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||
| 263 | 0 | ▶ | if (my $file = $self->log_file) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 264 | 0 | ▶ | open (my $fh, '>>', $file) or die "Cannot open $file $!"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 265 | 0 | my $now = "\n" . localtime() . "\n"; | |||||||||||||||||||||||||||
| 266 | 0 | print $fh $now, @strings; | |||||||||||||||||||||||||||
| 267 | 0 | ▶ | close $fh or die "Cannot close $file $!"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 268 | } | ||||||||||||||||||||||||||||
| 269 | } | ||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||
| 271 | sub _prepare_headers { | ||||||||||||||||||||||||||||
| 272 | 0 | ▶ | my ($self, $call) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_prepare_headers: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 273 | 0 | my $headers = HTTP::Headers->new; | |||||||||||||||||||||||||||
| 274 | 0 | $headers->push_header('X-EBAY-API-COMPATIBILITY-LEVEL' => $self->compatibility_level); | |||||||||||||||||||||||||||
| 275 | 0 | $headers->push_header('X-EBAY-API-DEV-NAME' => $self->developer_key); | |||||||||||||||||||||||||||
| 276 | 0 | $headers->push_header('X-EBAY-API-APP-NAME' => $self->application_key); | |||||||||||||||||||||||||||
| 277 | 0 | $headers->push_header('X-EBAY-API-CERT-NAME' => $self->certificate_key); | |||||||||||||||||||||||||||
| 278 | 0 | $headers->push_header('X-EBAY-API-CALL-NAME' => $call); | |||||||||||||||||||||||||||
| 279 | 0 | $headers->push_header('X-EBAY-API-SITEID' => $self->site_id); | |||||||||||||||||||||||||||
| 280 | 0 | $headers->push_header('Content-Type' => 'text/xml'); | |||||||||||||||||||||||||||
| 281 | 0 | return $headers; | |||||||||||||||||||||||||||
| 282 | } | ||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||
| 284 | sub show_xml_template { | ||||||||||||||||||||||||||||
| 285 | 0 | ▶ | my ($self, $call, $call_type) = @_; | ||||||||||||||||||||||||||
|
Subroutine
show_xml_template: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 286 | 0 | return $self->schema->template(PERL => $self->_xml_type($call, $call_type), | |||||||||||||||||||||||||||
| 287 | use_default_namespace => 1); | ||||||||||||||||||||||||||||
| 288 | } | ||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||
| 290 | sub _xml_type { | ||||||||||||||||||||||||||||
| 291 | 0 | ▶ | my ($self, $call, $call_type) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_xml_type: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||
| 292 | 0 | ▶ | $call_type ||= 'Request'; | ||||||||||||||||||||||||||
|
Condition0%0/2
$call_type ||= "Request"
MC/DC0%0/1
$call_type ||= "Request"
$call_type
Truth table0%0/2
A
A= $call_type
| |||||||||||||||||||||||||||||
| 293 | 0 | ▶ | die "Second argument must be Request or Response, defaulting to Request" | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$call_type eq "Request" or $call_type eq "Response"
MC/DC0%0/2
$call_type eq "Request" or $call_type eq "Response"
$call_type eq "Request"
$call_type eq "Response"
Truth table0%0/3
A or B
A= $call_type eq "Request"B= $call_type eq "Response"
| |||||||||||||||||||||||||||||
| 294 | unless ($call_type eq 'Request' or $call_type eq 'Response'); | ||||||||||||||||||||||||||||
| 295 | 0 | return pack_type('urn:ebay:apis:eBLBaseComponents', $call . $call_type); | |||||||||||||||||||||||||||
| 296 | } | ||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||
| 298 | sub prepare_xml { | ||||||||||||||||||||||||||||
| 299 | 0 | ▶ | my ($self, $name, $data) = @_; | ||||||||||||||||||||||||||
|
Subroutine
prepare_xml: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 300 | 0 | ▶ | $data ||= {}; | ||||||||||||||||||||||||||
|
Condition0%0/2
$data ||= {}
MC/DC0%0/1
$data ||= {}
$data
Truth table0%0/2
A
A= $data
| |||||||||||||||||||||||||||||
| 301 | # inject the token | ||||||||||||||||||||||||||||
| 302 | 0 | $data->{RequesterCredentials}->{eBayAuthToken} = $self->token; | |||||||||||||||||||||||||||
| 303 | 0 | my $doc = XML::LibXML::Document->new('1.0', 'UTF-8'); | |||||||||||||||||||||||||||
| 304 | 0 | my $type = $self->_xml_type($name); | |||||||||||||||||||||||||||
| 305 | 0 | my $write = $self->schema->compile(WRITER => $type, | |||||||||||||||||||||||||||
| 306 | use_default_namespace => 1); | ||||||||||||||||||||||||||||
| 307 | 0 | my $xml = $write->($doc, $data); | |||||||||||||||||||||||||||
| 308 | 0 | $doc->setDocumentElement($xml); | |||||||||||||||||||||||||||
| 309 | 0 | return $doc->toString(1); | |||||||||||||||||||||||||||
| 310 | } | ||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||
| 312 | =head1 CONVENIENCE METHODS | ||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||
| 314 | =cut | ||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||
| 316 | =head2 api_call_wrapper($call, $data, @ids) | ||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||
| 318 | Call Ebay's API $call with data $data. Then check the response and | ||||||||||||||||||||||||||||
| 319 | return it. This ends calling $self->api_call($call, $data), but after | ||||||||||||||||||||||||||||
| 320 | that the response is checked and diagnostics are printed out. If you | ||||||||||||||||||||||||||||
| 321 | want something quiet and which is not going to die, or you're | ||||||||||||||||||||||||||||
| 322 | expecting invalid structures, you should use C<api_call> directly. | ||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||
| 324 | Return the response object. If no response object is found, it will | ||||||||||||||||||||||||||||
| 325 | die. | ||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||
| 327 | =cut | ||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||
| 329 | sub api_call_wrapper { | ||||||||||||||||||||||||||||
| 330 | 0 | ▶ | my ($self, $call, $data, @identifiers) = @_; | ||||||||||||||||||||||||||
|
Subroutine
api_call_wrapper: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||
| 331 | 0 | my $res = $self->api_call($call, $data); | |||||||||||||||||||||||||||
| 332 | 0 | my $message = $call; | |||||||||||||||||||||||||||
| 333 | 0 | ▶ | if (@identifiers) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 334 | 0 | $message .= " on " . join(' ', @identifiers); | |||||||||||||||||||||||||||
| 335 | } | ||||||||||||||||||||||||||||
| 336 | 0 | ▶ | if ($res) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 337 | 0 | ▶ | if ($res->is_success) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 338 | 0 | print "$message OK\n"; | |||||||||||||||||||||||||||
| 339 | } | ||||||||||||||||||||||||||||
| 340 | elsif ($res->errors) { | ||||||||||||||||||||||||||||
| 341 | 0 | warn "$message:\n" . $res->errors_as_string; | |||||||||||||||||||||||||||
| 342 | } | ||||||||||||||||||||||||||||
| 343 | else { | ||||||||||||||||||||||||||||
| 344 | 0 | die "$message: Nor success, nor errors!" . Dumper($res); | |||||||||||||||||||||||||||
| 345 | } | ||||||||||||||||||||||||||||
| 346 | 0 | ▶ | if (my $item_id = $res->item_id) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 347 | 0 | print "$message: ebay id: $item_id\n"; | |||||||||||||||||||||||||||
| 348 | } | ||||||||||||||||||||||||||||
| 349 | 0 | my $fee = $res->total_listing_fee; | |||||||||||||||||||||||||||
| 350 | 0 | ▶ | if (defined $fee) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 351 | 0 | print "$message Fee is $fee\n"; | |||||||||||||||||||||||||||
| 352 | } | ||||||||||||||||||||||||||||
| 353 | } | ||||||||||||||||||||||||||||
| 354 | else { | ||||||||||||||||||||||||||||
| 355 | 0 | die "No response found!" . $self->last_response->status_line | |||||||||||||||||||||||||||
| 356 | . "\n" . $self->last_response->content; | ||||||||||||||||||||||||||||
| 357 | } | ||||||||||||||||||||||||||||
| 358 | 0 | return $res; | |||||||||||||||||||||||||||
| 359 | } | ||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||
| 361 | =head2 cancel_item($identifier, $id, $reason) | ||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||
| 363 | $identifier is mandatory and can be C<SKU> or C<ItemID> (depending if | ||||||||||||||||||||||||||||
| 364 | you do tracking by sku (this is possible only if the sku was uploaded | ||||||||||||||||||||||||||||
| 365 | with InventoryTrackingMethod = SKU) or by ebay item id. The $id is | ||||||||||||||||||||||||||||
| 366 | mandatory and is the sku or the ebay_id. | ||||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||
| 368 | Reason can be one of the following, defaulting to OtherListingError: Incorrect, LostOrBroken, NotAvailable, OtherListingError, SellToHighBidder, Sold. | ||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||
| 370 | It calls EndFixedPriceItem, so this method is useful only for shops. | ||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||
| 372 | =cut | ||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||
| 374 | sub cancel_item { | ||||||||||||||||||||||||||||
| 375 | 0 | ▶ | my ($self, $key, $value, $reason) = @_; | ||||||||||||||||||||||||||
|
Subroutine
cancel_item: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||
| 376 | 0 | ▶ | die "Missing SKU or ItemID" unless $key; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 377 | 0 | my %mapping = ( | |||||||||||||||||||||||||||
| 378 | SKU => 'sku', | ||||||||||||||||||||||||||||
| 379 | ItemID => 'ebay_sku', | ||||||||||||||||||||||||||||
| 380 | ); | ||||||||||||||||||||||||||||
| 381 | 0 | my %reasons = ( | |||||||||||||||||||||||||||
| 382 | Incorrect => 1, | ||||||||||||||||||||||||||||
| 383 | LostOrBroken => 1, | ||||||||||||||||||||||||||||
| 384 | NotAvailable => 1, | ||||||||||||||||||||||||||||
| 385 | OtherListingError => 1, | ||||||||||||||||||||||||||||
| 386 | SellToHighBidder => 1, | ||||||||||||||||||||||||||||
| 387 | Sold => 1, | ||||||||||||||||||||||||||||
| 388 | ); | ||||||||||||||||||||||||||||
| 389 | 0 | ▶ | die "Invalid key $key" unless $mapping{$key}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 390 | 0 | ▶ | unless ($reason && $reasons{$reason}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$reason and $reasons{$reason}
MC/DC0%0/2
$reason and $reasons{$reason}
$reason
$reasons{$reason}
Truth table0%0/3
A and B
A= $reasonB= $reasons{$reason}
| |||||||||||||||||||||||||||||
| 391 | 0 | $reason = 'OtherListingError'; | |||||||||||||||||||||||||||
| 392 | } | ||||||||||||||||||||||||||||
| 393 | 0 | ▶ | die "Missing $key" unless $value; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 394 | 0 | my $res = $self | |||||||||||||||||||||||||||
| 395 | ->api_call_wrapper(EndFixedPriceItem => { | ||||||||||||||||||||||||||||
| 396 | EndingReason => $reason, | ||||||||||||||||||||||||||||
| 397 | ErrorLanguage => 'en_US', | ||||||||||||||||||||||||||||
| 398 | $key => $value, | ||||||||||||||||||||||||||||
| 399 | }, $key, $value); | ||||||||||||||||||||||||||||
| 400 | 0 | return $res; | |||||||||||||||||||||||||||
| 401 | } | ||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||
| 403 | =head2 delete_sku_variations($sku, \@list_of_sku_variations) | ||||||||||||||||||||||||||||
| 404 | |||||||||||||||||||||||||||||
| 405 | It uses ReviseFixedPriceItem to cancel variations of a given sku | ||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||
| 407 | https://developer.ebay.com/DevZone/xml/docs/Reference/ebay/Samples/ReviseFixedPriceItem_variationsDeleteSKU_in_xml_xml.txt | ||||||||||||||||||||||||||||
| 408 | |||||||||||||||||||||||||||||
| 409 | =cut | ||||||||||||||||||||||||||||
| 410 | |||||||||||||||||||||||||||||
| 411 | sub delete_sku_variations { | ||||||||||||||||||||||||||||
| 412 | 0 | ▶ | my ($self, $sku, $list) = @_; | ||||||||||||||||||||||||||
|
Subroutine
delete_sku_variations: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 413 | 0 | ▶ | die unless $sku && $list; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$sku and $list
MC/DC0%0/2
$sku and $list
$sku
$list
Truth table0%0/3
A and B
A= $skuB= $list
| |||||||||||||||||||||||||||||
| 414 | 0 | my @delete = map { +{ | |||||||||||||||||||||||||||
| 415 | 0 | Delete => 1, | |||||||||||||||||||||||||||
| 416 | SKU => $_, | ||||||||||||||||||||||||||||
| 417 | } } @$list; | ||||||||||||||||||||||||||||
| 418 | 0 | my $data = { | |||||||||||||||||||||||||||
| 419 | ErrorLanguage => 'en_US', | ||||||||||||||||||||||||||||
| 420 | WarningLevel => 'High', | ||||||||||||||||||||||||||||
| 421 | Item => { | ||||||||||||||||||||||||||||
| 422 | SKU => $sku, | ||||||||||||||||||||||||||||
| 423 | Variations => { | ||||||||||||||||||||||||||||
| 424 | Variation => \@delete, | ||||||||||||||||||||||||||||
| 425 | } | ||||||||||||||||||||||||||||
| 426 | }, | ||||||||||||||||||||||||||||
| 427 | }; | ||||||||||||||||||||||||||||
| 428 | 0 | my $res = $self->api_call_wrapper(ReviseFixedPriceItem => $data, $sku, "delete variations"); | |||||||||||||||||||||||||||
| 429 | 0 | return $res; | |||||||||||||||||||||||||||
| 430 | } | ||||||||||||||||||||||||||||
| 431 | |||||||||||||||||||||||||||||
| 432 | =head2 get_category_specifics($id) | ||||||||||||||||||||||||||||
| 433 | |||||||||||||||||||||||||||||
| 434 | Return a dump of the structure found in the GetCategorySpecifics | ||||||||||||||||||||||||||||
| 435 | |||||||||||||||||||||||||||||
| 436 | =cut | ||||||||||||||||||||||||||||
| 437 | |||||||||||||||||||||||||||||
| 438 | sub get_category_specifics { | ||||||||||||||||||||||||||||
| 439 | 0 | ▶ | my ($self, $id) = @_; | ||||||||||||||||||||||||||
|
Subroutine
get_category_specifics: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 440 | 0 | ▶ | die "Missing category id" unless $id; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 441 | 0 | my $res = $self->api_call_wrapper(GetCategorySpecifics => { | |||||||||||||||||||||||||||
| 442 | CategoryID => $id, | ||||||||||||||||||||||||||||
| 443 | }, "category id $id"); | ||||||||||||||||||||||||||||
| 444 | 0 | return $res; | |||||||||||||||||||||||||||
| 445 | } | ||||||||||||||||||||||||||||
| 446 | |||||||||||||||||||||||||||||
| 447 | =head2 get_orders($number_of_days) | ||||||||||||||||||||||||||||
| 448 | |||||||||||||||||||||||||||||
| 449 | Retrieve the last orders in the last number of days, defaulting to 7. | ||||||||||||||||||||||||||||
| 450 | Return a list of L<Marketplace::Ebay::Order> objects. You can access | ||||||||||||||||||||||||||||
| 451 | the raw structures with $object->order. | ||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||
| 453 | =cut | ||||||||||||||||||||||||||||
| 454 | |||||||||||||||||||||||||||||
| 455 | sub get_orders { | ||||||||||||||||||||||||||||
| 456 | 0 | ▶ | my ($self, $backlog) = @_; | ||||||||||||||||||||||||||
|
Subroutine
get_orders: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||
| 457 | 0 | ▶ | $backlog ||= 7; | ||||||||||||||||||||||||||
|
Condition0%0/2
$backlog ||= 7
MC/DC0%0/1
$backlog ||= 7
$backlog
Truth table0%0/2
A
A= $backlog
| |||||||||||||||||||||||||||||
| 458 | 0 | my $request = { | |||||||||||||||||||||||||||
| 459 | NumberOfDays => $backlog, | ||||||||||||||||||||||||||||
| 460 | Pagination => { | ||||||||||||||||||||||||||||
| 461 | PageNumber => 1, | ||||||||||||||||||||||||||||
| 462 | EntriesPerPage => 100, | ||||||||||||||||||||||||||||
| 463 | }, | ||||||||||||||||||||||||||||
| 464 | ErrorLanguage => 'en_US', | ||||||||||||||||||||||||||||
| 465 | }; | ||||||||||||||||||||||||||||
| 466 | 0 | my $repeat = 1; | |||||||||||||||||||||||||||
| 467 | 0 | my @orders; | |||||||||||||||||||||||||||
| 468 | 0 | ▶ | do { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 469 | 0 | my $obj = $self->api_call_wrapper(GetOrders => $request); | |||||||||||||||||||||||||||
| 470 | 0 | my $res = $obj->struct; | |||||||||||||||||||||||||||
| 471 | 0 | ▶ | if (exists $res->{OrderArray} and | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
exists $res->{"OrderArray"} and exists $res->{"OrderArray"}{"Order"}
MC/DC0%0/2
exists $res->{"OrderArray"} and exists $res->{"OrderArray"}{"Order"}
exists $res->{"OrderArray"}
exists $res->{"OrderArray"}{"Order"}
Truth table0%0/3
A and B
A= exists $res->{"OrderArray"}B= exists $res->{"OrderArray"}{"Order"}
| |||||||||||||||||||||||||||||
| 472 | exists $res->{OrderArray}->{Order}) { | ||||||||||||||||||||||||||||
| 473 | 0 | foreach my $ord (@{$res->{OrderArray}->{Order}}) { | |||||||||||||||||||||||||||
| 474 | 0 | push @orders, Marketplace::Ebay::Order->new(order => $ord); | |||||||||||||||||||||||||||
| 475 | } | ||||||||||||||||||||||||||||
| 476 | } | ||||||||||||||||||||||||||||
| 477 | 0 | $repeat = $res->{HasMoreOrders}; | |||||||||||||||||||||||||||
| 478 | 0 | $request->{Pagination}->{PageNumber}++; | |||||||||||||||||||||||||||
| 479 | } while ($repeat); | ||||||||||||||||||||||||||||
| 480 | |||||||||||||||||||||||||||||
| 481 | 0 | return @orders; | |||||||||||||||||||||||||||
| 482 | } | ||||||||||||||||||||||||||||
| 483 | |||||||||||||||||||||||||||||
| 484 | =head2 get_orders_for_site | ||||||||||||||||||||||||||||
| 485 | |||||||||||||||||||||||||||||
| 486 | Like get_orders, but filter the orders by the site_id of the object | ||||||||||||||||||||||||||||
| 487 | (otherwise you pull the orders from all the international sites). | ||||||||||||||||||||||||||||
| 488 | |||||||||||||||||||||||||||||
| 489 | =cut | ||||||||||||||||||||||||||||
| 490 | |||||||||||||||||||||||||||||
| 491 | sub get_orders_for_site { | ||||||||||||||||||||||||||||
| 492 | 0 | ▶ | my ($self, $backlog) = @_; | ||||||||||||||||||||||||||
|
Subroutine
get_orders_for_site: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 493 | 0 | my @orders = $self->get_orders($backlog); | |||||||||||||||||||||||||||
| 494 | 0 | my $name = $self->site_code; | |||||||||||||||||||||||||||
| 495 | 0 | return grep { $_->ebay_site eq $name } @orders; | |||||||||||||||||||||||||||
| 496 | } | ||||||||||||||||||||||||||||
| 497 | |||||||||||||||||||||||||||||
| 498 | =head2 ebay_site_code_types (internal) | ||||||||||||||||||||||||||||
| 499 | |||||||||||||||||||||||||||||
| 500 | L<http://developer.ebay.com/devzone/XML/docs/Reference/ebay/types/SiteCodeType.html> | ||||||||||||||||||||||||||||
| 501 | turned into an hashref to map the site name to an id. | ||||||||||||||||||||||||||||
| 502 | |||||||||||||||||||||||||||||
| 503 | =head2 ebay_sites_name_to_id | ||||||||||||||||||||||||||||
| 504 | |||||||||||||||||||||||||||||
| 505 | Return an hashref for mapping ebay site names and abbreviations to a numeric id. | ||||||||||||||||||||||||||||
| 506 | |||||||||||||||||||||||||||||
| 507 | =head2 ebay_sites_id_to_name | ||||||||||||||||||||||||||||
| 508 | |||||||||||||||||||||||||||||
| 509 | Return an hashref for mapping ebay site id to its name. | ||||||||||||||||||||||||||||
| 510 | # http://developer.ebay.com/devzone/XML/docs/Reference/ebay/types/SiteCodeType.html | ||||||||||||||||||||||||||||
| 511 | |||||||||||||||||||||||||||||
| 512 | =cut | ||||||||||||||||||||||||||||
| 513 | |||||||||||||||||||||||||||||
| 514 | sub ebay_site_code_types { | ||||||||||||||||||||||||||||
| 515 | |||||||||||||||||||||||||||||
| 516 | 0 | ▶ | my %codes = ( | ||||||||||||||||||||||||||
|
Subroutine
ebay_site_code_types: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 517 | Australia => { id => 15, abbreviation => "AU" }, | ||||||||||||||||||||||||||||
| 518 | Austria => { id => 16, abbreviation => "AT" }, | ||||||||||||||||||||||||||||
| 519 | Belgium_Dutch => { id => 123, abbreviation => "BENL" }, | ||||||||||||||||||||||||||||
| 520 | Belgium_French => { id => 23, abbreviation => "BEFR" }, | ||||||||||||||||||||||||||||
| 521 | Canada => { id => 2, abbreviation => "CA" }, | ||||||||||||||||||||||||||||
| 522 | CanadaFrench => { id => 210, abbreviation => "CAFR" }, | ||||||||||||||||||||||||||||
| 523 | France => { id => 71, abbreviation => "FR" }, | ||||||||||||||||||||||||||||
| 524 | Germany => { id => 77, abbreviation => "DE" }, | ||||||||||||||||||||||||||||
| 525 | HongKong => { id => 201, abbreviation => "HK" }, | ||||||||||||||||||||||||||||
| 526 | India => { id => 203, abbreviation => "IN" }, | ||||||||||||||||||||||||||||
| 527 | Ireland => { id => 205, abbreviation => "IE" }, | ||||||||||||||||||||||||||||
| 528 | Italy => { id => 101, abbreviation => "IT" }, | ||||||||||||||||||||||||||||
| 529 | Malaysia => { id => 207, abbreviation => "MY" }, | ||||||||||||||||||||||||||||
| 530 | Netherlands => { id => 146, abbreviation => "NL" }, | ||||||||||||||||||||||||||||
| 531 | Philippines => { id => 211, abbreviation => "PH" }, | ||||||||||||||||||||||||||||
| 532 | Poland => { id => 212, abbreviation => "PL" }, | ||||||||||||||||||||||||||||
| 533 | Russia => { id => 215, abbreviation => "RU" }, | ||||||||||||||||||||||||||||
| 534 | Singapore => { id => 216, abbreviation => "SG" }, | ||||||||||||||||||||||||||||
| 535 | Spain => { id => 186, abbreviation => "ES" }, | ||||||||||||||||||||||||||||
| 536 | Switzerland => { id => 193, abbreviation => "CH" }, | ||||||||||||||||||||||||||||
| 537 | UK => { id => 3, abbreviation => "UK" }, | ||||||||||||||||||||||||||||
| 538 | US => { id => 0, abbreviation => "US" }, | ||||||||||||||||||||||||||||
| 539 | ); | ||||||||||||||||||||||||||||
| 540 | 0 | return %codes; | |||||||||||||||||||||||||||
| 541 | } | ||||||||||||||||||||||||||||
| 542 | |||||||||||||||||||||||||||||
| 543 | sub ebay_sites_name_to_id { | ||||||||||||||||||||||||||||
| 544 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
ebay_sites_name_to_id: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 545 | 0 | my %out; | |||||||||||||||||||||||||||
| 546 | 0 | my %codes = $self->ebay_site_code_types; | |||||||||||||||||||||||||||
| 547 | 0 | foreach my $k (keys %codes) { | |||||||||||||||||||||||||||
| 548 | 0 | $out{$k} = $codes{$k}{id}; | |||||||||||||||||||||||||||
| 549 | 0 | $out{$codes{$k}{abbreviation}} = $codes{$k}{id}; | |||||||||||||||||||||||||||
| 550 | } | ||||||||||||||||||||||||||||
| 551 | 0 | return \%out; | |||||||||||||||||||||||||||
| 552 | } | ||||||||||||||||||||||||||||
| 553 | |||||||||||||||||||||||||||||
| 554 | sub ebay_sites_id_to_name { | ||||||||||||||||||||||||||||
| 555 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
ebay_sites_id_to_name: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 556 | 0 | my %codes = $self->ebay_site_code_types; | |||||||||||||||||||||||||||
| 557 | 0 | my %out; | |||||||||||||||||||||||||||
| 558 | 0 | foreach my $k (keys %codes) { | |||||||||||||||||||||||||||
| 559 | 0 | $out{$codes{$k}{id}} = $k; | |||||||||||||||||||||||||||
| 560 | } | ||||||||||||||||||||||||||||
| 561 | 0 | return \%out; | |||||||||||||||||||||||||||
| 562 | } | ||||||||||||||||||||||||||||
| 563 | |||||||||||||||||||||||||||||
| 564 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 565 | |||||||||||||||||||||||||||||
| 566 | Marco Pessotto, C<< <melmothx at gmail.com> >> | ||||||||||||||||||||||||||||
| 567 | |||||||||||||||||||||||||||||
| 568 | =head1 BUGS | ||||||||||||||||||||||||||||
| 569 | |||||||||||||||||||||||||||||
| 570 | Please report any bugs or feature requests to C<bug-marketplace-ebay at rt.cpan.org>, or through | ||||||||||||||||||||||||||||
| 571 | the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Marketplace-Ebay>. I will be notified, and then you'll | ||||||||||||||||||||||||||||
| 572 | automatically be notified of progress on your bug as I make changes. | ||||||||||||||||||||||||||||
| 573 | |||||||||||||||||||||||||||||
| 574 | |||||||||||||||||||||||||||||
| 575 | |||||||||||||||||||||||||||||
| 576 | |||||||||||||||||||||||||||||
| 577 | =head1 SUPPORT | ||||||||||||||||||||||||||||
| 578 | |||||||||||||||||||||||||||||
| 579 | You can find documentation for this module with the perldoc command. | ||||||||||||||||||||||||||||
| 580 | |||||||||||||||||||||||||||||
| 581 | perldoc Marketplace::Ebay | ||||||||||||||||||||||||||||
| 582 | |||||||||||||||||||||||||||||
| 583 | |||||||||||||||||||||||||||||
| 584 | You can also look for information at: | ||||||||||||||||||||||||||||
| 585 | |||||||||||||||||||||||||||||
| 586 | =over 4 | ||||||||||||||||||||||||||||
| 587 | |||||||||||||||||||||||||||||
| 588 | =item * RT: CPAN's request tracker (report bugs here) | ||||||||||||||||||||||||||||
| 589 | |||||||||||||||||||||||||||||
| 590 | L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Marketplace-Ebay> | ||||||||||||||||||||||||||||
| 591 | |||||||||||||||||||||||||||||
| 592 | =item * AnnoCPAN: Annotated CPAN documentation | ||||||||||||||||||||||||||||
| 593 | |||||||||||||||||||||||||||||
| 594 | L<http://annocpan.org/dist/Marketplace-Ebay> | ||||||||||||||||||||||||||||
| 595 | |||||||||||||||||||||||||||||
| 596 | =item * CPAN Ratings | ||||||||||||||||||||||||||||
| 597 | |||||||||||||||||||||||||||||
| 598 | L<http://cpanratings.perl.org/d/Marketplace-Ebay> | ||||||||||||||||||||||||||||
| 599 | |||||||||||||||||||||||||||||
| 600 | =item * Search CPAN | ||||||||||||||||||||||||||||
| 601 | |||||||||||||||||||||||||||||
| 602 | L<http://search.cpan.org/dist/Marketplace-Ebay/> | ||||||||||||||||||||||||||||
| 603 | |||||||||||||||||||||||||||||
| 604 | =back | ||||||||||||||||||||||||||||
| 605 | |||||||||||||||||||||||||||||
| 606 | |||||||||||||||||||||||||||||
| 607 | =head1 ACKNOWLEDGEMENTS | ||||||||||||||||||||||||||||
| 608 | |||||||||||||||||||||||||||||
| 609 | |||||||||||||||||||||||||||||
| 610 | =head1 LICENSE AND COPYRIGHT | ||||||||||||||||||||||||||||
| 611 | |||||||||||||||||||||||||||||
| 612 | Copyright 2014 Marco Pessotto. | ||||||||||||||||||||||||||||
| 613 | |||||||||||||||||||||||||||||
| 614 | This program is free software; you can redistribute it and/or modify it | ||||||||||||||||||||||||||||
| 615 | under the terms of either: the GNU General Public License as published | ||||||||||||||||||||||||||||
| 616 | by the Free Software Foundation; or the Artistic License. | ||||||||||||||||||||||||||||
| 617 | |||||||||||||||||||||||||||||
| 618 | See L<http://dev.perl.org/licenses/> for more information. | ||||||||||||||||||||||||||||
| 619 | |||||||||||||||||||||||||||||
| 620 | |||||||||||||||||||||||||||||
| 621 | =cut | ||||||||||||||||||||||||||||
| 622 | |||||||||||||||||||||||||||||
| 623 | 4 | 1; # End of Marketplace::Ebay | |||||||||||||||||||||||||||