pwinty 3.0.1 → 3.0.2

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
  SHA256:
3
- metadata.gz: 5076f4e3e6fe45dc91cd6f502d24c3579406b2894e13835c4455feaeca66eb86
4
- data.tar.gz: '07998de4bca760eee940c24e235e36aa74a543a93aee204fe6bc5f5cf0109292'
3
+ metadata.gz: 9fb9342998514edb4c51d29d77f8572ca73baae3e213843151b8c24b14493952
4
+ data.tar.gz: 59acc7485eb5463db08ca457d55f60b273c670d5ded7a5b5277f808b68773267
5
5
  SHA512:
6
- metadata.gz: d5ad732854db523ae41b30541cced1335616816219166caaa737a082fe6a55625c9c0d76cb678ce1056bbe70bb6d7d51f44766f16adf0f9c4e855b5dea09071d
7
- data.tar.gz: 2ee761b1229f0cf3b08ac81b27055016a54e1e394c5f93ee4d9c970d72671add4197681b598b09eb361d3acabfe0e7790335e19a4422c1b4626728721eb1b8e4
6
+ metadata.gz: b11e31df0970ad45537c2c9def49fdcc581a27ad260c6d39eb91fb8e03d067548f909434f3a721a42cf3ef89dfcf22134c03e2e81664e0ad7e8a81d21c9ae7c9
7
+ data.tar.gz: '03599d879d7b02cfadb975f8fb7544df05f391991051149c6f65e3ad8a36c93542686379c4a1e7740cc3b8c711413986f6ffe03708608e9d9c4aa97002058c44'
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- pwinty (3.0.1)
4
+ pwinty (3.0.2)
5
5
  dry-struct (~> 1.0)
6
6
  dry-struct-setters (~> 0.2)
7
7
  faraday (~> 0.15)
@@ -36,12 +36,20 @@ module Pwinty
36
36
  attribute :invoiceCurrency, Types::String.optional
37
37
  attribute :tag, Types::String.optional
38
38
 
39
- def self.list
40
- response = Pwinty.conn.get("orders?count=250&offset=0")
41
- r_data = response.body['data']
42
- # TODO There is some bug with offset in the API.
43
- # total_count = r_data['count']
44
- Pwinty.collate_results(r_data['content'], self)
39
+ def self.list(page_size=50)
40
+ all_orders = list_each_page(page_size)
41
+ Pwinty.collate_results(all_orders, self)
42
+ end
43
+
44
+ def self.list_each_page(page_size, page_start=0, total_orders_count=nil)
45
+ all_orders = []
46
+ while total_orders_count.nil? or all_orders.count < total_orders_count
47
+ response = Pwinty.conn.get("orders?limit=#{page_size}&start=#{page_start}")
48
+ total_orders_count ||= response.body['data']['count']
49
+ all_orders = all_orders + response.body['data']['content']
50
+ page_start = page_start + page_size
51
+ end
52
+ all_orders
45
53
  end
46
54
 
47
55
 
@@ -1,3 +1,3 @@
1
1
  module Pwinty
2
- VERSION = "3.0.1"
2
+ VERSION = "3.0.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pwinty
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.1
4
+ version: 3.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thomas Harvey