walmart_open 0.1.2 → 0.1.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 99ef0d1a053ce3fcd3bf4a46e79ef360cb169e57
4
- data.tar.gz: 5d238dcb8bec67b17d36a0dc0a7640e5d57c3c59
3
+ metadata.gz: e2e2cc53e1f114c469a9c4b581830302bd4d95db
4
+ data.tar.gz: 68f2c814157e9cd885e800cbd4f63f259954982b
5
5
  SHA512:
6
- metadata.gz: ac2ae75e1a8c323b597bd878f7740d45f854d5a5bdc443db31afe1de6bad592af19f5bb814b1024d96b6dd7a4624e361c8a828bfad73ad2fc609243280c93018
7
- data.tar.gz: 3f657ba97af0af99d15d3447b56d378a62ae5b30efc47e445bd9ed8b28a4d4d414caa8fe6ef0025044ff1203d656d1171e21bb0a5351f66ab6c718c264500e62
6
+ metadata.gz: ca63c6c9051233b325afe870813eece19538deb76327f7aa6696b20786540f31d00521397305176d4c56762e283431e7d3d61a9306f6b9f93f95fbf9a3ac3ab3
7
+ data.tar.gz: 84c0f094e6dd90dc00bf165bb846204c21f7557fabed344c6532a86a16708d396ce07ab41d56c4f85bc981d1d7e6f795e85de2b2f1d34550c9b96217e87155de
@@ -15,11 +15,7 @@ module WalmartOpen
15
15
  # TODO: set the page!
16
16
  # @page = ...
17
17
 
18
- @items = []
19
-
20
- response["items"].each do |item|
21
- @items << Item.new(item)
22
- end
18
+ @items = Array(response["items"]).map { |item| Item.new(item) }
23
19
  end
24
20
  end
25
21
  end
@@ -1,3 +1,3 @@
1
1
  module WalmartOpen
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
@@ -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) do
7
- {
8
- "query" => "ipod",
9
- "sort" => "relevance",
10
- "format" => "json",
11
- "responseGroup" => "base",
12
- "totalResults" => 38666,
13
- "start" => 1,
14
- "numItems" => 10,
15
- "items"=>[
16
- {
17
- "itemId" => 21967115,
18
- "parentItemId" => 21967115,
19
- "name" => "Apple iPod Touch 5th Generation (Choose Your Color in 32GB or 64GB) with Bonus Accessory Kit",
20
- "salePrice" => 279.0,
21
- "categoryPath" => "Electronics/iPods & MP3 Players/Apple iPods",
22
- "shortDescription" => "With an ultrathin design, a 4-inch Retina display.",
23
- "longDescription" => "iPod touch features a 6-millimetre ultrathin design and a brilliant 4-inch Retina display.",
24
- "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",
25
- "standardShipRate" => 0.0,
26
- "marketplace" => false,
27
- "productUrl" => "http://www.walmart.com/ip/Apple-iPod-Touch-5th-Generation-Choose-Your-Color-in-32GB-or-64GB-with-Bonus-Accessory-Kit/21967115",
28
- "categoryNode" => "3944_96469_1057284",
29
- "bundle" => true,
30
- "availableOnline" => true
31
- },
32
- {
33
- "itemId" => 21967113,
34
- "parentItemId" => 21967113,
35
- "name" => "Apple iPod Nano 16GB (Choose Your Color) with Bonus Accessory Kit",
36
- "salePrice" => 139.0,
37
- "categoryPath" => "Electronics/iPods & MP3 Players/Apple iPods",
38
- "shortDescription" =>"The redesigned, ultraportable iPod nano now has a larger, 2.5&quot.",
39
- "longDescription" => "&lt;br&gt;&lt;b&gt;Key Features:&lt;",
40
- "customerRating" => "4.789",
41
- "numReviews" => 375,
42
- "customerRatingImage" => "http://i2.walmartimages.com/i/CustRating/4_8.gif",
43
- "categoryNode" => "3944_96469_1057284",
44
- "bundle" => false,
45
- "availableOnline" => true
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&quot.",
42
+ "longDescription" => "&lt;br&gt;&lt;b&gt;Key Features:&lt;",
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
- it "sets value correctly" do
52
- search_results = WalmartOpen::SearchResults.new(search_result)
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
- expect(search_results.query).to eq(search_result["query"])
55
- expect(search_results.total).to eq(search_result["totalResults"])
56
- expect(search_results.start).to eq(search_result["start"])
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.2
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-03-28 00:00:00.000000000 Z
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