line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
###################################################################### |
2
|
|
|
|
|
|
|
package Net::Amazon::Request::ASIN; |
3
|
|
|
|
|
|
|
###################################################################### |
4
|
4
|
|
|
4
|
|
86916
|
use warnings; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
140
|
|
5
|
4
|
|
|
4
|
|
20
|
use strict; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
131
|
|
6
|
4
|
|
|
4
|
|
24
|
use base qw(Net::Amazon::Request); |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
2028
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
# These values are defined in the AWS SDK |
9
|
|
|
|
|
|
|
# (http://amazon.com/webservices) under |
10
|
|
|
|
|
|
|
# "Product and Catalog Data" / "ASIN and ISBN Searches" |
11
|
4
|
|
|
4
|
|
26
|
use constant MAX_ASINS_PER_REQUEST => 10; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
1181
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
################################################## |
15
|
|
|
|
|
|
|
sub new { |
16
|
|
|
|
|
|
|
################################################## |
17
|
1
|
|
|
1
|
1
|
36
|
my($class, %options) = @_; |
18
|
|
|
|
|
|
|
|
19
|
1
|
|
|
|
|
17
|
$class->_assert_options_defined(\%options, 'asin'); |
20
|
|
|
|
|
|
|
|
21
|
1
|
|
|
|
|
12
|
$class->_convert_option(\%options, |
22
|
|
|
|
|
|
|
'asin', |
23
|
|
|
|
|
|
|
'ItemId', |
24
|
|
|
|
|
|
|
\&_process_asin_option); |
25
|
|
|
|
|
|
|
|
26
|
1
|
|
|
|
|
8
|
my $self = $class->SUPER::new(%options); |
27
|
|
|
|
|
|
|
|
28
|
1
|
|
|
|
|
13
|
bless $self, $class; # reconsecrate |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
## |
32
|
|
|
|
|
|
|
## PRIVATE FUNCTIONS |
33
|
|
|
|
|
|
|
## |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
# _process_asin_option( OPTIONS, KEY ) |
36
|
|
|
|
|
|
|
# |
37
|
|
|
|
|
|
|
# Takes a reference to a hash of OPTIONS and checks the value keyed by |
38
|
|
|
|
|
|
|
# KEY to make sure it looks legitimate. If the value associated with |
39
|
|
|
|
|
|
|
# KEY is an array, we check to make sure that we're not asking for |
40
|
|
|
|
|
|
|
# too many asins at once. |
41
|
|
|
|
|
|
|
# |
42
|
|
|
|
|
|
|
# Returns true if all goes well. If any problems are encountered, |
43
|
|
|
|
|
|
|
# die() will be called. |
44
|
|
|
|
|
|
|
# |
45
|
|
|
|
|
|
|
sub _process_asin_option { |
46
|
1
|
|
|
1
|
|
3
|
my ($options, $key) = @_; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
# If the asins are supplied in the form of an array, we have to |
49
|
|
|
|
|
|
|
# make sure that the caller isn't trying to ask for too many at a |
50
|
|
|
|
|
|
|
# time. If we don't make this test, those excessive asins will be |
51
|
|
|
|
|
|
|
# silently ignored by the AWS servers...resulting in potentially |
52
|
|
|
|
|
|
|
# confusing results for the user. |
53
|
1
|
50
|
|
|
|
7
|
if ( ref $options->{$key} eq 'ARRAY' ) { |
|
|
50
|
|
|
|
|
|
54
|
0
|
|
|
|
|
0
|
my $max_asins = MAX_ASINS_PER_REQUEST; |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
# Dying is the right thing to do here because this is |
57
|
|
|
|
|
|
|
# indicative of a programming error. |
58
|
0
|
|
|
|
|
0
|
die "Only $max_asins may be requested at a time" |
59
|
0
|
0
|
|
|
|
0
|
if ( @{$options->{$key}} > $max_asins ); |
60
|
|
|
|
|
|
|
|
61
|
0
|
|
|
|
|
0
|
$options->{$key} = join ',', @{$options->{$key}}; |
|
0
|
|
|
|
|
0
|
|
62
|
|
|
|
|
|
|
} elsif ( ref $options->{$key} ) { |
63
|
0
|
|
|
|
|
0
|
die "The 'asin' parameter must either be a scalar or an array"; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
1
|
|
|
|
|
3
|
return 1; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
1; |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
__END__ |