walmart_open 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e2e2cc53e1f114c469a9c4b581830302bd4d95db
|
4
|
+
data.tar.gz: 68f2c814157e9cd885e800cbd4f63f259954982b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ca63c6c9051233b325afe870813eece19538deb76327f7aa6696b20786540f31d00521397305176d4c56762e283431e7d3d61a9306f6b9f93f95fbf9a3ac3ab3
|
7
|
+
data.tar.gz: 84c0f094e6dd90dc00bf165bb846204c21f7557fabed344c6532a86a16708d396ce07ab41d56c4f85bc981d1d7e6f795e85de2b2f1d34550c9b96217e87155de
|
data/lib/walmart_open/version.rb
CHANGED
@@ -3,58 +3,79 @@ require "walmart_open/search_results"
|
|
3
3
|
|
4
4
|
describe WalmartOpen::SearchResults do
|
5
5
|
context ".new" do
|
6
|
-
let(:search_result)
|
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
|
-
|
6
|
+
let(:search_results) { WalmartOpen::SearchResults.new(search_result) }
|
7
|
+
|
8
|
+
context "with a some items" do
|
9
|
+
let(:search_result) do
|
10
|
+
{
|
11
|
+
"query" => "ipod",
|
12
|
+
"sort" => "relevance",
|
13
|
+
"format" => "json",
|
14
|
+
"responseGroup" => "base",
|
15
|
+
"totalResults" => 38666,
|
16
|
+
"start" => 1,
|
17
|
+
"numItems" => 10,
|
18
|
+
"items"=>[
|
19
|
+
{
|
20
|
+
"itemId" => 21967115,
|
21
|
+
"parentItemId" => 21967115,
|
22
|
+
"name" => "Apple iPod Touch 5th Generation (Choose Your Color in 32GB or 64GB) with Bonus Accessory Kit",
|
23
|
+
"salePrice" => 279.0,
|
24
|
+
"categoryPath" => "Electronics/iPods & MP3 Players/Apple iPods",
|
25
|
+
"shortDescription" => "With an ultrathin design, a 4-inch Retina display.",
|
26
|
+
"longDescription" => "iPod touch features a 6-millimetre ultrathin design and a brilliant 4-inch Retina display.",
|
27
|
+
"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",
|
28
|
+
"standardShipRate" => 0.0,
|
29
|
+
"marketplace" => false,
|
30
|
+
"productUrl" => "http://www.walmart.com/ip/Apple-iPod-Touch-5th-Generation-Choose-Your-Color-in-32GB-or-64GB-with-Bonus-Accessory-Kit/21967115",
|
31
|
+
"categoryNode" => "3944_96469_1057284",
|
32
|
+
"bundle" => true,
|
33
|
+
"availableOnline" => true
|
34
|
+
},
|
35
|
+
{
|
36
|
+
"itemId" => 21967113,
|
37
|
+
"parentItemId" => 21967113,
|
38
|
+
"name" => "Apple iPod Nano 16GB (Choose Your Color) with Bonus Accessory Kit",
|
39
|
+
"salePrice" => 139.0,
|
40
|
+
"categoryPath" => "Electronics/iPods & MP3 Players/Apple iPods",
|
41
|
+
"shortDescription" =>"The redesigned, ultraportable iPod nano now has a larger, 2.5".",
|
42
|
+
"longDescription" => "<br><b>Key Features:<",
|
43
|
+
"customerRating" => "4.789",
|
44
|
+
"numReviews" => 375,
|
45
|
+
"customerRatingImage" => "http://i2.walmartimages.com/i/CustRating/4_8.gif",
|
46
|
+
"categoryNode" => "3944_96469_1057284",
|
47
|
+
"bundle" => false,
|
48
|
+
"availableOnline" => true
|
49
|
+
}
|
50
|
+
]
|
51
|
+
}
|
52
|
+
end
|
53
|
+
|
54
|
+
it "sets value correctly" do
|
55
|
+
expect(search_results.query).to eq(search_result["query"])
|
56
|
+
expect(search_results.total).to eq(search_result["totalResults"])
|
57
|
+
expect(search_results.start).to eq(search_result["start"])
|
58
|
+
expect(search_results.items.count).to be(search_result["items"].count)
|
59
|
+
end
|
49
60
|
end
|
50
61
|
|
51
|
-
|
52
|
-
|
62
|
+
context "without items" do
|
63
|
+
let(:search_result) do
|
64
|
+
{
|
65
|
+
"query" => "ipod",
|
66
|
+
"sort" => "relevance",
|
67
|
+
"format" => "json",
|
68
|
+
"responseGroup" => "base",
|
69
|
+
"totalResults" => 38666,
|
70
|
+
"start" => 1,
|
71
|
+
"numItems" => 10,
|
72
|
+
"items"=>nil
|
73
|
+
}
|
74
|
+
end
|
53
75
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
expect(search_results.items.count).to be(search_result["items"].count)
|
76
|
+
it "returns an empty array" do
|
77
|
+
expect(search_results.items.count).to be(0)
|
78
|
+
end
|
58
79
|
end
|
59
80
|
end
|
60
81
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: walmart_open
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ngan Pham
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-
|
12
|
+
date: 2016-05-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: httparty
|
@@ -140,7 +140,6 @@ files:
|
|
140
140
|
- lib/walmart_open/connection_manager.rb
|
141
141
|
- lib/walmart_open/errors.rb
|
142
142
|
- lib/walmart_open/item.rb
|
143
|
-
- lib/walmart_open/order_verify_xml_builder.rb
|
144
143
|
- lib/walmart_open/request.rb
|
145
144
|
- lib/walmart_open/requests/execute_order.rb
|
146
145
|
- lib/walmart_open/requests/feed.rb
|
@@ -1,62 +0,0 @@
|
|
1
|
-
require "builder"
|
2
|
-
|
3
|
-
module WalmartOpen
|
4
|
-
class OrderXMLBuilder
|
5
|
-
attr_reader :order
|
6
|
-
|
7
|
-
def initialize(order)
|
8
|
-
@order = order
|
9
|
-
end
|
10
|
-
|
11
|
-
def build
|
12
|
-
xml = Builder::XmlMarkup.new
|
13
|
-
xml.instruct!(:xml, version: "1.0", encoding: "UTF-8")
|
14
|
-
xml.order do |xml|
|
15
|
-
payment(xml)
|
16
|
-
shipping_address(xml)
|
17
|
-
xml.partnerOrderId(order.partner_order_id)
|
18
|
-
xml.partnerOrderTime(order.partner_order_time.strftime( "%H:%M:%S"))
|
19
|
-
|
20
|
-
xml.items do |xml|
|
21
|
-
order.items.each do |order_item|
|
22
|
-
item(xml, order_item)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
xml.target!
|
27
|
-
end
|
28
|
-
|
29
|
-
end
|
30
|
-
|
31
|
-
private
|
32
|
-
|
33
|
-
def shipping_address(xml)
|
34
|
-
xml.shippingAddress do |xml|
|
35
|
-
xml.firstName(order.shipping_address.first_name)
|
36
|
-
xml.lastName(order.shipping_address.last_name) if order.shipping_address.last_name
|
37
|
-
xml.street1(order.shipping_address.street1)
|
38
|
-
xml.street2(order.shipping_address.street2) if order.shipping_address.street2
|
39
|
-
xml.city(order.shipping_address.city)
|
40
|
-
xml.state(order.shipping_address.state)
|
41
|
-
xml.zip(order.shipping_address.zipcode)
|
42
|
-
xml.country(order.shipping_address.country)
|
43
|
-
xml.phone(order.shipping_address.phone)
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
def payment(xml)
|
48
|
-
xml.payment do |xml|
|
49
|
-
xml.billingRecordId(order.billing_record_id)
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
def item(xml, order_item)
|
54
|
-
xml.item do |xml|
|
55
|
-
xml.itemId(order_item.item_id)
|
56
|
-
xml.quantity(order_item.quantity)
|
57
|
-
xml.itemPrice(order_item.item_price) if order_item.item_price
|
58
|
-
xml.shippingPrice(order_item.shipping_price) if order_item.shipping_price
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|