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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 95f3c106206a90f99fb34905b00304e6b7495479
4
- data.tar.gz: f3b59e1204b2e10f74a074a5f8bbb38edfb64d9c
3
+ metadata.gz: 53c2d3f393205f6efefb2fac672a494cc13a9f14
4
+ data.tar.gz: e339d4812334f4ee907ae9c1e92b536af666250f
5
5
  SHA512:
6
- metadata.gz: 39a2665ad1298a4aee9d7794ea52893a37859cdb402b82478b708e1e29dd01fac9b61765abacc6d76c728824b2621b3c579d25a92950f780006a4e52d775b594
7
- data.tar.gz: 36da2a427e9053348d0f2cb89174cf321aca374b9237154c6224f59f7b68321e580f7cf961a74f512af47a8055fcd5d8420998884114c7c96d1d406c70fc4b7c
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.product_items.map { |product| new(product) }
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.product_items.map { |product| new(product) }
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
@@ -23,5 +23,5 @@
23
23
  #++
24
24
 
25
25
  module Zanox
26
- VERSION = '0.5.6'
26
+ VERSION = '0.5.7'
27
27
  end
@@ -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(7187) }
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] == 7187 }).to be_truthy
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.6
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-30 00:00:00.000000000 Z
11
+ date: 2015-07-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty