| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Amazon::MWS::Routines; |
|
2
|
|
|
|
|
|
|
|
|
3
|
8
|
|
|
9
|
|
5013
|
use URI; |
|
|
8
|
|
|
|
|
34253
|
|
|
|
8
|
|
|
|
|
250
|
|
|
4
|
8
|
|
|
9
|
|
61
|
use DateTime; |
|
|
8
|
|
|
|
|
10
|
|
|
|
8
|
|
|
|
|
187
|
|
|
5
|
8
|
|
|
9
|
|
7292
|
use XML::Simple; |
|
|
8
|
|
|
|
|
63203
|
|
|
|
8
|
|
|
|
|
70
|
|
|
6
|
8
|
|
|
9
|
|
766
|
use URI::Escape; |
|
|
8
|
|
|
|
|
19
|
|
|
|
8
|
|
|
|
|
464
|
|
|
7
|
8
|
|
|
9
|
|
5045
|
use MIME::Base64; |
|
|
8
|
|
|
|
|
5638
|
|
|
|
8
|
|
|
|
|
550
|
|
|
8
|
8
|
|
|
9
|
|
4852
|
use Digest::SHA; |
|
|
8
|
|
|
|
|
23050
|
|
|
|
8
|
|
|
|
|
525
|
|
|
9
|
8
|
|
|
9
|
|
4588
|
use HTTP::Request; |
|
|
8
|
|
|
|
|
98432
|
|
|
|
8
|
|
|
|
|
294
|
|
|
10
|
8
|
|
|
9
|
|
5870
|
use LWP::UserAgent; |
|
|
8
|
|
|
|
|
162736
|
|
|
|
8
|
|
|
|
|
311
|
|
|
11
|
8
|
|
|
9
|
|
64
|
use Digest::MD5 qw(md5_base64); |
|
|
8
|
|
|
|
|
13
|
|
|
|
8
|
|
|
|
|
580
|
|
|
12
|
8
|
|
|
9
|
|
46
|
use Amazon::MWS::TypeMap qw(:all); |
|
|
8
|
|
|
|
|
16
|
|
|
|
8
|
|
|
|
|
1212
|
|
|
13
|
8
|
|
|
9
|
|
4017
|
use Amazon::MWS::Exception; |
|
|
8
|
|
|
|
|
19
|
|
|
|
8
|
|
|
|
|
269
|
|
|
14
|
8
|
|
|
9
|
|
1445
|
use Data::Dumper; |
|
|
8
|
|
|
|
|
15292
|
|
|
|
8
|
|
|
|
|
527
|
|
|
15
|
|
|
|
|
|
|
|
|
16
|
8
|
|
|
9
|
|
44
|
use Exporter qw(import); |
|
|
8
|
|
|
|
|
191
|
|
|
|
8
|
|
|
|
|
9082
|
|
|
17
|
|
|
|
|
|
|
our @EXPORT_OK = qw(define_api_method new sign_request convert force_array); |
|
18
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( all => \@EXPORT_OK ); |
|
19
|
|
|
|
|
|
|
|
|
20
|
458
|
50
|
|
459
|
0
|
1427
|
sub slurp_kwargs { ref $_[0] eq 'HASH' ? shift : { @_ } } |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub define_api_method { |
|
23
|
456
|
|
|
456
|
0
|
516
|
my $method_name = shift; |
|
24
|
456
|
|
|
|
|
640
|
my $spec = slurp_kwargs(@_); |
|
25
|
456
|
|
|
|
|
510
|
my $params = $spec->{parameters}; |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
my $method = sub { |
|
28
|
|
|
|
|
|
|
|
|
29
|
2
|
|
|
2
|
|
2828
|
my $self = shift; |
|
30
|
2
|
|
|
|
|
10
|
my $args = slurp_kwargs(@_); |
|
31
|
2
|
|
|
|
|
5
|
my $body = ''; |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
my %form = ( |
|
34
|
|
|
|
|
|
|
Action => $method_name, |
|
35
|
|
|
|
|
|
|
AWSAccessKeyId => $self->{access_key_id}, |
|
36
|
|
|
|
|
|
|
Merchant => $self->{merchant_id}, |
|
37
|
|
|
|
|
|
|
SellerId => $self->{merchant_id}, |
|
38
|
2
|
|
|
|
|
32
|
SignatureVersion => 2, |
|
39
|
|
|
|
|
|
|
SignatureMethod => 'HmacSHA256', |
|
40
|
|
|
|
|
|
|
Timestamp => to_amazon('datetime', DateTime->now), |
|
41
|
|
|
|
|
|
|
); |
|
42
|
|
|
|
|
|
|
|
|
43
|
2
|
|
|
|
|
1321
|
foreach my $name (keys %$params) { |
|
44
|
4
|
|
|
|
|
6
|
my $param = $params->{$name}; |
|
45
|
4
|
100
|
|
|
|
9
|
unless (exists $args->{$name}) { |
|
46
|
1
|
50
|
|
|
|
3
|
Amazon::MWS::Exception::MissingArgument->throw(name => $name) if $param->{required}; |
|
47
|
1
|
|
|
|
|
3
|
next; |
|
48
|
|
|
|
|
|
|
} |
|
49
|
|
|
|
|
|
|
|
|
50
|
3
|
|
|
|
|
5
|
my $type = $param->{type}; |
|
51
|
3
|
|
|
|
|
3
|
my $array_names = $param->{array_names}; |
|
52
|
3
|
|
|
|
|
5
|
my $value = $args->{$name}; |
|
53
|
|
|
|
|
|
|
|
|
54
|
3
|
50
|
|
|
|
8
|
if ($type =~ /^List$/) { |
|
55
|
0
|
|
|
|
|
0
|
my %valuehash; |
|
56
|
0
|
|
|
|
|
0
|
@valuehash{@{$param->{values}}}=(); |
|
|
0
|
|
|
|
|
0
|
|
|
57
|
0
|
0
|
|
|
|
0
|
Amazon::MWS::Exception::Invalid->throw(field => $name, value=>$value) unless (exists ($valuehash{$value})); |
|
58
|
0
|
|
|
|
|
0
|
$form{$name} = $value; |
|
59
|
0
|
|
|
|
|
0
|
next; |
|
60
|
|
|
|
|
|
|
} |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
# Odd 'structured list' notation handled here |
|
63
|
3
|
50
|
|
|
|
7
|
if ($type =~ /(\w+)List/) { |
|
64
|
0
|
|
|
|
|
0
|
my $list_type = $1; |
|
65
|
0
|
0
|
|
|
|
0
|
Amazon::MWS::Exception::Invalid->throw(field => $name, value=>$value, message=>"$name should be of type ARRAY") unless (ref $value eq 'ARRAY'); |
|
66
|
0
|
|
|
|
|
0
|
my $counter = 1; |
|
67
|
|
|
|
|
|
|
|
|
68
|
0
|
|
|
|
|
0
|
foreach my $sub_value (@$value) { |
|
69
|
0
|
|
|
|
|
0
|
my $listKey = "$name.$list_type." . $counter++; |
|
70
|
0
|
|
|
|
|
0
|
$form{$listKey} = $sub_value; |
|
71
|
|
|
|
|
|
|
} |
|
72
|
0
|
|
|
|
|
0
|
next; |
|
73
|
|
|
|
|
|
|
} |
|
74
|
|
|
|
|
|
|
|
|
75
|
3
|
50
|
|
|
|
10
|
if ($type =~ /(\w+)Array/) { |
|
76
|
0
|
0
|
|
|
|
0
|
Amazon::MWS::Exception::Invalid->throw(field => $name, value=>$value, message=>"$name should be of type ARRAY") unless (ref $value eq 'ARRAY'); |
|
77
|
0
|
|
|
|
|
0
|
my $list_type = $1; |
|
78
|
0
|
|
|
|
|
0
|
my $counter = 0; |
|
79
|
0
|
|
|
|
|
0
|
foreach my $sub_value (@$value) { |
|
80
|
0
|
|
|
|
|
0
|
$counter++; |
|
81
|
0
|
|
|
|
|
0
|
my $arr_col=0; |
|
82
|
0
|
|
|
|
|
0
|
foreach my $array_name (@{$array_names}) { |
|
|
0
|
|
|
|
|
0
|
|
|
83
|
0
|
0
|
|
|
|
0
|
if ( ! defined $sub_value->[$arr_col] ) { next; } |
|
|
0
|
|
|
|
|
0
|
|
|
84
|
0
|
|
|
|
|
0
|
my $listKey = "$name.$list_type." . $counter; |
|
85
|
0
|
|
|
|
|
0
|
$listKey .= ".$array_name"; |
|
86
|
0
|
|
|
|
|
0
|
$form{$listKey} = $sub_value->[$arr_col++]; |
|
87
|
|
|
|
|
|
|
} |
|
88
|
|
|
|
|
|
|
} |
|
89
|
0
|
|
|
|
|
0
|
next; |
|
90
|
|
|
|
|
|
|
} |
|
91
|
3
|
100
|
|
|
|
6
|
if ($type eq 'HTTP-BODY') { |
|
92
|
1
|
|
|
|
|
3
|
$body = $value; |
|
93
|
|
|
|
|
|
|
} |
|
94
|
|
|
|
|
|
|
else { |
|
95
|
2
|
|
|
|
|
7
|
$form{$name} = to_amazon($type, $value); |
|
96
|
|
|
|
|
|
|
} |
|
97
|
|
|
|
|
|
|
} |
|
98
|
|
|
|
|
|
|
|
|
99
|
2
|
|
50
|
|
|
13
|
$form{Version} = $spec->{version} || '2010-01-01'; |
|
100
|
|
|
|
|
|
|
|
|
101
|
2
|
100
|
|
|
|
10
|
my $endpoint = ( $spec->{service} ) ? "$self->{endpoint}$spec->{service}" : $self->{endpoint}; |
|
102
|
|
|
|
|
|
|
|
|
103
|
2
|
|
|
|
|
14
|
my $uri = URI->new($endpoint); |
|
104
|
|
|
|
|
|
|
|
|
105
|
2
|
|
|
|
|
13722
|
my $request = HTTP::Request->new; |
|
106
|
2
|
|
|
|
|
158
|
$request->protocol('HTTP/1.0'); |
|
107
|
|
|
|
|
|
|
|
|
108
|
2
|
|
|
|
|
16
|
my ($response, $content); |
|
109
|
|
|
|
|
|
|
|
|
110
|
2
|
50
|
|
|
|
12
|
$spec->{method} = 'GET' unless $spec->{method}; |
|
111
|
|
|
|
|
|
|
|
|
112
|
2
|
50
|
|
|
|
11
|
if ($spec->{method} eq 'POST') { |
|
|
|
100
|
|
|
|
|
|
|
113
|
0
|
|
|
|
|
0
|
$request->uri($uri); |
|
114
|
0
|
|
|
|
|
0
|
$request->method('POST'); |
|
115
|
0
|
|
|
|
|
0
|
$request->content($body); |
|
116
|
0
|
|
0
|
|
|
0
|
$request->content_type($args->{content_type}||'application/x-www-form-urlencoded'); |
|
117
|
0
|
|
|
|
|
0
|
my $signature = $self->sign_request($request, %form); |
|
118
|
|
|
|
|
|
|
|
|
119
|
0
|
|
|
|
|
0
|
$response = $self->agent->request($request); |
|
120
|
0
|
|
|
|
|
0
|
$content = $response->content; |
|
121
|
|
|
|
|
|
|
} elsif ($body) { |
|
122
|
1
|
|
|
|
|
4
|
$request->uri($uri); |
|
123
|
1
|
|
|
|
|
92
|
$request->method('POST'); |
|
124
|
1
|
|
|
|
|
35
|
$request->content($body); |
|
125
|
1
|
|
|
|
|
44
|
$request->header('Content-MD5' => md5_base64($body) . '=='); |
|
126
|
1
|
|
50
|
|
|
96
|
$request->content_type($args->{content_type}||'text/plain'); |
|
127
|
|
|
|
|
|
|
|
|
128
|
1
|
|
|
|
|
38
|
$self->sign_request($request, %form); |
|
129
|
1
|
|
|
|
|
5
|
$request->content($body); |
|
130
|
1
|
|
|
|
|
16
|
$response = $self->agent->request($request); |
|
131
|
1
|
|
|
|
|
240
|
$content = $response->content; |
|
132
|
|
|
|
|
|
|
} else { |
|
133
|
1
|
|
|
|
|
10
|
$uri->query_form(\%form); |
|
134
|
1
|
|
|
|
|
315
|
$request->uri($uri); |
|
135
|
1
|
|
|
|
|
34
|
$request->method('GET'); |
|
136
|
|
|
|
|
|
|
|
|
137
|
1
|
|
|
|
|
13
|
$self->sign_request($request); |
|
138
|
|
|
|
|
|
|
|
|
139
|
1
|
|
|
|
|
7
|
$response = $self->agent->request($request); |
|
140
|
1
|
|
|
|
|
546758
|
$content = $response->content; |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
} |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
|
|
145
|
2
|
50
|
|
|
|
40
|
if ($self->{debug}) { |
|
146
|
0
|
|
|
|
|
0
|
open LOG, ">>$self->{logfile}"; |
|
147
|
0
|
|
|
|
|
0
|
print LOG Dumper($response); |
|
148
|
|
|
|
|
|
|
} |
|
149
|
|
|
|
|
|
|
|
|
150
|
2
|
|
|
|
|
27
|
my $xs = XML::Simple->new( KeepRoot => 1 ); |
|
151
|
|
|
|
|
|
|
|
|
152
|
2
|
50
|
33
|
|
|
201
|
if ($response->code == 400 || $response->code == 403) { |
|
153
|
0
|
|
|
|
|
0
|
my $hash = $xs->xml_in($content); |
|
154
|
0
|
|
|
|
|
0
|
my $root = $hash->{ErrorResponse}; |
|
155
|
0
|
|
|
|
|
0
|
force_array($root, 'Error'); |
|
156
|
0
|
|
|
|
|
0
|
Amazon::MWS::Exception::Response->throw(errors => $root->{Error}, xml => $content); |
|
157
|
|
|
|
|
|
|
} |
|
158
|
|
|
|
|
|
|
|
|
159
|
2
|
50
|
|
|
|
63
|
if ($response->code == 503) { |
|
160
|
0
|
|
|
|
|
0
|
my $hash = $xs->xml_in($content); |
|
161
|
0
|
|
|
|
|
0
|
my $root = $hash->{ErrorResponse}; |
|
162
|
0
|
|
|
|
|
0
|
force_array($root, 'Error'); |
|
163
|
0
|
|
|
|
|
0
|
Amazon::MWS::Exception::Throttled->throw(errors => $root->{Error}, xml => $content); |
|
164
|
|
|
|
|
|
|
} |
|
165
|
|
|
|
|
|
|
|
|
166
|
2
|
50
|
|
|
|
29
|
unless ($response->is_success) { |
|
167
|
0
|
|
|
|
|
0
|
Amazon::MWS::Exception::Transport->throw(request => $request, response => $response); |
|
168
|
|
|
|
|
|
|
} |
|
169
|
|
|
|
|
|
|
|
|
170
|
2
|
50
|
|
|
|
35
|
if (my $md5 = $response->header('Content-MD5')) { |
|
171
|
0
|
0
|
|
|
|
0
|
Amazon::MWS::Exception::BedChecksum->throw(response => $response) |
|
172
|
|
|
|
|
|
|
unless ($md5 eq md5_base64($content) . '=='); |
|
173
|
|
|
|
|
|
|
} |
|
174
|
|
|
|
|
|
|
|
|
175
|
2
|
50
|
33
|
|
|
111
|
return $content if ($spec->{raw_body} || $args->{raw_body}); |
|
176
|
|
|
|
|
|
|
|
|
177
|
2
|
|
|
|
|
10
|
my $hash = $xs->xml_in($content); |
|
178
|
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
my $root = $hash->{$method_name . 'Response'} |
|
180
|
2
|
|
|
|
|
180223
|
->{$method_name . 'Result'}; |
|
181
|
|
|
|
|
|
|
|
|
182
|
2
|
|
|
|
|
12
|
return $spec->{respond}->($root); |
|
183
|
456
|
|
|
|
|
3398
|
}; |
|
184
|
|
|
|
|
|
|
|
|
185
|
456
|
|
100
|
|
|
1436
|
my $module_name = $spec->{module_name} || 'Amazon::MWS::Client'; |
|
186
|
456
|
|
|
|
|
771
|
my $fqn = join '::', "$module_name", $method_name; |
|
187
|
|
|
|
|
|
|
|
|
188
|
8
|
|
|
9
|
|
49
|
no strict 'refs'; |
|
|
8
|
|
|
|
|
12
|
|
|
|
8
|
|
|
|
|
6160
|
|
|
189
|
456
|
|
|
|
|
2652
|
*$fqn = $method; |
|
190
|
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
} |
|
192
|
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
sub force_array { |
|
194
|
|
|
|
|
|
|
|
|
195
|
0
|
|
|
0
|
0
|
0
|
my ($hash, $key) = @_; |
|
196
|
0
|
|
|
|
|
0
|
my $val = $hash->{$key}; |
|
197
|
|
|
|
|
|
|
|
|
198
|
0
|
0
|
|
|
|
0
|
if (!defined $val) { |
|
|
|
0
|
|
|
|
|
|
|
199
|
0
|
|
|
|
|
0
|
$val = []; |
|
200
|
|
|
|
|
|
|
} |
|
201
|
|
|
|
|
|
|
elsif (ref $val ne 'ARRAY') { |
|
202
|
0
|
|
|
|
|
0
|
$val = [ $val ]; |
|
203
|
|
|
|
|
|
|
} |
|
204
|
|
|
|
|
|
|
|
|
205
|
0
|
|
|
|
|
0
|
$hash->{$key} = $val; |
|
206
|
|
|
|
|
|
|
} |
|
207
|
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
sub sign_request { |
|
209
|
2
|
|
|
2
|
0
|
11
|
my ($self, $request, %form) = @_; |
|
210
|
|
|
|
|
|
|
|
|
211
|
2
|
|
|
|
|
7
|
my $uri = $request->uri; |
|
212
|
2
|
100
|
|
|
|
14
|
my %params = ($request->method eq 'GET' ) ? $uri->query_form : %form; |
|
213
|
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
my $canonical = join '&', map { |
|
215
|
2
|
|
|
|
|
158
|
my $param = uri_escape($_); |
|
|
18
|
|
|
|
|
41
|
|
|
216
|
18
|
|
|
|
|
229
|
my $value = uri_escape($params{$_}); |
|
217
|
18
|
|
|
|
|
201
|
"$param=$value"; |
|
218
|
|
|
|
|
|
|
} sort keys %params; |
|
219
|
|
|
|
|
|
|
|
|
220
|
2
|
|
100
|
|
|
17
|
my $path = $uri->path || '/'; |
|
221
|
2
|
|
|
|
|
38
|
my $string = $request->method . "\n" |
|
222
|
|
|
|
|
|
|
. $uri->authority . "\n" |
|
223
|
|
|
|
|
|
|
. $path . "\n" |
|
224
|
|
|
|
|
|
|
. $canonical; |
|
225
|
|
|
|
|
|
|
|
|
226
|
2
|
|
|
|
|
173
|
$params{Signature} = Digest::SHA::hmac_sha256_base64($string, $self->{secret_key}); |
|
227
|
2
|
|
|
|
|
12
|
while (length($params{Signature}) % 4) { |
|
228
|
2
|
|
|
|
|
7
|
$params{Signature} .= '='; |
|
229
|
|
|
|
|
|
|
} |
|
230
|
|
|
|
|
|
|
|
|
231
|
2
|
50
|
66
|
|
|
14
|
if ($request->{_method} eq 'GET' || $request->{_content} ) { |
|
232
|
2
|
|
|
|
|
12
|
$uri->query_form(\%params); |
|
233
|
|
|
|
|
|
|
} else { |
|
234
|
0
|
|
|
|
|
0
|
$request->{_content} = "$canonical&Signature=$params{Signature}"; |
|
235
|
|
|
|
|
|
|
} |
|
236
|
2
|
|
|
|
|
384
|
$request->uri($uri); |
|
237
|
2
|
|
|
|
|
62
|
return $request; |
|
238
|
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
} |
|
240
|
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
sub convert { |
|
242
|
1
|
|
|
1
|
0
|
3
|
my ($hash, $key, $type) = @_; |
|
243
|
1
|
|
|
|
|
7
|
$hash->{$key} = from_amazon($type, $hash->{$key}); |
|
244
|
|
|
|
|
|
|
} |
|
245
|
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
sub new { |
|
248
|
|
|
|
|
|
|
|
|
249
|
2
|
|
|
2
|
0
|
290
|
my($pkg, %opts) = @_; |
|
250
|
|
|
|
|
|
|
|
|
251
|
2
|
|
50
|
|
|
20
|
$opts{configfile} ||= 'amazon.xml'; |
|
252
|
|
|
|
|
|
|
|
|
253
|
2
|
50
|
|
|
|
62
|
if (-r $opts{configfile} ) { |
|
254
|
|
|
|
|
|
|
|
|
255
|
0
|
|
|
|
|
0
|
my $xmlconfig = XML::Simple::XMLin("$opts{configfile}"); |
|
256
|
|
|
|
|
|
|
|
|
257
|
0
|
|
0
|
|
|
0
|
$opts{access_key_id} ||= $xmlconfig->{access_key_id}; |
|
258
|
0
|
|
0
|
|
|
0
|
$opts{secret_key} ||= $xmlconfig->{secret_key}; |
|
259
|
0
|
|
0
|
|
|
0
|
$opts{merchant_id} ||= $xmlconfig->{merchant_id}; |
|
260
|
0
|
|
0
|
|
|
0
|
$opts{marketplace_id} ||= $xmlconfig->{marketplace_id}; |
|
261
|
0
|
|
0
|
|
|
0
|
$opts{endpoint} ||= $xmlconfig->{endpoint}; |
|
262
|
0
|
|
0
|
|
|
0
|
$opts{debug} ||= $xmlconfig->{debug}; |
|
263
|
0
|
|
0
|
|
|
0
|
$opts{logfile} ||= $xmlconfig->{logfile}; |
|
264
|
|
|
|
|
|
|
} |
|
265
|
|
|
|
|
|
|
|
|
266
|
2
|
|
|
|
|
6
|
my $attr = $opts->{agent_attributes}; |
|
267
|
2
|
|
|
|
|
5
|
$attr->{Language} = 'Perl'; |
|
268
|
|
|
|
|
|
|
|
|
269
|
2
|
|
|
|
|
9
|
my $attr_str = join ';', map { "$_=$attr->{$_}" } keys %$attr; |
|
|
2
|
|
|
|
|
13
|
|
|
270
|
2
|
|
50
|
|
|
13
|
my $appname = $opts{Application} || 'Amazon::MWS::Client'; |
|
271
|
2
|
|
50
|
|
|
11
|
my $version = $opts{Version} || 0.5; |
|
272
|
|
|
|
|
|
|
|
|
273
|
2
|
|
|
|
|
38
|
my $agent_string = "$appname/$version ($attr_str)"; |
|
274
|
|
|
|
|
|
|
|
|
275
|
2
|
50
|
|
|
|
6
|
die 'No access key id' unless $opts{access_key_id}; |
|
276
|
2
|
50
|
|
|
|
15
|
die 'No secret key' unless $opts{secret_key}; |
|
277
|
2
|
50
|
|
|
|
9
|
die 'No merchant id' unless $opts{merchant_id}; |
|
278
|
2
|
50
|
|
|
|
7
|
die 'No marketplace id' unless $opts{marketplace_id}; |
|
279
|
|
|
|
|
|
|
|
|
280
|
2
|
50
|
|
|
|
8
|
if ($opts{debug}) { |
|
281
|
0
|
0
|
|
|
|
0
|
open LOG, ">$opts{logfile}" or die "Cannot open logfile."; |
|
282
|
0
|
|
|
|
|
0
|
print LOG DateTime->now(); |
|
283
|
0
|
|
|
|
|
0
|
print LOG "\nNew instance created. \n"; |
|
284
|
0
|
|
|
|
|
0
|
print LOG Dumper(\%opts); |
|
285
|
0
|
|
|
|
|
0
|
close LOG; |
|
286
|
|
|
|
|
|
|
} |
|
287
|
|
|
|
|
|
|
|
|
288
|
|
|
|
|
|
|
# https://github.com/interchange/Amazon-MWS/issues/9 |
|
289
|
2
|
|
50
|
|
|
13
|
$opts{endpoint} ||= 'https://mws.amazonaws.com'; |
|
290
|
|
|
|
|
|
|
# strip the trailing slashes |
|
291
|
2
|
|
|
|
|
10
|
$opts{endpoint} =~ s/\/+\z//; |
|
292
|
|
|
|
|
|
|
|
|
293
|
|
|
|
|
|
|
bless { |
|
294
|
|
|
|
|
|
|
package => "$pkg", |
|
295
|
|
|
|
|
|
|
agent => LWP::UserAgent->new(agent => $agent_string), |
|
296
|
|
|
|
|
|
|
endpoint => $opts{endpoint}, |
|
297
|
|
|
|
|
|
|
access_key_id => $opts{access_key_id}, |
|
298
|
|
|
|
|
|
|
secret_key => $opts{secret_key}, |
|
299
|
|
|
|
|
|
|
merchant_id => $opts{merchant_id}, |
|
300
|
|
|
|
|
|
|
marketplace_id => $opts{marketplace_id}, |
|
301
|
|
|
|
|
|
|
debug => $opts{debug}, |
|
302
|
|
|
|
|
|
|
logfile => $opts{logfile}, |
|
303
|
2
|
|
|
|
|
40
|
}, $pkg; |
|
304
|
|
|
|
|
|
|
|
|
305
|
|
|
|
|
|
|
} |
|
306
|
|
|
|
|
|
|
|
|
307
|
|
|
|
|
|
|
1; |
|
308
|
|
|
|
|
|
|
|
|
309
|
|
|
|
|
|
|
# Local Variables: |
|
310
|
|
|
|
|
|
|
# tab-width: 8 |
|
311
|
|
|
|
|
|
|
# End: |
|
312
|
|
|
|
|
|
|
|