walmart_open 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/LICENSE.txt +22 -0
- data/README.md +171 -0
- data/Rakefile +1 -0
- data/lib/walmart_open.rb +6 -0
- data/lib/walmart_open/auth_token.rb +25 -0
- data/lib/walmart_open/client.rb +48 -0
- data/lib/walmart_open/commerce_request.rb +23 -0
- data/lib/walmart_open/config.rb +41 -0
- data/lib/walmart_open/connection_manager.rb +47 -0
- data/lib/walmart_open/errors.rb +13 -0
- data/lib/walmart_open/item.rb +41 -0
- data/lib/walmart_open/order.rb +53 -0
- data/lib/walmart_open/order_item.rb +17 -0
- data/lib/walmart_open/order_results.rb +40 -0
- data/lib/walmart_open/order_xml_builder.rb +62 -0
- data/lib/walmart_open/ordered_item.rb +31 -0
- data/lib/walmart_open/product_request.rb +28 -0
- data/lib/walmart_open/request.rb +64 -0
- data/lib/walmart_open/requests/lookup.rb +27 -0
- data/lib/walmart_open/requests/place_order.rb +58 -0
- data/lib/walmart_open/requests/search.rb +19 -0
- data/lib/walmart_open/requests/taxonomy.rb +17 -0
- data/lib/walmart_open/requests/token.rb +30 -0
- data/lib/walmart_open/search_results.rb +25 -0
- data/lib/walmart_open/shipping_address.rb +36 -0
- data/lib/walmart_open/version.rb +3 -0
- data/spec/spec_helper.rb +16 -0
- data/spec/walmart_open/auth_token_spec.rb +53 -0
- data/spec/walmart_open/client_spec.rb +92 -0
- data/spec/walmart_open/config_spec.rb +35 -0
- data/spec/walmart_open/connection_manager_spec.rb +58 -0
- data/spec/walmart_open/item_spec.rb +52 -0
- data/spec/walmart_open/order_item_spec.rb +18 -0
- data/spec/walmart_open/order_results_spec.rb +83 -0
- data/spec/walmart_open/order_spec.rb +124 -0
- data/spec/walmart_open/request_spec.rb +79 -0
- data/spec/walmart_open/requests/lookup_spec.rb +91 -0
- data/spec/walmart_open/requests/place_order_spec.rb +149 -0
- data/spec/walmart_open/requests/search_spec.rb +86 -0
- data/spec/walmart_open/requests/taxonomy_spec.rb +69 -0
- data/spec/walmart_open/requests/token_spec.rb +49 -0
- data/spec/walmart_open/search_results_spec.rb +60 -0
- data/spec/walmart_open/shipping_address_spec.rb +63 -0
- metadata +204 -0
@@ -0,0 +1,124 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "walmart_open/order"
|
3
|
+
|
4
|
+
describe WalmartOpen::Order do
|
5
|
+
context "create order" do
|
6
|
+
let(:order_params) do
|
7
|
+
{
|
8
|
+
billing_id: 1,
|
9
|
+
first_name: "James",
|
10
|
+
last_name: "Fong",
|
11
|
+
partner_order_id: "42",
|
12
|
+
phone: "606-478-0850",
|
13
|
+
partner_order_time: Time.now
|
14
|
+
}
|
15
|
+
end
|
16
|
+
|
17
|
+
let(:shipping_addr_params) do
|
18
|
+
{
|
19
|
+
street1: "Listia Inc, 200 Blossom Ln",
|
20
|
+
street2: "street2 test",
|
21
|
+
city: "Mountain View",
|
22
|
+
state: "CA",
|
23
|
+
zipcode: "94043",
|
24
|
+
country: "USA"
|
25
|
+
}
|
26
|
+
end
|
27
|
+
|
28
|
+
let(:order) { WalmartOpen::Order.new(order_params) }
|
29
|
+
|
30
|
+
context ".new" do
|
31
|
+
it "sets value correctly" do
|
32
|
+
expect(order.shipping_address).to be_nil
|
33
|
+
expect(order.items).to be_empty
|
34
|
+
expect(order.billing_id).to eql(order_params[:billing_id])
|
35
|
+
expect(order.first_name).to eql(order_params[:first_name])
|
36
|
+
expect(order.last_name).to eql(order_params[:last_name])
|
37
|
+
expect(order.phone).to eql(order_params[:phone])
|
38
|
+
expect(order.partner_order_id).to eq(order_params[:partner_order_id])
|
39
|
+
expect(order.partner_order_time).to eq(order_params[:partner_order_time])
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
context "#add_shipping_address" do
|
44
|
+
it "sets value correctly" do
|
45
|
+
order.add_shipping_address(shipping_addr_params)
|
46
|
+
|
47
|
+
expect(order.shipping_address).not_to be_nil
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
context "#add_item" do
|
52
|
+
it "adds item object" do
|
53
|
+
item = double
|
54
|
+
order.add_item(item)
|
55
|
+
expect(order.items).not_to be_empty
|
56
|
+
end
|
57
|
+
|
58
|
+
it "adds item by id" do
|
59
|
+
order.add_item(1, 2.0)
|
60
|
+
expect(order.items).not_to be_empty
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
context "#valid?" do
|
66
|
+
let(:valid_attrs) do
|
67
|
+
{
|
68
|
+
first_name: "James",
|
69
|
+
billing_id: 1
|
70
|
+
}
|
71
|
+
end
|
72
|
+
|
73
|
+
let(:order) do
|
74
|
+
WalmartOpen::Order.new(valid_attrs).tap do |order|
|
75
|
+
order.add_shipping_address({})
|
76
|
+
order.add_item(10371356, 27.94)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
context "when shipping address is valid" do
|
81
|
+
before do
|
82
|
+
allow(order.shipping_address).to receive(:valid?).and_return(true)
|
83
|
+
end
|
84
|
+
|
85
|
+
context "when order attributes are valid" do
|
86
|
+
context "when items are valid" do
|
87
|
+
it "returns true" do
|
88
|
+
expect(order).to be_valid
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
context "when items are not valid" do
|
93
|
+
before do
|
94
|
+
order.add_item(12345)
|
95
|
+
end
|
96
|
+
|
97
|
+
it "returns false" do
|
98
|
+
expect(order).to_not be_valid
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
context "when order attributes are not valid" do
|
104
|
+
before do
|
105
|
+
order.first_name = nil
|
106
|
+
end
|
107
|
+
|
108
|
+
it "returns false" do
|
109
|
+
expect(order).to_not be_valid
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
context "when shipping address is not valid" do
|
115
|
+
before do
|
116
|
+
allow(order.shipping_address).to receive(:valid?).and_return(false)
|
117
|
+
end
|
118
|
+
|
119
|
+
it "returns false" do
|
120
|
+
expect(order).to_not be_valid
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "walmart_open/request"
|
3
|
+
require "walmart_open/client"
|
4
|
+
require "walmart_open/errors"
|
5
|
+
|
6
|
+
describe WalmartOpen::Request do
|
7
|
+
class DummyRequest < WalmartOpen::Request
|
8
|
+
attr_accessor :fake_url,
|
9
|
+
:fake_request_options
|
10
|
+
|
11
|
+
def initialize
|
12
|
+
@path = "dummy"
|
13
|
+
@fake_url = "http://example.com/foo/bar/path?q1=true"
|
14
|
+
@fake_request_options = {dummy_option: true}
|
15
|
+
end
|
16
|
+
|
17
|
+
def build_url(client)
|
18
|
+
@fake_url
|
19
|
+
end
|
20
|
+
|
21
|
+
def request_options(client)
|
22
|
+
@fake_request_options
|
23
|
+
end
|
24
|
+
|
25
|
+
def unset_path!
|
26
|
+
@path = nil
|
27
|
+
end
|
28
|
+
|
29
|
+
public :request_method
|
30
|
+
end
|
31
|
+
|
32
|
+
context "#submit" do
|
33
|
+
let(:client) { WalmartOpen::Client.new }
|
34
|
+
let(:request) { DummyRequest.new }
|
35
|
+
let(:response) { double(success?: true, parsed_response: {}) }
|
36
|
+
|
37
|
+
before do
|
38
|
+
allow(HTTParty).to receive(request.request_method).with(request.fake_url, request.fake_request_options).and_return(response)
|
39
|
+
end
|
40
|
+
|
41
|
+
context "when path is set" do
|
42
|
+
it "uses HTTParty to make the request" do
|
43
|
+
expect(HTTParty).to receive(request.request_method).with(request.fake_url, request.fake_request_options).and_return(response)
|
44
|
+
|
45
|
+
request.submit(client)
|
46
|
+
end
|
47
|
+
|
48
|
+
context "when response is success" do
|
49
|
+
it "returns the response" do
|
50
|
+
expect(request.submit(client)).to eq(response)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
context "when response is not success" do
|
55
|
+
before do
|
56
|
+
allow(response).to receive(:success?).and_return(false)
|
57
|
+
end
|
58
|
+
|
59
|
+
it "raises an error" do
|
60
|
+
expect {
|
61
|
+
request.submit(client)
|
62
|
+
}.to raise_error(WalmartOpen::AuthenticationError)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
context "when path is not set" do
|
68
|
+
before do
|
69
|
+
request.unset_path!
|
70
|
+
end
|
71
|
+
|
72
|
+
it "raises an error" do
|
73
|
+
expect {
|
74
|
+
request.submit(client)
|
75
|
+
}.to raise_error("@path must be specified")
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
@@ -0,0 +1,91 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "walmart_open/requests/lookup"
|
3
|
+
require "walmart_open/client"
|
4
|
+
require "walmart_open/errors"
|
5
|
+
|
6
|
+
describe WalmartOpen::Requests::Lookup do
|
7
|
+
context "#submit" do
|
8
|
+
let(:success_response) { double(success?: true) }
|
9
|
+
let(:fail_response) { double(success?: false) }
|
10
|
+
let(:client) { WalmartOpen::Client.new }
|
11
|
+
let(:lookup_req) { WalmartOpen::Requests::Lookup.new(1) }
|
12
|
+
let(:lookup_attrs) do
|
13
|
+
{
|
14
|
+
"itemId" => 10371356,
|
15
|
+
"parentItemId" => 10371356,
|
16
|
+
"name" => "Microplush Blanket",
|
17
|
+
"salePrice" => 22.97,
|
18
|
+
"upc" => "801418711959",
|
19
|
+
"categoryPath" => "Home/Bedding/Blankets & Throws",
|
20
|
+
"shortDescription" => "Cuddle up in bed, on the couch, or even on a sandy beach with this super-soft and thick microfiber blanket. It's luxuriously crafted to provide sumptuous warmth and comfort, even in the coldest environment. Constructed from 100% microfiber, the blanket yarns feel plush and cozy against your skin. This lavish microplush blanket is available in 7 beautiful colors, and can be elegantly matched to any home decor. It works well as an outdoor blanket too — it's perfect for picnics, long car rides, and trips to the ballpark. Plus, this microplush blanket is easy to take care of without hassle, and saves valuable energy over electric blankets. Now you can bundle up and stay warm anywhere, indoors or out. <p>Soft microplush blanket is available in Twin, Full, Queen and King Sizes.</p>", "longDescription"=>"<p><b>Microplush Blanket, 7 Colors:</b></p><ul><li>Super-soft, thick and plush</li><li>100% microfiber blanket yarns are soft and plush to the touch</li><li>Microplush blanket is suitable for all-year use, and can be used indoors or outdoors without hassle</li><li>Luxurious microplush blanket is easy to clean just machine wash and tumble dry</li><li>Twin: 90" x 66"</li><li>Full: 90" x 80"</li><li>Queen: 90" x 90"</li><li>King: 90" x 102"</li></ul>", "brandName"=>"Sun Yin", "thumbnailImage"=>"http://i.walmartimages.com/i/p/00/80/14/18/71/0080141871195_Color_Burgundy_SW_100X100.jpg",
|
21
|
+
"mediumImage" => "http://i.walmartimages.com/i/p/00/80/14/18/71/0080141871195_Color_Burgundy_SW_180X180.jpg",
|
22
|
+
"largeImage" => "http://i.walmartimages.com/i/p/00/80/14/18/71/0080141871195_Color_Burgundy_SW_500X500.jpg",
|
23
|
+
"productTrackingUrl" => "http://linksynergy.walmart.com/fs-bin/click?id=|LSNID|&offerid=223073.7200&type=14&catid=8&subid=0&hid=7200&tmpid=1081&RD_PARM1=http%253A%252F%252Fwww.walmart.com%252Fip%252FMicroplush-Blanket%252F10371356%253Faffilsrc%253Dapi",
|
24
|
+
"ninetySevenCentShipping" => false,
|
25
|
+
"standardShipRate" => 4.97,
|
26
|
+
"twoThreeDayShippingRate" => 10.97,
|
27
|
+
"overnightShippingRate" => 14.97,
|
28
|
+
"size" => "Twin",
|
29
|
+
"color" => "Burgundy",
|
30
|
+
"marketplace" => false,
|
31
|
+
"shipToStore" => true,
|
32
|
+
"freeShipToStore" => true,
|
33
|
+
"modelNumber" => "BKT051166T",
|
34
|
+
"productUrl" => "http://www.walmart.com/ip/Microplush-Blanket/10371356",
|
35
|
+
"customerRating" => "4.446",
|
36
|
+
"numReviews" => 621,
|
37
|
+
"customerRatingImage" => "http://i2.walmartimages.com/i/CustRating/4_4.gif",
|
38
|
+
"categoryNode" => "4044_539103_4756",
|
39
|
+
"rollBack" => false,
|
40
|
+
"bundle" => false,
|
41
|
+
"clearance" => false,
|
42
|
+
"preOrder" => false,
|
43
|
+
"stock" => "Available",
|
44
|
+
"availableOnline" => true
|
45
|
+
}
|
46
|
+
end
|
47
|
+
|
48
|
+
context "when response is success" do
|
49
|
+
before do
|
50
|
+
allow(HTTParty).to receive(:get).and_return(success_response)
|
51
|
+
allow(success_response).to receive(:parsed_response).and_return(lookup_attrs)
|
52
|
+
allow(success_response).to receive(:code).and_return(200)
|
53
|
+
end
|
54
|
+
|
55
|
+
it "returns response" do
|
56
|
+
item = lookup_req.submit(client)
|
57
|
+
|
58
|
+
expect(item.raw_attributes).to eq(lookup_attrs)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
context "when response is not successful" do
|
63
|
+
before do
|
64
|
+
allow(HTTParty).to receive(:get).and_return(fail_response)
|
65
|
+
end
|
66
|
+
context "when http code is 400" do
|
67
|
+
before do
|
68
|
+
allow(fail_response).to receive(:code).and_return(400)
|
69
|
+
allow(fail_response).to receive(:parsed_response).and_return({"errors"=>[{"code"=>4002, "message"=>"Invalid itemId"}]})
|
70
|
+
end
|
71
|
+
|
72
|
+
it "raises item not found error" do
|
73
|
+
expect{lookup_req.submit(client)}.to raise_error(WalmartOpen::ItemNotFoundError)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
context "when http code is not 400" do
|
78
|
+
before do
|
79
|
+
allow(fail_response).to receive(:code).and_return(403)
|
80
|
+
allow(fail_response).to receive(:parsed_response).and_return({"errors"=>[{"code"=>403, "message"=>"Account Inactive"}]})
|
81
|
+
end
|
82
|
+
|
83
|
+
it "raises authentication error" do
|
84
|
+
expect {
|
85
|
+
lookup_req.submit(client)
|
86
|
+
}.to raise_error(WalmartOpen::AuthenticationError)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
@@ -0,0 +1,149 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "walmart_open/requests/place_order"
|
3
|
+
require "walmart_open/order"
|
4
|
+
require "walmart_open/client"
|
5
|
+
require "walmart_open/errors"
|
6
|
+
|
7
|
+
describe WalmartOpen::Requests::PlaceOrder do
|
8
|
+
context "#submit" do
|
9
|
+
let(:order_attrs) do
|
10
|
+
{
|
11
|
+
billing_id: 1,
|
12
|
+
first_name: "James",
|
13
|
+
last_name: "Fong",
|
14
|
+
partner_order_id: "44",
|
15
|
+
phone: "606-478-0850"
|
16
|
+
}
|
17
|
+
end
|
18
|
+
|
19
|
+
let(:multiple_order_response) do
|
20
|
+
{
|
21
|
+
"response" => {
|
22
|
+
"orderId" => "2677911169085",
|
23
|
+
"partnerOrderId" => "8",
|
24
|
+
"items" => {
|
25
|
+
"item" => [
|
26
|
+
{
|
27
|
+
"itemId" => "25174174",
|
28
|
+
"quantity" => "1",
|
29
|
+
"itemPrice" => "214.99"
|
30
|
+
},
|
31
|
+
{
|
32
|
+
"itemId" => "10371356",
|
33
|
+
"quantity" => "1",
|
34
|
+
"itemPrice" => "22.97"
|
35
|
+
}
|
36
|
+
]
|
37
|
+
},
|
38
|
+
"total" => "259.38",
|
39
|
+
"itemTotal" => "237.96",
|
40
|
+
"shipping" => "0",
|
41
|
+
"salesTax" => "21.42",
|
42
|
+
"surcharge" => "0.00"
|
43
|
+
}
|
44
|
+
}
|
45
|
+
end
|
46
|
+
|
47
|
+
let(:single_order_response) do
|
48
|
+
{
|
49
|
+
"response" => {
|
50
|
+
"orderId" => "2677913310915",
|
51
|
+
"partnerOrderId" => "20",
|
52
|
+
"items" => {
|
53
|
+
"item" => {
|
54
|
+
"itemId" => "10371356",
|
55
|
+
"quantity" => "1",
|
56
|
+
"itemPrice" => "22.97"
|
57
|
+
}
|
58
|
+
},
|
59
|
+
"total" => "29.95",
|
60
|
+
"itemTotal" => "22.97",
|
61
|
+
"shipping" => "4.97",
|
62
|
+
"salesTax" => "2.01",
|
63
|
+
"surcharge" => "0.00"
|
64
|
+
}
|
65
|
+
}
|
66
|
+
end
|
67
|
+
|
68
|
+
let(:client) { WalmartOpen::Client.new }
|
69
|
+
let(:order) { WalmartOpen::Order.new(order_attrs) }
|
70
|
+
let(:order_req) { WalmartOpen::Requests::PlaceOrder.new(order) }
|
71
|
+
let(:success_response) { double(success?: true) }
|
72
|
+
let(:fail_response) { double(success?: false) }
|
73
|
+
|
74
|
+
before do
|
75
|
+
allow(order_req).to receive(:request_options).and_return({})
|
76
|
+
end
|
77
|
+
|
78
|
+
context "when response is success" do
|
79
|
+
before do
|
80
|
+
allow(HTTParty).to receive(:post).and_return(success_response)
|
81
|
+
allow(success_response).to receive(:code).and_return(200)
|
82
|
+
end
|
83
|
+
|
84
|
+
context "when multiple orders" do
|
85
|
+
before do
|
86
|
+
allow(success_response).to receive(:parsed_response).and_return(multiple_order_response)
|
87
|
+
end
|
88
|
+
|
89
|
+
it "return response" do
|
90
|
+
order = order_req.submit(client)
|
91
|
+
expect(order.raw_attributes).to eq(multiple_order_response)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
context "when one order" do
|
96
|
+
before do
|
97
|
+
allow(success_response).to receive(:parsed_response).and_return(single_order_response)
|
98
|
+
end
|
99
|
+
|
100
|
+
it "return response" do
|
101
|
+
order = order_req.submit(client)
|
102
|
+
expect(order.raw_attributes).to eq(single_order_response)
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
context "when response is not success" do
|
108
|
+
before do
|
109
|
+
allow(HTTParty).to receive(:post).and_return(fail_response)
|
110
|
+
end
|
111
|
+
|
112
|
+
context "response has http code 400" do
|
113
|
+
before do
|
114
|
+
allow(fail_response).to receive(:code).and_return(400)
|
115
|
+
allow(fail_response).to receive(:parsed_response).and_return({
|
116
|
+
"errors" => {
|
117
|
+
"error" => {
|
118
|
+
"code" => "10020",
|
119
|
+
"message" => "This order has already been executed"
|
120
|
+
}
|
121
|
+
}
|
122
|
+
})
|
123
|
+
end
|
124
|
+
|
125
|
+
it "raises order error" do
|
126
|
+
expect{order_req.submit(client)}.to raise_error(WalmartOpen::OrderError)
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
context "response has http code not 400" do
|
131
|
+
before do
|
132
|
+
allow(fail_response).to receive(:code).and_return(403)
|
133
|
+
allow(fail_response).to receive(:parsed_response).and_return({
|
134
|
+
"errors" => [{
|
135
|
+
"code" => 403,
|
136
|
+
"message" => "Account Inactive"
|
137
|
+
}]
|
138
|
+
})
|
139
|
+
end
|
140
|
+
|
141
|
+
it "raises authentication error" do
|
142
|
+
expect {
|
143
|
+
order_req.submit(client)
|
144
|
+
}.to raise_error(WalmartOpen::AuthenticationError)
|
145
|
+
end
|
146
|
+
end
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
@@ -0,0 +1,86 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "walmart_open/requests/search"
|
3
|
+
require "walmart_open/client"
|
4
|
+
require "walmart_open/errors"
|
5
|
+
|
6
|
+
describe WalmartOpen::Requests::Search do
|
7
|
+
context "#submit" do
|
8
|
+
let(:client) { WalmartOpen::Client.new }
|
9
|
+
let(:success_response) { double(success?: true) }
|
10
|
+
let(:fail_response) { double(success?: false) }
|
11
|
+
let(:search_req) { WalmartOpen::Requests::Search.new("ipod") }
|
12
|
+
let(:search_response) do
|
13
|
+
{
|
14
|
+
"query" => "ipod",
|
15
|
+
"sort" => "relevance",
|
16
|
+
"format" => "json",
|
17
|
+
"responseGroup" => "base",
|
18
|
+
"totalResults" => 38666,
|
19
|
+
"start" => 1,
|
20
|
+
"numItems" => 10,
|
21
|
+
"items" => [
|
22
|
+
{
|
23
|
+
"itemId" => 21967115,
|
24
|
+
"parentItemId" => 21967115,
|
25
|
+
"name" => "Apple iPod Touch 5th Generation (Choose Your Color in 32GB or 64GB) with Bonus Accessory Kit",
|
26
|
+
"salePrice" => 279.0,
|
27
|
+
"categoryPath" => "Electronics/iPods & MP3 Players/Apple iPods",
|
28
|
+
"shortDescription" => "With an ultrathin design, a 4-inch Retina display, a 5-megapixel iSight camera on the 32GB and 64GB models, iTunes and the App Store, Siri, iMessage, FaceTime, Game Center and more it's the most fun iPod touch ever.",
|
29
|
+
"longDescription"=>"iPod touch features a 6-millimetre ultrathin design and a brilliant 4-inch Retina display. The 5-megapixel iSight camera on the 32GB and 64GB models lets you take stunning photos, even in panorama or record 1080p video. Discover music, movies and more from the iTunes Store or browse apps and games from the App Store. And with iOS 6 the world's most advanced mobile operating system you get Siri, iMessage, Facebook integration, FaceTime, Game Center and more.<p>Key Features</p><p></p><ul class="noindent"><li>Ultrathin design available in five gorgeous colors</li><li>4-inch Retina display</li><li>Apple A5 chip</li><li>5-megapixel iSight camera with 1080p HD video recording</li><li>FaceTime HD camera with 1.2-megapixel photos and 720p HD video recording</li><li>iOS 6 with features like Siri, Passbook and Facebook integration</li><li>iTunes Store with millions of songs and thousands of movies and TV shows</li><li>App Store with more than 900,000 apps, including over 100,000 games</li><li>Game Center with millions of gamers</li><li>Free text messaging over Wi-Fi with iMessage</li><li>Rich HTML email and Safari web browser</li><li>AirPlay and AirPlay Mirroring</li><li>40 hours of music playback, 8 hours of video playback</li><li>iPod touch loop included</li></ul>", "thumbnailImage"=>"http://i.walmartimages.com/i/p/11/13/01/55/15/1113015515798_100X100.jpg", "productTrackingUrl"=>"http://linksynergy.walmart.com/fs-bin/click?id=|LSNID|&offerid=223073.7200&type=14&catid=8&subid=0&hid=7200&tmpid=1081&RD_PARM1=http%253A%252F%252Fwww.walmart.com%252Fip%252FApple-iPod-Touch-5th-Generation-Choose-Your-Color-in-32GB-or-64GB-with-Bonus-Accessory-Kit%252F21967115%253Faffilsrc%253Dapi", "standardShipRate"=>0.0, "marketplace"=>false, "productUrl"=>"http://www.walmart.com/ip/Apple-iPod-Touch-5th-Generation-Choose-Your-Color-in-32GB-or-64GB-with-Bonus-Accessory-Kit/21967115",
|
30
|
+
"categoryNode"=>"3944_96469_1057284",
|
31
|
+
"bundle"=>true,
|
32
|
+
"availableOnline"=>true
|
33
|
+
},
|
34
|
+
{
|
35
|
+
"itemId" => 21967113,
|
36
|
+
"parentItemId" => 21967113,
|
37
|
+
"name" => "Apple iPod Nano 16GB (Choose Your Color) with Bonus Accessory Kit",
|
38
|
+
"salePrice" => 139.0,
|
39
|
+
"categoryPath" => "Electronics/iPods & MP3 Players/Apple iPods",
|
40
|
+
"shortDescription" => "The redesigned, ultraportable iPod nano now has a larger, 2.5" ",
|
41
|
+
"longDescription" => "<br><b>Key Features:</b><ul><li>2.5" ",
|
42
|
+
"thumbnailImage" => "http://i.walmartimages.com/i/p/11/13/01/55/15/1113015515796_100X100.jpg",
|
43
|
+
"productTrackingUrl" => "http://linksynergy.walmart.com/fs-bin/click?id=|LSNID|&offerid=223073.7200&type=14&catid=8&subid=0&hid=7200&tmpid=1081&RD_PARM1=http%253A%252F%252Fwww.walmart.com%252Fip%252FApple-iPod-Nano-16GB-Choose-Your-Color-with-Bonus-Accessory-Kit%252F21967113%253Faffilsrc%253Dapi",
|
44
|
+
"standardShipRate" => 0.0,
|
45
|
+
"marketplace" => false,
|
46
|
+
"productUrl" => "http://www.walmart.com/ip/Apple-iPod-Nano-16GB-Choose-Your-Color-with-Bonus-Accessory-Kit/21967113",
|
47
|
+
"categoryNode" => "3944_96469_1057284",
|
48
|
+
"bundle" => true,
|
49
|
+
"availableOnline" => true
|
50
|
+
}],
|
51
|
+
}
|
52
|
+
end
|
53
|
+
context "get success response" do
|
54
|
+
before do
|
55
|
+
expect(HTTParty).to receive(:get).and_return(success_response)
|
56
|
+
allow(success_response).to receive(:parsed_response).and_return(search_response)
|
57
|
+
end
|
58
|
+
|
59
|
+
it "return response" do
|
60
|
+
search_results = search_req.submit(client)
|
61
|
+
|
62
|
+
expect(search_results.query).to eq(search_response["query"])
|
63
|
+
expect(search_results.total).to eq(search_response["totalResults"])
|
64
|
+
expect(search_results.start).to eq(search_response["start"])
|
65
|
+
expect(search_results.items.count).to be(search_response["items"].count)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
context "get fail response" do
|
70
|
+
before do
|
71
|
+
allow(fail_response).to receive(:parsed_response).and_return({
|
72
|
+
"errors" => [{
|
73
|
+
"code" => 403,
|
74
|
+
"message" => "Account Inactive"
|
75
|
+
}]
|
76
|
+
})
|
77
|
+
end
|
78
|
+
it "raises authentication error" do
|
79
|
+
expect {
|
80
|
+
search_req.submit(client)
|
81
|
+
}.to raise_error(WalmartOpen::AuthenticationError)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|