3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
|
# File 'lib/asin/adapter.rb', line 3
def handle_type(data, type)
Hashie::SCHash.new(data).tap do |schash|
schash.instance_eval do
case type
when :cart
def url
purchase_url
end
def price
sub_total.formatted_price
end
def items
return [] unless cart_items
cart_items.cart_item.is_a?(Array) ? cart_items.cart_item : [cart_items.cart_item]
end
def saved_items
return [] unless saved_for_later_items
saved_for_later_items.saved_for_later_item.is_a?(Array) ? saved_for_later_items.saved_for_later_item : [saved_for_later_items.saved_for_later_item]
end
def valid?
request.is_valid == 'True'
end
def empty?
cart_items.nil?
end
when :item
def title
item_attributes!.title
end
def amount
item_attributes!.list_price!.amount.to_i
end
def details_url
detail_page_url
end
def review
editorial_reviews!.editorial_review!.content
end
def image_url
large_image!.url
end
def review
EditorialReviews!.EditorialReview!.Content
end
def image_url
LargeImage!.URL
end
def author
item_attributes!.author
end
def binding
item_attributes!.binding
end
def brand
item_attributes!.brand
end
def ean
item_attributes!.ean
end
def edition
item_attributes!.edition
end
def isbn
item_attributes!.isbn
end
def item_dimensions
item_attributes!.item_dimensions
end
def item_height
item_attributes!.item_dimensions.height
end
def item_length
item_attributes!.item_dimensions[:length]
end
def item_width
item_attributes!.item_dimensions.width
end
def item_weight
item_attributes!.item_dimensions.weight
end
def package_dimensions
item_attributes!.package_dimensions
end
def package_height
item_attributes!.package_dimensions.height
end
def package_length
item_attributes!.package_dimensions[:length]
end
def package_width
item_attributes!.package_dimensions.width
end
def package_weight
item_attributes!.package_dimensions.weight
end
def label
item_attributes!.label
end
def language
item_attributes!.languages.language.first.name
end
def formatted_price
item_attributes!.list_price.formatted_price
end
def manufacturer
item_attributes!.manufacturer
end
def mpn
item_attributes!.mpn
end
def page_count
item_attributes!.number_of_pages
end
def part_number
item_attributes!.part_number
end
def product_group
item_attributes!.product_group
end
def publication_date
item_attributes!.publication_date
end
def publisher
item_attributes!.publisher
end
def sku
item_attributes!.sku
end
def studio
item_attributes!.studio
end
def total_new
offer_summary!.total_new
end
def total_used
offer_summary!.total_used
end
when :node
def node_id
browse_node_id
end
def children
return [] unless children
children.browse_node.is_a?(Array) ? children.browse_node : [children.browse_node]
end
def ancestors
return [] unless ancestors
ancestors.browse_node.is_a?(Array) ? ancestors.browse_node : [ancestors.browse_node]
end
def top_item_set
return [] unless top_item_set
top_item_set.top_item.is_a?(Array) ? top_item_set.top_item : [top_item_set.top_item]
end
end
end
end
end
|