zanoxrb 0.5.6 → 0.5.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/zanox/resources/product.rb +12 -2
- data/lib/zanox/version.rb +1 -1
- data/specs/resources/product_spec.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 53c2d3f393205f6efefb2fac672a494cc13a9f14
|
4
|
+
data.tar.gz: e339d4812334f4ee907ae9c1e92b536af666250f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7bbf5eb4a76c3583c602c4956a32b1fd1df44f1ea77f876b7168308f8a090a05ae2bec9bd10e852706891e115327e50e859b6e3ded2224838573f0b771f914ac
|
7
|
+
data.tar.gz: f5a4b28fedcdd1fd078e0a5bc5fbf1f69010d352834dd411c3d0789266ffe93fab5141c14a8ebf248913c2d8f67e4852246757bc14a583fe7908315fea41b83b
|
@@ -26,6 +26,7 @@ module Zanox
|
|
26
26
|
class Product < Item
|
27
27
|
attr_reader :pid, :name, :program, :description, :excerpt, :manufacturer, :category,
|
28
28
|
:images, :currency, :price, :shipping_costs, :delivery_time, :tracking_link
|
29
|
+
attr_accessor :pagination
|
29
30
|
|
30
31
|
###################
|
31
32
|
# - pid (String) Product ID
|
@@ -68,19 +69,28 @@ module Zanox
|
|
68
69
|
def find(keyword, args = {})
|
69
70
|
args.merge!({ q: keyword })
|
70
71
|
response = API.request(:products, args)
|
71
|
-
response
|
72
|
+
from_product_items(response)
|
72
73
|
end
|
73
74
|
|
74
75
|
def from_shop(shop_id, args = {})
|
75
76
|
args.merge!({ programs: shop_id })
|
76
77
|
response = API.request(:products, args)
|
77
|
-
response
|
78
|
+
from_product_items(response)
|
78
79
|
end
|
79
80
|
|
80
81
|
def from_id(product_id, args = {})
|
81
82
|
response = API.request("products/product/#{product_id}", args)
|
82
83
|
new(response.product_item.first)
|
83
84
|
end
|
85
|
+
|
86
|
+
private
|
87
|
+
def from_product_items(response)
|
88
|
+
response.product_items.map do |product|
|
89
|
+
item = new(product)
|
90
|
+
item.pagination = { page: response.page, items: response.items, total: response.total }
|
91
|
+
item
|
92
|
+
end
|
93
|
+
end
|
84
94
|
end
|
85
95
|
|
86
96
|
private
|
data/lib/zanox/version.rb
CHANGED
@@ -22,7 +22,7 @@ describe Zanox::Product do
|
|
22
22
|
end
|
23
23
|
|
24
24
|
describe '#from_shop' do
|
25
|
-
let(:products) { Zanox::Product.from_shop(
|
25
|
+
let(:products) { Zanox::Product.from_shop(5563) }
|
26
26
|
|
27
27
|
it 'finds products by keyword' do
|
28
28
|
expect(products.length).to be >= 8
|
@@ -33,7 +33,7 @@ describe Zanox::Product do
|
|
33
33
|
end
|
34
34
|
|
35
35
|
it 'returns only Products that belongs to given shop' do
|
36
|
-
expect(products.all? { |product| product.program[:id] ==
|
36
|
+
expect(products.all? { |product| product.program[:id] == 5563 }).to be_truthy
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zanoxrb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Giovanni Capuano
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-07-
|
11
|
+
date: 2015-07-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|