walmart_open 0.0.6 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +31 -28
- data/lib/walmart_open/item.rb +4 -0
- data/lib/walmart_open/version.rb +1 -1
- data/spec/walmart_open/item_spec.rb +21 -1
- data/spec/walmart_open/requests/lookup_spec.rb +2 -1
- metadata +2 -2
data/README.md
CHANGED
@@ -70,32 +70,11 @@ res = client.search("ipod")
|
|
70
70
|
|
71
71
|
# Lookup (by item id)
|
72
72
|
item = client.lookup(15076191)
|
73
|
-
#=> item is of class WalmartOpen::Item
|
74
|
-
#
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
# item.price = "189.0"
|
79
|
-
# item.upc = nil
|
80
|
-
# item.category_node = "3944_96469_164001"
|
81
|
-
# item.short_description = "The world's most popular portable gaming device ... "
|
82
|
-
# item.long_description = "<br><b>Apple iPod touch 32GB (4th Gen) ..."
|
83
|
-
# item.brand = nil
|
84
|
-
# item.shipping_rate = 0.0
|
85
|
-
# item.size = nil
|
86
|
-
# item.color = "Black"
|
87
|
-
# item.model_number = ?
|
88
|
-
# item.url = "http://www.walmart.com/ip/Apple-iPod-Touch-8GB-32GB-and-64GB-newest-model/15076191"
|
89
|
-
# item.raw_attributes = {"itemId" => 15076191, .....}
|
90
|
-
# item.large_image = "http://i.walmartimages.com/i/p/00/80/14/18/71/0080141871195_Color_Burgundy_SW_500X500.jpg"
|
91
|
-
# item.thumbnail_image = "http://i.walmartimages.com/i/p/00/80/14/18/71/0080141871195_Color_Burgundy_SW_100X100.jpg"
|
92
|
-
# item.medium_image = "http://i.walmartimages.com/i/p/00/80/14/18/71/0080141871195_Color_Burgundy_SW_180X180.jpg"
|
93
|
-
|
94
|
-
# when fail: example of item
|
95
|
-
# item.error? == true
|
96
|
-
# item.error[:code] = 4002
|
97
|
-
# item.error[:message] = "Invalid itemId"
|
98
|
-
# item.raw_attributes = {"errors"=>[{"code"=>4002, "message"=>"Invalid itemId"}]}
|
73
|
+
#=> item is of class WalmartOpen::Item, see WalmartOpen::Item section for detail
|
74
|
+
# When item not found, an error of class WalmartOpen::ItemNotFoundError is thrown,
|
75
|
+
eg: {"errors"=>[{"code"=>4002, "message"=>"Invalid itemId"}]}
|
76
|
+
When walmart api is down, an error of class WalmartOpen::ServerError is thrown,
|
77
|
+
eg: {"errors"=>[{"code"=>504, "message"=>"Gateway Timeout"}]}
|
99
78
|
|
100
79
|
# Taxonomy
|
101
80
|
taxonomies = client.taxonomy
|
@@ -110,8 +89,7 @@ taxonomies = client.taxonomy
|
|
110
89
|
# For :preorder case, you do not need to pass param category_id
|
111
90
|
items = client.feed(:bestsellers, category_id)
|
112
91
|
#=> Array
|
113
|
-
# when success:
|
114
|
-
# items = [item, ... ]
|
92
|
+
# when success: items is an array of WalmartOpen::Item items
|
115
93
|
```
|
116
94
|
|
117
95
|
### Making Commerce API Calls
|
@@ -168,6 +146,31 @@ res = client.order(order)
|
|
168
146
|
# res.raw_attributes = {"errors"=>{"error"=>{"code"=>"10001", "message"=>"Invalid xml"}}}
|
169
147
|
```
|
170
148
|
|
149
|
+
# WalmartOpen::Item
|
150
|
+
# example of a WalmartOpen::Item item
|
151
|
+
# item.id = "15076191"
|
152
|
+
# item.name = "Apple iPod Touch 4th Generation 32GB with Bonus Accessory Kit"
|
153
|
+
# item.price = "189.0"
|
154
|
+
# item.upc = nil
|
155
|
+
# item.category_node = "3944_96469_164001"
|
156
|
+
# item.short_description = "The world's most popular portable gaming device ... "
|
157
|
+
# item.long_description = "<br><b>Apple iPod touch 32GB (4th Gen) ..."
|
158
|
+
# item.brand = nil
|
159
|
+
# item.shipping_rate = 0.0
|
160
|
+
# item.size = nil
|
161
|
+
# item.color = "Black"
|
162
|
+
# item.model_number = ?
|
163
|
+
# item.url = "http://www.walmart.com/ip/Apple-iPod-Touch-8GB-32GB-and-64GB-newest-model/15076191"
|
164
|
+
# item.raw_attributes = {"itemId" => 15076191, .....}
|
165
|
+
# item.large_image = "http://i.walmartimages.com/i/p/00/80/14/18/71/0080141871195_Color_Burgundy_SW_500X500.jpg"
|
166
|
+
# item.thumbnail_image = "http://i.walmartimages.com/i/p/00/80/14/18/71/0080141871195_Color_Burgundy_SW_100X100.jpg"
|
167
|
+
# item.medium_image = "http://i.walmartimages.com/i/p/00/80/14/18/71/0080141871195_Color_Burgundy_SW_180X180.jpg"
|
168
|
+
|
169
|
+
# item.variants returns an array of product ids when a walmart product has
|
170
|
+
variants that user can choose, eg a different color or style. An example:
|
171
|
+
# items.variants = [15076191, 15076192]
|
172
|
+
# An empty array is returned when a product has no variants.
|
173
|
+
|
171
174
|
### Authentication failure
|
172
175
|
In the case of authentication failure during an API call, a
|
173
176
|
WalmartOpen::AuthenticationError exception will be raised
|
data/lib/walmart_open/item.rb
CHANGED
data/lib/walmart_open/version.rb
CHANGED
@@ -36,7 +36,8 @@ describe WalmartOpen::Item do
|
|
36
36
|
"clearance" => false,
|
37
37
|
"preOrder" => false,
|
38
38
|
"stock" => "Available",
|
39
|
-
"availableOnline" => true
|
39
|
+
"availableOnline" => true,
|
40
|
+
"variants" => [10371356, 10371357]
|
40
41
|
}
|
41
42
|
end
|
42
43
|
|
@@ -49,4 +50,23 @@ describe WalmartOpen::Item do
|
|
49
50
|
expect(item.raw_attributes).to eq(item_attrs)
|
50
51
|
end
|
51
52
|
end
|
53
|
+
|
54
|
+
context "#variants" do
|
55
|
+
context "when item has variants" do
|
56
|
+
it "returns a array with variants" do
|
57
|
+
item = WalmartOpen::Item.new(item_attrs)
|
58
|
+
|
59
|
+
expect(item.variants).to eq([10371356, 10371357])
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
context "when item has no variants" do
|
64
|
+
it "returns an empty array" do
|
65
|
+
item_attrs.delete("variants")
|
66
|
+
item = WalmartOpen::Item.new(item_attrs)
|
67
|
+
|
68
|
+
expect(item.variants).to eq([])
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
52
72
|
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: walmart_open
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.7
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Ngan Pham
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2014-02-
|
13
|
+
date: 2014-02-24 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: httparty
|