quaderno 1.17.1 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +28 -73
- data/changelog.md +9 -0
- data/lib/quaderno-ruby/base.rb +13 -3
- data/lib/quaderno-ruby/behavior/block.rb +1 -1
- data/lib/quaderno-ruby/behavior/crud.rb +43 -24
- data/lib/quaderno-ruby/behavior/deliver.rb +1 -1
- data/lib/quaderno-ruby/behavior/payment.rb +2 -2
- data/lib/quaderno-ruby/behavior/retrieve.rb +1 -1
- data/lib/quaderno-ruby/collection.rb +16 -11
- data/lib/quaderno-ruby/report.rb +4 -4
- data/lib/quaderno-ruby/tax.rb +5 -5
- data/lib/quaderno-ruby/version.rb +1 -1
- data/lib/quaderno-ruby.rb +1 -0
- data/quaderno.gemspec +1 -1
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 18ba0623ca695fdd9f95f1bb922e7002f6482224aa8b793b307bbe233327b0d9
|
4
|
+
data.tar.gz: 0d3719afdbbfc2739a64513d451444f7bfd268fe9a521e6522f24d160acf7612
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2ce0a701562afa7626f8bc0f6ee19a72f2a36360c65a2aff42732bb6aa2fdfd71fc3f22039c4d910a33ccd01f5df528fe5453ebd6d50d05ae71097b1a0986373
|
7
|
+
data.tar.gz: 38aeb9bd57999f419ead00c46a4f2382de663b8c18c935dc13c9ea9f5b43d4dfcc80b3cb822d55f7d2c884ac6fe0ad14b679b6e7da43d2bd01e329a310da437f
|
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Quaderno-ruby is a ruby wrapper for [Quaderno API] (https://github.com/quaderno/quaderno-api).
|
4
4
|
|
5
|
-
Current version is
|
5
|
+
Current version is 2.0.1 See the changelog [here](https://github.com/quaderno/quaderno-ruby/blob/master/changelog.md)
|
6
6
|
|
7
7
|
## Installation & Configuration
|
8
8
|
|
@@ -99,10 +99,9 @@ Quaderno-ruby parses all the json responses in human readable data, so you can a
|
|
99
99
|
### Getting contacts
|
100
100
|
```ruby
|
101
101
|
Quaderno::Contact.all #=> Array
|
102
|
-
Quaderno::Contact.all(page: 1) #=> Array
|
103
102
|
```
|
104
103
|
|
105
|
-
will return an array with all your contacts
|
104
|
+
will return an array with all your contacts. You can also pass query strings using the attribute :q in order to filter the results by contact name. For example:
|
106
105
|
|
107
106
|
```ruby
|
108
107
|
Quaderno::Contact.all(q: 'John Doe') #=> Array
|
@@ -188,10 +187,9 @@ will delete the item with the id passed as parameter. If the deletion was succe
|
|
188
187
|
### Getting invoices
|
189
188
|
```ruby
|
190
189
|
Quaderno::Invoice.all #=> Array
|
191
|
-
Quaderno::Invoice.all(page: 1) #=> Array
|
192
190
|
```
|
193
191
|
|
194
|
-
will return an array with all your invoices
|
192
|
+
will return an array with all your invoices. You can also pass query strings using the attribute :q in order to filter the results by contact name, :state to filter by state or :date to filter by date
|
195
193
|
|
196
194
|
### Finding an invoice
|
197
195
|
```ruby
|
@@ -259,67 +257,14 @@ In order to remove a payment you will need the Invoice instance you want to upd
|
|
259
257
|
result.success #=> Boolean
|
260
258
|
```
|
261
259
|
|
262
|
-
## Managing receipts
|
263
|
-
|
264
|
-
### Getting receipts
|
265
|
-
```ruby
|
266
|
-
Quaderno::Receipt.all #=> Array
|
267
|
-
Quaderno::Receipt.all(page: 1) #=> Array
|
268
|
-
```
|
269
|
-
|
270
|
-
will return an array with all your receipts on the first page. You can also pass query strings using the attribute :q in order to filter the results by contact name, :state to filter by state or :date to filter by date
|
271
|
-
|
272
|
-
### Finding a receipt
|
273
|
-
```ruby
|
274
|
-
Quaderno::Receipt.find(id) #=> Quaderno::Receipt
|
275
|
-
```
|
276
|
-
|
277
|
-
will return the receipt with the id passed as parameter.
|
278
|
-
|
279
|
-
### Creating a new receipt
|
280
|
-
|
281
|
-
```ruby
|
282
|
-
Quaderno::Receipt.create(params) #=> Quaderno::Receipt
|
283
|
-
```
|
284
|
-
|
285
|
-
will create an receipt using the information of the hash passed as parameter.
|
286
|
-
|
287
|
-
### Updating an existing receipt
|
288
|
-
```ruby
|
289
|
-
Quaderno::Receipt.update(id, params) #=> Quaderno::Receipt
|
290
|
-
```
|
291
|
-
|
292
|
-
will update the specified receipt with the data of the hash passed as second parameter.
|
293
|
-
|
294
|
-
### Deleting an receipt
|
295
|
-
|
296
|
-
```ruby
|
297
|
-
Quaderno::Receipt.delete(id) #=> Quaderno::Receipt
|
298
|
-
```
|
299
|
-
|
300
|
-
will delete the receipt with the id passed as parameter. If the deletion was successful, an instance of `Quaderno::Receipt` with the `deleted` attribute set to `true` will be returned.
|
301
|
-
|
302
|
-
### Delivering the receipt
|
303
|
-
|
304
|
-
In order to deliver the receipt to the default recipient you will need the receipt you want to send.
|
305
|
-
|
306
|
-
```ruby
|
307
|
-
receipt = Quaderno::Receipt.find(receipt_id)
|
308
|
-
result = receipt.deliver #=> Quaderno::Base
|
309
|
-
|
310
|
-
result.success #=> Boolean
|
311
|
-
```
|
312
|
-
|
313
|
-
|
314
260
|
## Managing credits
|
315
261
|
|
316
262
|
### Getting credits
|
317
263
|
```ruby
|
318
264
|
Quaderno::Credit.all #=> Array
|
319
|
-
Quaderno::Credit.all(page: 1) #=> Array
|
320
265
|
```
|
321
266
|
|
322
|
-
will return an array with all your credit notes
|
267
|
+
will return an array with all your credit notes. You can also pass query strings using the attribute :q in order to filter the results by contact name, :state to filter by state or :date to filter by date
|
323
268
|
|
324
269
|
### Finding a credit
|
325
270
|
```ruby
|
@@ -337,10 +282,10 @@ will return the credit note with the transaction id passed as parameter.
|
|
337
282
|
### Creating a new credit
|
338
283
|
|
339
284
|
```ruby
|
340
|
-
Quaderno::Credit.create(
|
285
|
+
Quaderno::Credit.create(invoice_id: 42) #=> Quaderno::Credit
|
341
286
|
```
|
342
287
|
|
343
|
-
will create a credit
|
288
|
+
will create a credit from the invoice specified in the parameter.
|
344
289
|
|
345
290
|
### Updating an existing credit
|
346
291
|
```ruby
|
@@ -395,10 +340,9 @@ If the deletion was successful, an instance of `Quaderno::Payment` with the `del
|
|
395
340
|
### Getting estimates
|
396
341
|
```ruby
|
397
342
|
Quaderno::Estimate.all #=> Array
|
398
|
-
Quaderno::Estimate.all(page: 1) #=> Array
|
399
343
|
```
|
400
344
|
|
401
|
-
will return an array with all your estimates
|
345
|
+
will return an array with all your estimates.
|
402
346
|
|
403
347
|
### Finding an estimate
|
404
348
|
```ruby
|
@@ -464,10 +408,9 @@ In order to remove a payment you will need the estimate you want to update.
|
|
464
408
|
### Getting expenses
|
465
409
|
```ruby
|
466
410
|
Quaderno::Expense.all #=> Array
|
467
|
-
Quaderno::Expense.all(page: 1) #=> Array
|
468
411
|
```
|
469
412
|
|
470
|
-
will return an array with all your expenses
|
413
|
+
will return an array with all your expenses. You can also pass query strings using the attribute :q in order to filter the results by contact name, :state to filter by state or :date to filter by date.
|
471
414
|
|
472
415
|
### Finding an expense
|
473
416
|
```ruby
|
@@ -503,10 +446,9 @@ will delete the expense with the id passed as parameter. If the deletion was suc
|
|
503
446
|
### Getting recurrings
|
504
447
|
```ruby
|
505
448
|
Quaderno::Recurring.all #=> Array
|
506
|
-
Quaderno::Recurring.all(page: 1) #=> Array
|
507
449
|
```
|
508
450
|
|
509
|
-
will return an array with all your recurring notes
|
451
|
+
will return an array with all your recurring notes. You can also pass query strings using the attribute :q in order to filter the results by contact name, :state to filter by state or :date to filter by date
|
510
452
|
|
511
453
|
### Finding a recurring
|
512
454
|
```ruby
|
@@ -669,12 +611,27 @@ All those exceptions inherit from `Quaderno::Exceptions::BaseException`.
|
|
669
611
|
Whenever you call the `all` method on one of the classes, the result will be a `Quaderno::Collection`. For example:
|
670
612
|
|
671
613
|
```ruby
|
672
|
-
collection = Quaderno::Contact.all
|
614
|
+
collection = Quaderno::Contact.all
|
673
615
|
|
674
616
|
collection.class #=> Quaderno::Collection
|
675
|
-
collection.
|
676
|
-
collection.
|
677
|
-
|
617
|
+
collection.has_next? #=> true
|
618
|
+
collection.next_page #=> another instance of
|
619
|
+
```
|
620
|
+
|
621
|
+
The `next_page` method is an abstraction for the `created_before` parameter, which you may also use with the `all` method.
|
622
|
+
|
623
|
+
```ruby
|
624
|
+
collection = Quaderno::Contact.all
|
625
|
+
|
626
|
+
Quaderno::Contact.all(created_before: collection.last.id)
|
627
|
+
```
|
628
|
+
|
629
|
+
You can also use the `limit` parameter to determine how many results to retrieve. Its default is `25`, and Quaderno will cap the limit at `100`.
|
630
|
+
|
631
|
+
```ruby
|
632
|
+
collection = Quaderno::Contact.all(limit: 50)
|
633
|
+
|
634
|
+
collection.length #=> 50
|
678
635
|
```
|
679
636
|
|
680
637
|
### Thread-safe configuration
|
@@ -731,5 +688,3 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
731
688
|
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
732
689
|
|
733
690
|
THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
734
|
-
|
735
|
-
|
data/changelog.md
CHANGED
@@ -1,5 +1,14 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 2.0.1
|
4
|
+
* Fix an issue where requests would result in an error due to a missing `require`
|
5
|
+
|
6
|
+
## 2.0.0
|
7
|
+
* **Breaking change** Pagination strategy has been updated to be cursor based. Collections no longer offer the `current_page` and `total_pages` methods, and offer `has_more?` and `next_page` instead. The `page` parameter is no longer supported either, in favour of the `created_before` parameter. [See more information in the documentation](https://developers.quaderno.io/api/#pagination).
|
8
|
+
* **Breaking change** `Quaderno::Tax.calculate` uses the [new tax calculation endpoint](https://developers.quaderno.io/api/#calculate-a-tax-rate). This endpoint accepts address parameters with the prefix `to_`. For example, `postal_code` is deprecated in favour of `to_postal_code`.
|
9
|
+
* `Quaderno::Tax.validate` uses the [new tax ID validation endpoint](https://developers.quaderno.io/api/#validate-a-tax-id). The signature did not change, and no updates are necessary.
|
10
|
+
* All requests now send the gem version in their User Agent header.
|
11
|
+
|
3
12
|
## 1.17.1
|
4
13
|
* Do not modify the input arguments when the thread-safe mode is used.
|
5
14
|
|
data/lib/quaderno-ruby/base.rb
CHANGED
@@ -49,7 +49,7 @@ class Quaderno::Base < OpenStruct
|
|
49
49
|
def self.authorization(auth_token, mode = nil)
|
50
50
|
mode ||= :production
|
51
51
|
url = mode == :sandbox ? SANDBOX_URL : PRODUCTION_URL
|
52
|
-
response = get("#{url}authorization.json", basic_auth: { username: auth_token }, headers:
|
52
|
+
response = get("#{url}authorization.json", basic_auth: { username: auth_token }, headers: default_headers)
|
53
53
|
|
54
54
|
if response.code == 200
|
55
55
|
data = self.new(response.parsed_response)
|
@@ -71,7 +71,7 @@ class Quaderno::Base < OpenStruct
|
|
71
71
|
|
72
72
|
party_response = get("#{authentication[:url]}ping.json",
|
73
73
|
basic_auth: authentication[:basic_auth],
|
74
|
-
headers:
|
74
|
+
headers: default_headers.merge(authentication[:headers])
|
75
75
|
)
|
76
76
|
|
77
77
|
check_exception_for(party_response, { subdomain_or_token: true })
|
@@ -96,7 +96,7 @@ class Quaderno::Base < OpenStruct
|
|
96
96
|
|
97
97
|
party_response = get("#{authentication[:url]}me.json",
|
98
98
|
basic_auth: authentication[:basic_auth],
|
99
|
-
headers:
|
99
|
+
headers: default_headers.merge(authentication[:headers])
|
100
100
|
)
|
101
101
|
|
102
102
|
check_exception_for(party_response, { subdomain_or_token: true })
|
@@ -135,7 +135,17 @@ class Quaderno::Base < OpenStruct
|
|
135
135
|
@_document ||= document
|
136
136
|
end
|
137
137
|
|
138
|
+
def self.default_headers
|
139
|
+
user_agent_header.merge(version_header)
|
140
|
+
end
|
141
|
+
|
142
|
+
def self.user_agent_header
|
143
|
+
{ "User-Agent" => "Quaderno Ruby Gem #{Quaderno::VERSION}" }
|
144
|
+
end
|
145
|
+
|
138
146
|
def self.version_header
|
139
147
|
{ 'Accept' => @@api_version.to_i.zero? ? "application/json" : "application/json; api_version=#{@@api_version.to_i}"}
|
140
148
|
end
|
149
|
+
|
150
|
+
headers self.default_headers
|
141
151
|
end
|
@@ -13,7 +13,7 @@ module Quaderno::Behavior
|
|
13
13
|
|
14
14
|
response = put("#{authentication[:url]}#{api_model.api_path}/#{id}/block.json",
|
15
15
|
basic_auth: authentication[:basic_auth],
|
16
|
-
headers:
|
16
|
+
headers: default_headers.merge(authentication[:headers])
|
17
17
|
)
|
18
18
|
|
19
19
|
check_exception_for(response, { rate_limit: true, subdomain_or_token: true, id: true })
|
@@ -23,6 +23,17 @@ module Quaderno::Behavior
|
|
23
23
|
element
|
24
24
|
end
|
25
25
|
|
26
|
+
def all_from_url(url, options = {})
|
27
|
+
authentication = get_authentication(api_model: api_model)
|
28
|
+
|
29
|
+
response = get(url,
|
30
|
+
basic_auth: authentication[:basic_auth],
|
31
|
+
headers: default_headers.merge(authentication[:headers])
|
32
|
+
)
|
33
|
+
|
34
|
+
handle_all_response(response, authentication, options)
|
35
|
+
end
|
36
|
+
|
26
37
|
def all(options = {})
|
27
38
|
authentication = get_authentication(options.merge(api_model: api_model))
|
28
39
|
filter = options.dup.delete_if { |k,v| %w(auth_token access_token api_url mode api_model).include? k.to_s }
|
@@ -30,28 +41,10 @@ module Quaderno::Behavior
|
|
30
41
|
response = get("#{authentication[:url]}#{api_model.api_path}.json",
|
31
42
|
query: filter,
|
32
43
|
basic_auth: authentication[:basic_auth],
|
33
|
-
headers:
|
44
|
+
headers: default_headers.merge(authentication[:headers])
|
34
45
|
)
|
35
46
|
|
36
|
-
|
37
|
-
array = response.parsed_response
|
38
|
-
collection = Quaderno::Collection.new
|
39
|
-
|
40
|
-
if is_a_document?
|
41
|
-
array.each do |element|
|
42
|
-
element[:authentication_data] = authentication
|
43
|
-
api_model.parse_nested(element)
|
44
|
-
collection << (new element)
|
45
|
-
end
|
46
|
-
else
|
47
|
-
array.each { |element| collection << (new element) }
|
48
|
-
end
|
49
|
-
|
50
|
-
collection.rate_limit_info = response
|
51
|
-
collection.current_page = response.headers['x-pages-currentpage']
|
52
|
-
collection.total_pages = response.headers['x-pages-totalpages']
|
53
|
-
|
54
|
-
collection
|
47
|
+
handle_all_response(response, authentication, options)
|
55
48
|
end
|
56
49
|
|
57
50
|
def find(id, options = {})
|
@@ -59,7 +52,7 @@ module Quaderno::Behavior
|
|
59
52
|
|
60
53
|
response = get("#{authentication[:url]}#{api_model.api_path}/#{id}.json",
|
61
54
|
basic_auth: authentication[:basic_auth],
|
62
|
-
headers:
|
55
|
+
headers: default_headers.merge(authentication[:headers])
|
63
56
|
)
|
64
57
|
|
65
58
|
check_exception_for(response, { rate_limit: true, subdomain_or_token: true, id: true })
|
@@ -81,7 +74,7 @@ module Quaderno::Behavior
|
|
81
74
|
response = post("#{authentication[:url]}#{api_model.api_path}.json",
|
82
75
|
body: params.to_json,
|
83
76
|
basic_auth: authentication[:basic_auth],
|
84
|
-
headers:
|
77
|
+
headers: default_headers.merge(authentication[:headers]).merge('Content-Type' => 'application/json')
|
85
78
|
)
|
86
79
|
|
87
80
|
check_exception_for(response, { rate_limit: true, subdomain_or_token: true, required_fields: true })
|
@@ -103,7 +96,7 @@ module Quaderno::Behavior
|
|
103
96
|
response = put("#{authentication[:url]}#{api_model.api_path}/#{id}.json",
|
104
97
|
body: params.to_json,
|
105
98
|
basic_auth: authentication[:basic_auth],
|
106
|
-
headers:
|
99
|
+
headers: default_headers.merge(authentication[:headers]).merge('Content-Type' => 'application/json')
|
107
100
|
)
|
108
101
|
|
109
102
|
check_exception_for(response, { rate_limit: true, required_fields: true, subdomain_or_token: true, id: true })
|
@@ -123,7 +116,7 @@ module Quaderno::Behavior
|
|
123
116
|
|
124
117
|
response = HTTParty.delete("#{authentication[:url]}#{ api_model.api_path }/#{ id }.json",
|
125
118
|
basic_auth: authentication[:basic_auth],
|
126
|
-
headers:
|
119
|
+
headers: default_headers.merge(authentication[:headers])
|
127
120
|
)
|
128
121
|
check_exception_for(response, { rate_limit: true, subdomain_or_token: true, id: true, has_documents: true })
|
129
122
|
|
@@ -134,6 +127,32 @@ module Quaderno::Behavior
|
|
134
127
|
|
135
128
|
object
|
136
129
|
end
|
130
|
+
|
131
|
+
private
|
132
|
+
|
133
|
+
def handle_all_response(response, authentication, request_options)
|
134
|
+
check_exception_for(response, { rate_limit: true, subdomain_or_token: true })
|
135
|
+
array = response.parsed_response
|
136
|
+
collection = Quaderno::Collection.new
|
137
|
+
|
138
|
+
if is_a_document?
|
139
|
+
array.each do |element|
|
140
|
+
element[:authentication_data] = authentication
|
141
|
+
api_model.parse_nested(element)
|
142
|
+
collection << (new element)
|
143
|
+
end
|
144
|
+
else
|
145
|
+
array.each { |element| collection << (new element) }
|
146
|
+
end
|
147
|
+
|
148
|
+
collection.rate_limit_info = response
|
149
|
+
collection.request_options = request_options
|
150
|
+
collection.collection_type = self
|
151
|
+
collection.has_more = response.headers['x-pages-hasmore']
|
152
|
+
collection.next_page_url = response.headers['x-pages-nextpage']
|
153
|
+
|
154
|
+
collection
|
155
|
+
end
|
137
156
|
end
|
138
157
|
end
|
139
158
|
end
|
@@ -13,7 +13,7 @@ module Quaderno::Behavior
|
|
13
13
|
|
14
14
|
party_response = api_model.get("#{authentication_data[:url]}#{api_model.api_path}/#{id}/deliver.json",
|
15
15
|
basic_auth: authentication_data[:basic_auth],
|
16
|
-
headers: self.class.
|
16
|
+
headers: self.class.default_headers.merge(authentication_data[:headers])
|
17
17
|
)
|
18
18
|
|
19
19
|
api_model.check_exception_for(party_response, { rate_limit: true, subdomain_or_token: true, id: true, required_fields: true })
|
@@ -17,7 +17,7 @@ module Quaderno::Behavior
|
|
17
17
|
response = api_model.post("#{authentication_data[:url]}#{api_model.api_path}/#{id}/payments.json",
|
18
18
|
body: params,
|
19
19
|
basic_auth: authentication_data[:basic_auth],
|
20
|
-
headers: self.class.
|
20
|
+
headers: self.class.default_headers.merge(authentication_data[:headers])
|
21
21
|
)
|
22
22
|
|
23
23
|
api_model.check_exception_for(response, { rate_limit: true, subdomain_or_token: true, required_fields: true })
|
@@ -35,7 +35,7 @@ module Quaderno::Behavior
|
|
35
35
|
|
36
36
|
response = HTTParty.delete("#{authentication_data[:url]}#{api_model.api_path}/#{id}/payments/#{payment_id}.json",
|
37
37
|
basic_auth: authentication_data[:basic_auth],
|
38
|
-
headers: self.class.
|
38
|
+
headers: self.class.default_headers.merge(authentication_data[:headers])
|
39
39
|
)
|
40
40
|
|
41
41
|
api_model.check_exception_for(response, { rate_limit: true, subdomain_or_token: true, id: true })
|
@@ -13,7 +13,7 @@ module Quaderno::Behavior
|
|
13
13
|
|
14
14
|
response = get("#{authentication[:url]}#{gateway}/#{@_retrieve_path}/#{gateway_id}.json",
|
15
15
|
basic_auth: authentication[:basic_auth],
|
16
|
-
headers:
|
16
|
+
headers: default_headers.merge(authentication[:headers])
|
17
17
|
)
|
18
18
|
|
19
19
|
check_exception_for(response, { rate_limit: true, subdomain_or_token: true, id: true })
|
@@ -1,23 +1,28 @@
|
|
1
1
|
class Quaderno::Collection < Array
|
2
2
|
include Quaderno::Helpers::RateLimit
|
3
3
|
|
4
|
-
def
|
5
|
-
@
|
4
|
+
def request_options=(options)
|
5
|
+
@request_options = options
|
6
6
|
end
|
7
7
|
|
8
|
-
def
|
9
|
-
@
|
8
|
+
def collection_type=(collection_type)
|
9
|
+
@collection_type = collection_type
|
10
10
|
end
|
11
11
|
|
12
|
-
def
|
13
|
-
@
|
12
|
+
def has_more=(has_more_response)
|
13
|
+
@has_more = has_more_response
|
14
14
|
end
|
15
15
|
|
16
|
-
def
|
17
|
-
@
|
16
|
+
def next_page_url=(next_page_url)
|
17
|
+
@next_page_url = next_page_url
|
18
18
|
end
|
19
19
|
|
20
|
-
def
|
21
|
-
|
20
|
+
def has_more?
|
21
|
+
@has_more == 'true'
|
22
22
|
end
|
23
|
-
|
23
|
+
|
24
|
+
def next_page
|
25
|
+
return Quaderno::Collection.new unless has_more?
|
26
|
+
@collection_type.all_from_url(@next_page_url, @request_options)
|
27
|
+
end
|
28
|
+
end
|
data/lib/quaderno-ruby/report.rb
CHANGED
@@ -13,7 +13,7 @@ class Quaderno::Report < Quaderno::Base
|
|
13
13
|
response = get("#{authentication[:url]}#{api_model.api_path}/journal.json",
|
14
14
|
query: filter,
|
15
15
|
basic_auth: authentication[:basic_auth],
|
16
|
-
headers:
|
16
|
+
headers: default_headers.merge(authentication[:headers])
|
17
17
|
)
|
18
18
|
|
19
19
|
check_exception_for(response, { rate_limit: true, subdomain_or_token: true })
|
@@ -28,7 +28,7 @@ class Quaderno::Report < Quaderno::Base
|
|
28
28
|
response = get("#{authentication[:url]}#{api_model.api_path}/taxes.json",
|
29
29
|
query: filter,
|
30
30
|
basic_auth: authentication[:basic_auth],
|
31
|
-
headers:
|
31
|
+
headers: default_headers.merge(authentication[:headers])
|
32
32
|
)
|
33
33
|
|
34
34
|
check_exception_for(response, { rate_limit: true, subdomain_or_token: true })
|
@@ -65,7 +65,7 @@ class Quaderno::Report < Quaderno::Base
|
|
65
65
|
response = get("#{authentication[:url]}#{api_model.api_path}/#{tax_report_type}.json",
|
66
66
|
query: filter,
|
67
67
|
basic_auth: authentication[:basic_auth],
|
68
|
-
headers:
|
68
|
+
headers: default_headers.merge(authentication[:headers])
|
69
69
|
)
|
70
70
|
|
71
71
|
check_exception_for(response, { rate_limit: true, subdomain_or_token: true })
|
@@ -75,4 +75,4 @@ class Quaderno::Report < Quaderno::Base
|
|
75
75
|
|
76
76
|
collection
|
77
77
|
end
|
78
|
-
end
|
78
|
+
end
|
data/lib/quaderno-ruby/tax.rb
CHANGED
@@ -13,10 +13,10 @@ class Quaderno::Tax < Quaderno::Base
|
|
13
13
|
authentication = get_authentication(options.merge(api_model: api_model))
|
14
14
|
params = options.dup.delete_if { |k,v| %w(auth_token access_token api_url mode api_model).include? k.to_s }
|
15
15
|
|
16
|
-
response = get("#{authentication[:url]}
|
16
|
+
response = get("#{authentication[:url]}tax_rates/calculate.json",
|
17
17
|
query: params,
|
18
18
|
basic_auth: authentication[:basic_auth],
|
19
|
-
headers:
|
19
|
+
headers: default_headers.merge(authentication[:headers])
|
20
20
|
)
|
21
21
|
|
22
22
|
check_exception_for(response, { rate_limit: true, subdomain_or_token: true, id: true })
|
@@ -29,10 +29,10 @@ class Quaderno::Tax < Quaderno::Base
|
|
29
29
|
def self.validate_vat_number(country, vat_number, options = {})
|
30
30
|
authentication = get_authentication(options.merge(api_model: api_model))
|
31
31
|
|
32
|
-
response = get("#{authentication[:url]}
|
32
|
+
response = get("#{authentication[:url]}tax_ids/validate.json",
|
33
33
|
query: { country: country, vat_number: vat_number },
|
34
34
|
basic_auth: authentication[:basic_auth],
|
35
|
-
headers:
|
35
|
+
headers: default_headers.merge(authentication[:headers])
|
36
36
|
)
|
37
37
|
|
38
38
|
check_exception_for(response, { rate_limit: true, subdomain_or_token: true, id: true })
|
@@ -50,7 +50,7 @@ class Quaderno::Tax < Quaderno::Base
|
|
50
50
|
response = get("#{authentication[:url]}taxes/reports.json",
|
51
51
|
query: params,
|
52
52
|
basic_auth: authentication[:basic_auth],
|
53
|
-
headers:
|
53
|
+
headers: default_headers.merge(authentication[:headers])
|
54
54
|
)
|
55
55
|
|
56
56
|
array = response.parsed_response
|
data/lib/quaderno-ruby.rb
CHANGED
data/quaderno.gemspec
CHANGED
@@ -27,7 +27,7 @@ Gem::Specification.new do |spec|
|
|
27
27
|
spec.add_development_dependency('activesupport', "~> 4.2.0")
|
28
28
|
spec.add_development_dependency('webmock', "~> 1.22.6")
|
29
29
|
spec.add_development_dependency('vcr', ">= 0")
|
30
|
-
spec.add_development_dependency("bundler", "~>
|
30
|
+
spec.add_development_dependency("bundler", "~> 2.2")
|
31
31
|
spec.add_development_dependency("rake", ">= 12.3.3")
|
32
32
|
spec.add_development_dependency("rspec", "~> 3.0")
|
33
33
|
end
|
metadata
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: quaderno
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Recrea
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
11
|
date: 2018-05-07 00:00:00.000000000 Z
|
@@ -86,14 +86,14 @@ dependencies:
|
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
89
|
+
version: '2.2'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: '
|
96
|
+
version: '2.2'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: rake
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -172,7 +172,7 @@ homepage: http://github.com/quaderno/quaderno-ruby
|
|
172
172
|
licenses:
|
173
173
|
- MIT
|
174
174
|
metadata: {}
|
175
|
-
post_install_message:
|
175
|
+
post_install_message:
|
176
176
|
rdoc_options: []
|
177
177
|
require_paths:
|
178
178
|
- lib
|
@@ -187,8 +187,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
187
187
|
- !ruby/object:Gem::Version
|
188
188
|
version: '0'
|
189
189
|
requirements: []
|
190
|
-
rubygems_version: 3.0.
|
191
|
-
signing_key:
|
190
|
+
rubygems_version: 3.0.3
|
191
|
+
signing_key:
|
192
192
|
specification_version: 4
|
193
193
|
summary: Ruby wrapper for the Quaderno API (https://quaderno.io/docs/api)
|
194
194
|
test_files: []
|