quaderno 2.1.3 → 3.0.0
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 +4 -4
- data/.github/workflows/test.yml +1 -1
- data/.gitignore +3 -0
- data/README.md +266 -27
- data/changelog.md +18 -0
- data/lib/quaderno-ruby/account.rb +37 -0
- data/lib/quaderno-ruby/address.rb +10 -0
- data/lib/quaderno-ruby/base.rb +2 -0
- data/lib/quaderno-ruby/behavior/crud.rb +5 -4
- data/lib/quaderno-ruby/behavior/retrieve.rb +3 -2
- data/lib/quaderno-ruby/exceptions/exceptions.rb +27 -10
- data/lib/quaderno-ruby/helpers/response.rb +13 -0
- data/lib/quaderno-ruby/tax.rb +4 -2
- data/lib/quaderno-ruby/tax_code.rb +10 -0
- data/lib/quaderno-ruby/tax_id.rb +24 -0
- data/lib/quaderno-ruby/tax_jurisdiction.rb +10 -0
- data/lib/quaderno-ruby/tax_rate.rb +23 -0
- data/lib/quaderno-ruby/transaction.rb +11 -0
- data/lib/quaderno-ruby/version.rb +3 -1
- data/lib/quaderno-ruby.rb +5 -2
- data/quaderno.gemspec +4 -4
- metadata +36 -28
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 110d06dbefd7137c90b3446ba4fbd0e6cb967e215244de1c7a1f54d9beecf46c
|
|
4
|
+
data.tar.gz: 5f484fa04535448a06fd960e0656ab29b1abefea9db2dfa7e672f83511891af4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 925cbcdacf1bfa00b11c3b3f3e9f5791da6295f550d1feac7dd37d00dc2d5963752840c66cfb9e88d9e56d6e6d1fe4175ba4a1c084b83ba295971862056e0d64
|
|
7
|
+
data.tar.gz: 5439f1cb10b38539450c5351a256117fa39d906245a985533fc56a49d78ce456634aa1963f97fcbef57ce0f28227082a717b154618d987e3f5cd857e4c434552
|
data/.github/workflows/test.yml
CHANGED
data/.gitignore
CHANGED
data/README.md
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
# quaderno-ruby
|
|
2
2
|
|
|
3
|
-
Quaderno-ruby is a ruby wrapper for [Quaderno API]
|
|
3
|
+
Quaderno-ruby is a ruby wrapper for the [Quaderno API](https://developers.quaderno.io/api).
|
|
4
4
|
|
|
5
|
-
Current version is
|
|
5
|
+
Current version is 3.0.0 → See the changelog [here](https://github.com/quaderno/quaderno-ruby/blob/master/changelog.md).
|
|
6
|
+
|
|
7
|
+
To learn more about our API and ecosystem, check [developers.quaderno.io](https://developers.quaderno.io).
|
|
6
8
|
|
|
7
9
|
## Installation & Configuration
|
|
8
10
|
|
|
@@ -23,7 +25,11 @@ To configure just add this to your initializers
|
|
|
23
25
|
end
|
|
24
26
|
```
|
|
25
27
|
|
|
26
|
-
|
|
28
|
+
## Quaderno Sandbox
|
|
29
|
+
|
|
30
|
+
Quaderno Sandbox is our public staging environment, a safe space to experiment with our set of APIs and products. As a complete separate environment, it has it's own URL https://sandbox-quadernoapp.com and credentials.
|
|
31
|
+
|
|
32
|
+
It's perfect for your first steps with our tools. Please check https://developers.quaderno.io/dev_tools/sandbox to learn about its test data and limitations.
|
|
27
33
|
|
|
28
34
|
## Get authorization data
|
|
29
35
|
|
|
@@ -34,12 +40,13 @@ You can get your account subdomain by grabbing it from your account url or by ca
|
|
|
34
40
|
response.identity # => {"id"=>737000, "name"=>"Walter White", "email"=>"cooking@br.bd", "href"=>"https://my_subdomain.quadernoapp.com/api/"}
|
|
35
41
|
```
|
|
36
42
|
|
|
37
|
-
`environment` is an optional argument. By passing `:sandbox`, you will retrieve your credentials for the sandbox environment and not for production.
|
|
43
|
+
Note that `environment` is an optional argument. By passing `:sandbox`, you will retrieve your credentials for the sandbox environment and not for production.
|
|
38
44
|
|
|
39
45
|
This will return a hash with the information about your api url, which includes the account subdomain.
|
|
40
46
|
|
|
41
47
|
## Ping the service
|
|
42
|
-
|
|
48
|
+
|
|
49
|
+
You can ping the service in order to check if it is up with:
|
|
43
50
|
|
|
44
51
|
```ruby
|
|
45
52
|
response = Quaderno::Base.ping #=> Quaderno::Base
|
|
@@ -57,7 +64,7 @@ This will return `status: true` if the service is up or `status: false` if it is
|
|
|
57
64
|
|
|
58
65
|
```
|
|
59
66
|
|
|
60
|
-
This will return a hash with information about the seconds until the rate limit reset and your remaining requests per minute ([check the API documentation for more information](https://
|
|
67
|
+
This will return a hash with information about the seconds until the rate limit reset and your remaining requests per minute ([check the API documentation for more information](https://developers.quaderno.io/api#tag/API-features/Rate-Limiting)).
|
|
61
68
|
|
|
62
69
|
You can also check the rate limit for each request by checking the `rate_limit_info` method on the response:
|
|
63
70
|
|
|
@@ -98,6 +105,7 @@ Quaderno-ruby parses all the json responses in human readable data, so you can a
|
|
|
98
105
|
## Managing contacts
|
|
99
106
|
|
|
100
107
|
### Getting contacts
|
|
108
|
+
|
|
101
109
|
```ruby
|
|
102
110
|
Quaderno::Contact.all #=> Array
|
|
103
111
|
```
|
|
@@ -109,6 +117,7 @@ Quaderno-ruby parses all the json responses in human readable data, so you can a
|
|
|
109
117
|
```
|
|
110
118
|
|
|
111
119
|
### Finding a contact
|
|
120
|
+
|
|
112
121
|
```ruby
|
|
113
122
|
Quaderno::Contact.find(id) #=> Quaderno::Contact
|
|
114
123
|
```
|
|
@@ -116,15 +125,15 @@ Quaderno-ruby parses all the json responses in human readable data, so you can a
|
|
|
116
125
|
will return the contact with the id passed as parameter.
|
|
117
126
|
|
|
118
127
|
### Retrieving a contact by its payment gateway customer ID
|
|
128
|
+
|
|
119
129
|
```ruby
|
|
120
130
|
Quaderno::Contact.retrieve(PAYMENT_GATEWAY_CUSTOMER_ID, PAYMENT_GATEWAY) #=> Quaderno::Contact
|
|
121
131
|
```
|
|
122
|
-
will return the contact with the customer id passed as parameter.
|
|
123
|
-
|
|
124
|
-
*_Note_: `Quaderno::Contact.retrieve_customer` has been deprecated in favor of `Quaderno::Contact.retrieve`
|
|
125
132
|
|
|
133
|
+
will return the contact with the customer id passed as parameter.
|
|
126
134
|
|
|
127
135
|
### Creating a new contact
|
|
136
|
+
|
|
128
137
|
```ruby
|
|
129
138
|
Quaderno::Contact.create(params) #=> Quaderno::Contact
|
|
130
139
|
```
|
|
@@ -132,6 +141,7 @@ will return the contact with the customer id passed as parameter.
|
|
|
132
141
|
will create a contact using the information of the hash passed as parameter and return an instance of Quaderno::Contact with the created contact.
|
|
133
142
|
|
|
134
143
|
### Updating an existing contact
|
|
144
|
+
|
|
135
145
|
```ruby
|
|
136
146
|
Quaderno::Contact.update(id, params) #=> Quaderno::Contact
|
|
137
147
|
```
|
|
@@ -139,6 +149,7 @@ will create a contact using the information of the hash passed as parameter and
|
|
|
139
149
|
will update the specified contact with the data of the hash passed as second parameter.
|
|
140
150
|
|
|
141
151
|
### Deleting a contact
|
|
152
|
+
|
|
142
153
|
```ruby
|
|
143
154
|
Quaderno::Contact.delete(id) #=> Quaderno::Contact
|
|
144
155
|
```
|
|
@@ -148,6 +159,7 @@ will delete the contact with the id passed as parameter. If the deletion was suc
|
|
|
148
159
|
## Managing items
|
|
149
160
|
|
|
150
161
|
### Getting items
|
|
162
|
+
|
|
151
163
|
```ruby
|
|
152
164
|
Quaderno::Item.all #=> Array
|
|
153
165
|
```
|
|
@@ -155,6 +167,7 @@ will delete the contact with the id passed as parameter. If the deletion was suc
|
|
|
155
167
|
will return an array with all your items.
|
|
156
168
|
|
|
157
169
|
### Finding an item
|
|
170
|
+
|
|
158
171
|
```ruby
|
|
159
172
|
Quaderno::Item.find(id) #=> Quaderno::Item
|
|
160
173
|
```
|
|
@@ -162,6 +175,7 @@ will return an array with all your items.
|
|
|
162
175
|
will return the items with the id passed as parameter.
|
|
163
176
|
|
|
164
177
|
### Creating a new item
|
|
178
|
+
|
|
165
179
|
```ruby
|
|
166
180
|
Quaderno::Item.create(params) #=> Quaderno::Item
|
|
167
181
|
```
|
|
@@ -169,6 +183,7 @@ will return the items with the id passed as parameter.
|
|
|
169
183
|
will create an item using the information of the hash passed as parameter and return an instance of Quaderno::Item with the created contact.
|
|
170
184
|
|
|
171
185
|
### Updating an existing item
|
|
186
|
+
|
|
172
187
|
```ruby
|
|
173
188
|
Quaderno::Item.update(id, params) #=> Quaderno::Item
|
|
174
189
|
```
|
|
@@ -176,16 +191,27 @@ will create an item using the information of the hash passed as parameter and re
|
|
|
176
191
|
will update the specified item with the data of the hash passed as second parameter.
|
|
177
192
|
|
|
178
193
|
### Deleting an item
|
|
194
|
+
|
|
179
195
|
```ruby
|
|
180
196
|
Quaderno::Item.delete(id) #=> Quaderno::Item
|
|
181
197
|
```
|
|
182
198
|
|
|
183
199
|
will delete the item with the id passed as parameter. If the deletion was successful, an instance of `Quaderno::Item` with the `deleted` attribute set to `true` will be returned.
|
|
184
200
|
|
|
201
|
+
## Managing transactions
|
|
202
|
+
|
|
203
|
+
### Creating a new transaction
|
|
204
|
+
|
|
205
|
+
```ruby
|
|
206
|
+
Quaderno::Transaction.create(params) #=> Quaderno::Transaction
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
will create a sale or refund transaction using the information of the hash passed as parameter.
|
|
185
210
|
|
|
186
211
|
## Managing invoices
|
|
187
212
|
|
|
188
213
|
### Getting invoices
|
|
214
|
+
|
|
189
215
|
```ruby
|
|
190
216
|
Quaderno::Invoice.all #=> Array
|
|
191
217
|
```
|
|
@@ -193,6 +219,7 @@ will delete the item with the id passed as parameter. If the deletion was succe
|
|
|
193
219
|
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
|
|
194
220
|
|
|
195
221
|
### Finding an invoice
|
|
222
|
+
|
|
196
223
|
```ruby
|
|
197
224
|
Quaderno::Invoice.find(id) #=> Quaderno::Invoice
|
|
198
225
|
```
|
|
@@ -200,11 +227,12 @@ will delete the item with the id passed as parameter. If the deletion was succe
|
|
|
200
227
|
will return the invoice with the id passed as parameter.
|
|
201
228
|
|
|
202
229
|
### Retrieving an invoice by its payment gateway transaction ID
|
|
230
|
+
|
|
203
231
|
```ruby
|
|
204
232
|
Quaderno::Invoice.retrieve(PAYMENT_GATEWAY_TRANSACTION_ID, PAYMENT_GATEWAY) #=> Quaderno::Invoice
|
|
205
233
|
```
|
|
206
|
-
will return the invoice with the transaction id passed as parameter.
|
|
207
234
|
|
|
235
|
+
will return the invoice with the transaction id passed as parameter.
|
|
208
236
|
|
|
209
237
|
### Creating a new invoice
|
|
210
238
|
|
|
@@ -215,6 +243,7 @@ will return the invoice with the transaction id passed as parameter.
|
|
|
215
243
|
will create an invoice using the information of the hash passed as parameter.
|
|
216
244
|
|
|
217
245
|
### Updating an existing invoice
|
|
246
|
+
|
|
218
247
|
```ruby
|
|
219
248
|
Quaderno::Invoice.update(id, params) #=> Quaderno::Invoice
|
|
220
249
|
```
|
|
@@ -229,9 +258,9 @@ will update the specified invoice with the data of the hash passed as second par
|
|
|
229
258
|
|
|
230
259
|
will delete the invoice with the id passed as parameter. If the deletion was successful, an instance of `Quaderno::Item` with the `deleted` attribute set to `true` will be returned.
|
|
231
260
|
|
|
261
|
+
### Adding or removing a payment
|
|
232
262
|
|
|
233
|
-
|
|
234
|
-
In order to add a payment you will need the Invoice instance you want to update.
|
|
263
|
+
In order to add a payment you will need the Invoice instance you want to update.
|
|
235
264
|
|
|
236
265
|
```ruby
|
|
237
266
|
invoice = Quaderno::Invoice.find(invoice_id)
|
|
@@ -261,6 +290,7 @@ In order to remove a payment you will need the Invoice instance you want to upd
|
|
|
261
290
|
## Managing credits
|
|
262
291
|
|
|
263
292
|
### Getting credits
|
|
293
|
+
|
|
264
294
|
```ruby
|
|
265
295
|
Quaderno::Credit.all #=> Array
|
|
266
296
|
```
|
|
@@ -268,6 +298,7 @@ In order to remove a payment you will need the Invoice instance you want to upd
|
|
|
268
298
|
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
|
|
269
299
|
|
|
270
300
|
### Finding a credit
|
|
301
|
+
|
|
271
302
|
```ruby
|
|
272
303
|
Quaderno::Credit.find(id) #=> Quaderno::Credit
|
|
273
304
|
```
|
|
@@ -275,9 +306,11 @@ In order to remove a payment you will need the Invoice instance you want to upd
|
|
|
275
306
|
will return the credit with the id passed as parameter.
|
|
276
307
|
|
|
277
308
|
### Retrieving a credit by its payment gateway transaction ID
|
|
309
|
+
|
|
278
310
|
```ruby
|
|
279
311
|
Quaderno::Credit.retrieve(PAYMENT_GATEWAY_TRANSACTION_ID, PAYMENT_GATEWAY) #=> Quaderno::Credit
|
|
280
312
|
```
|
|
313
|
+
|
|
281
314
|
will return the credit note with the transaction id passed as parameter.
|
|
282
315
|
|
|
283
316
|
### Creating a new credit
|
|
@@ -289,6 +322,7 @@ will return the credit note with the transaction id passed as parameter.
|
|
|
289
322
|
will create a credit from the invoice specified in the parameter.
|
|
290
323
|
|
|
291
324
|
### Updating an existing credit
|
|
325
|
+
|
|
292
326
|
```ruby
|
|
293
327
|
Quaderno::Credit.update(id, params) #=> Quaderno::Credit
|
|
294
328
|
```
|
|
@@ -303,8 +337,8 @@ will update the specified credit with the data of the hash passed as second para
|
|
|
303
337
|
|
|
304
338
|
will delete the credit with the id passed as parameter. If the deletion was successful, an instance of `Quaderno::Credit` with the `deleted` attribute set to `true` will be returned.
|
|
305
339
|
|
|
306
|
-
|
|
307
340
|
### Adding or removing a payment
|
|
341
|
+
|
|
308
342
|
In order to add a payment you will need the Credit instance you want to update.
|
|
309
343
|
|
|
310
344
|
```ruby
|
|
@@ -334,11 +368,10 @@ If the deletion was successful, an instance of `Quaderno::Payment` with the `del
|
|
|
334
368
|
result.success #=> Boolean
|
|
335
369
|
```
|
|
336
370
|
|
|
337
|
-
|
|
338
371
|
## Managing estimates
|
|
339
372
|
|
|
340
|
-
|
|
341
373
|
### Getting estimates
|
|
374
|
+
|
|
342
375
|
```ruby
|
|
343
376
|
Quaderno::Estimate.all #=> Array
|
|
344
377
|
```
|
|
@@ -346,6 +379,7 @@ If the deletion was successful, an instance of `Quaderno::Payment` with the `del
|
|
|
346
379
|
will return an array with all your estimates.
|
|
347
380
|
|
|
348
381
|
### Finding an estimate
|
|
382
|
+
|
|
349
383
|
```ruby
|
|
350
384
|
Quaderno::Estimate.find(id) #=> Quaderno::Estimate
|
|
351
385
|
```
|
|
@@ -361,6 +395,7 @@ will return the estimate with the id passed as parameter.
|
|
|
361
395
|
will create an estimate using the information of the hash passed as parameter.
|
|
362
396
|
|
|
363
397
|
### Updating an existing estimate
|
|
398
|
+
|
|
364
399
|
```ruby
|
|
365
400
|
Quaderno::Estimate.update(id, params)
|
|
366
401
|
```
|
|
@@ -375,9 +410,9 @@ will update the specified estimate with the data of the hash passed as second pa
|
|
|
375
410
|
|
|
376
411
|
will delete the estimate with the id passed as parameter. If the deletion was successful, an instance of `Quaderno::Contact` with the `deleted` attribute set to `true` will be returned.
|
|
377
412
|
|
|
413
|
+
### Adding or removing a payment
|
|
378
414
|
|
|
379
|
-
|
|
380
|
-
In order to add a payment you will need the estimate you want to update.
|
|
415
|
+
In order to add a payment you will need the estimate you want to update.
|
|
381
416
|
|
|
382
417
|
```ruby
|
|
383
418
|
estimate = Quaderno::Estimate.find(estimate_id)
|
|
@@ -394,7 +429,8 @@ In order to remove a payment you will need the estimate you want to update.
|
|
|
394
429
|
```
|
|
395
430
|
|
|
396
431
|
### Delivering the estimate
|
|
397
|
-
|
|
432
|
+
|
|
433
|
+
In order to deliver the estimate to the default recipient you will need the estimate you want to send.
|
|
398
434
|
|
|
399
435
|
```ruby
|
|
400
436
|
estimate = Quaderno::Estimate.find(estimate_id)
|
|
@@ -403,10 +439,10 @@ In order to remove a payment you will need the estimate you want to update.
|
|
|
403
439
|
result.success #=> Boolean
|
|
404
440
|
```
|
|
405
441
|
|
|
406
|
-
|
|
407
442
|
## Managing expenses
|
|
408
443
|
|
|
409
444
|
### Getting expenses
|
|
445
|
+
|
|
410
446
|
```ruby
|
|
411
447
|
Quaderno::Expense.all #=> Array
|
|
412
448
|
```
|
|
@@ -414,6 +450,7 @@ In order to remove a payment you will need the estimate you want to update.
|
|
|
414
450
|
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.
|
|
415
451
|
|
|
416
452
|
### Finding an expense
|
|
453
|
+
|
|
417
454
|
```ruby
|
|
418
455
|
Quaderno::Expense.find(id) #=> Quaderno::Expense
|
|
419
456
|
```
|
|
@@ -421,6 +458,7 @@ In order to remove a payment you will need the estimate you want to update.
|
|
|
421
458
|
will return the expense with the id passed as parameter.
|
|
422
459
|
|
|
423
460
|
### Creating a new expense
|
|
461
|
+
|
|
424
462
|
```ruby
|
|
425
463
|
Quaderno::Expense.create(params) #=> Quaderno::Expense
|
|
426
464
|
```
|
|
@@ -428,6 +466,7 @@ will return the expense with the id passed as parameter.
|
|
|
428
466
|
will create an expense using the information of the hash passed as parameter and return an instance of Quaderno::Expense with the created expense.
|
|
429
467
|
|
|
430
468
|
### Updating an existing expense
|
|
469
|
+
|
|
431
470
|
```ruby
|
|
432
471
|
Quaderno::Expense.update(id, params) #=> Quaderno::Expense
|
|
433
472
|
```
|
|
@@ -435,16 +474,17 @@ will create an expense using the information of the hash passed as parameter and
|
|
|
435
474
|
will update the specified expense with the data of the hash passed as second parameter.
|
|
436
475
|
|
|
437
476
|
### Deleting an expense
|
|
477
|
+
|
|
438
478
|
```ruby
|
|
439
479
|
Quaderno::Expense.delete(id) #=> Quaderno::Expense
|
|
440
480
|
```
|
|
441
481
|
|
|
442
482
|
will delete the expense with the id passed as parameter. If the deletion was successful, an instance of `Quaderno::Expense` with the `deleted` attribute set to `true` will be returned.
|
|
443
483
|
|
|
444
|
-
|
|
445
484
|
## Managing recurrings
|
|
446
485
|
|
|
447
486
|
### Getting recurrings
|
|
487
|
+
|
|
448
488
|
```ruby
|
|
449
489
|
Quaderno::Recurring.all #=> Array
|
|
450
490
|
```
|
|
@@ -452,6 +492,7 @@ will delete the expense with the id passed as parameter. If the deletion was suc
|
|
|
452
492
|
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
|
|
453
493
|
|
|
454
494
|
### Finding a recurring
|
|
495
|
+
|
|
455
496
|
```ruby
|
|
456
497
|
Quaderno::Recurring.find(id) #=> Quaderno::Recurring
|
|
457
498
|
```
|
|
@@ -467,6 +508,7 @@ will return the recurring with the id passed as parameter.
|
|
|
467
508
|
will create a recurring using the information of the hash passed as parameter.
|
|
468
509
|
|
|
469
510
|
### Updating an existing recurring
|
|
511
|
+
|
|
470
512
|
```ruby
|
|
471
513
|
Quaderno::Recurring.update(id, params) #=> Quaderno::Recurring
|
|
472
514
|
```
|
|
@@ -481,10 +523,10 @@ will update the specified recurring with the data of the hash passed as second p
|
|
|
481
523
|
|
|
482
524
|
will delete the recurring with the id passed as parameter. If the deletion was successful, an instance of `Quaderno::Recurring` with the `deleted` attribute set to `true` will be returned.
|
|
483
525
|
|
|
484
|
-
|
|
485
526
|
## Managing webhooks
|
|
486
527
|
|
|
487
528
|
### Getting webhooks
|
|
529
|
+
|
|
488
530
|
```ruby
|
|
489
531
|
Quaderno::Webhook.all #=> Array
|
|
490
532
|
```
|
|
@@ -492,6 +534,7 @@ will delete the recurring with the id passed as parameter. If the deletion was s
|
|
|
492
534
|
will return an array with all the webhooks you have subscribed.
|
|
493
535
|
|
|
494
536
|
### Finding a webhook
|
|
537
|
+
|
|
495
538
|
```ruby
|
|
496
539
|
Quaderno::Webhook.find(id) #=> Quaderno::Webhook
|
|
497
540
|
```
|
|
@@ -499,6 +542,7 @@ will delete the recurring with the id passed as parameter. If the deletion was s
|
|
|
499
542
|
will return the webhook with the id passed as parameter.
|
|
500
543
|
|
|
501
544
|
### Creating a new webhook
|
|
545
|
+
|
|
502
546
|
```ruby
|
|
503
547
|
Quaderno::Webhook.create(params) #=> Quaderno::Webhook
|
|
504
548
|
```
|
|
@@ -506,6 +550,7 @@ will return the webhook with the id passed as parameter.
|
|
|
506
550
|
will create a webhook using the information of the hash passed as parameter and return an instance of Quaderno::Webhook with the created webhook.
|
|
507
551
|
|
|
508
552
|
### Updating an existing webhook
|
|
553
|
+
|
|
509
554
|
```ruby
|
|
510
555
|
Quaderno::Webhook.update(id, params) #=> Quaderno::Webhook
|
|
511
556
|
```
|
|
@@ -513,27 +558,108 @@ will create a webhook using the information of the hash passed as parameter and
|
|
|
513
558
|
will update the specified webhook with the data of the hash passed as second parameter.
|
|
514
559
|
|
|
515
560
|
### Deleting a webhook
|
|
561
|
+
|
|
516
562
|
```ruby
|
|
517
563
|
Quaderno::Webhook.delete(id) #=> Quaderno::Webhook
|
|
518
564
|
```
|
|
519
|
-
will delete the webhook with the id passed as parameter. If the deletion was successful, an instance of `Quaderno::Webhook` with the `deleted` attribute set to `true` will be returned.
|
|
520
565
|
|
|
566
|
+
will delete the webhook with the id passed as parameter. If the deletion was successful, an instance of `Quaderno::Webhook` with the `deleted` attribute set to `true` will be returned.
|
|
521
567
|
|
|
522
|
-
##
|
|
568
|
+
## Tax rates
|
|
523
569
|
|
|
524
570
|
### Calculating taxes
|
|
571
|
+
|
|
525
572
|
```ruby
|
|
526
|
-
Quaderno::
|
|
573
|
+
Quaderno::TaxRate.calculate(params) #=> Quaderno::TaxRate
|
|
527
574
|
```
|
|
528
575
|
|
|
529
576
|
will calculate the taxes applied for a customer based on the data pased as parameters.
|
|
530
577
|
|
|
531
|
-
|
|
578
|
+
## Tax jurisdictions
|
|
579
|
+
|
|
580
|
+
### Listing tax jurisdictions
|
|
581
|
+
|
|
582
|
+
```ruby
|
|
583
|
+
Quaderno::TaxJurisdiction.all #=> Array
|
|
584
|
+
```
|
|
585
|
+
|
|
586
|
+
will return an array with all the tax jurisdictions supported in Quaderno.
|
|
587
|
+
|
|
588
|
+
### Finding a tax jurisdiction
|
|
589
|
+
|
|
590
|
+
```ruby
|
|
591
|
+
Quaderno::TaxJurisdiction.find(id) #=> Quaderno::TaxJurisdiction
|
|
592
|
+
```
|
|
593
|
+
|
|
594
|
+
will return the tax jurisdiction with the id passed as parameter.
|
|
595
|
+
|
|
596
|
+
## Tax codes
|
|
597
|
+
|
|
598
|
+
### Listing tax codes
|
|
599
|
+
|
|
600
|
+
```ruby
|
|
601
|
+
Quaderno::TaxCode.all #=> Array
|
|
602
|
+
```
|
|
603
|
+
|
|
604
|
+
will return an array with all the tax codes supported in Quaderno.
|
|
605
|
+
|
|
606
|
+
### Finding a tax jurisdiction
|
|
607
|
+
|
|
608
|
+
```ruby
|
|
609
|
+
Quaderno::TaxCode.find(id) #=> Quaderno::TaxCode
|
|
610
|
+
```
|
|
611
|
+
|
|
612
|
+
will return the tax code with the id passed as parameter.
|
|
613
|
+
|
|
614
|
+
## Managing Tax ids
|
|
615
|
+
|
|
616
|
+
### Getting tax ids
|
|
617
|
+
|
|
618
|
+
```ruby
|
|
619
|
+
Quaderno::TaxId.all #=> Array
|
|
620
|
+
```
|
|
621
|
+
|
|
622
|
+
will return an array with all the tax ids in the target account.
|
|
623
|
+
|
|
624
|
+
### Finding a tax id
|
|
625
|
+
|
|
626
|
+
```ruby
|
|
627
|
+
Quaderno::TaxId.find(id) #=> Quaderno::TaxId
|
|
628
|
+
```
|
|
629
|
+
|
|
630
|
+
will return the tax id with the id passed as parameter.
|
|
631
|
+
|
|
632
|
+
### Adding a new tax id
|
|
633
|
+
|
|
634
|
+
```ruby
|
|
635
|
+
Quaderno::TaxId.create(params) #=> Quaderno::TaxId
|
|
636
|
+
```
|
|
637
|
+
|
|
638
|
+
will create a tax id using the information of the hash passed as parameter and return an instance of Quaderno::TaxId with the created tax id.
|
|
639
|
+
|
|
640
|
+
### Updating an existing tax id
|
|
641
|
+
|
|
642
|
+
```ruby
|
|
643
|
+
Quaderno::TaxId.update(id, params) #=> Quaderno::TaxId
|
|
644
|
+
```
|
|
645
|
+
|
|
646
|
+
will update the specified tax id with the data of the hash passed as second parameter.
|
|
647
|
+
|
|
648
|
+
### Deleting a tax id
|
|
649
|
+
|
|
650
|
+
```ruby
|
|
651
|
+
Quaderno::TaxId.delete(id) #=> Quaderno::TaxId
|
|
652
|
+
```
|
|
653
|
+
|
|
654
|
+
will delete the tax id with the id passed as parameter. If the deletion was successful, an instance of `Quaderno::TaxId` with the `deleted` attribute set to `true` will be returned.
|
|
655
|
+
|
|
656
|
+
### Validate a tax id
|
|
657
|
+
|
|
532
658
|
```ruby
|
|
533
659
|
country = 'IE'
|
|
534
660
|
tax_id = 'IE6388047V'
|
|
535
661
|
|
|
536
|
-
result = Quaderno::
|
|
662
|
+
result = Quaderno::TaxId.validate(country, tax_id) #=> Quaderno::TaxId
|
|
537
663
|
|
|
538
664
|
result.valid #=> Boolean or nil
|
|
539
665
|
```
|
|
@@ -543,6 +669,7 @@ will validate the tax ID or business number for the specified country.
|
|
|
543
669
|
## Evidences
|
|
544
670
|
|
|
545
671
|
### Creating location evidences
|
|
672
|
+
|
|
546
673
|
```ruby
|
|
547
674
|
Quaderno::Evidence.create(params) #=> Quaderno::Evidence
|
|
548
675
|
```
|
|
@@ -559,6 +686,7 @@ will create an evidence based on the data pased as parameters.
|
|
|
559
686
|
will return an array with all the checkout sessions in your account.
|
|
560
687
|
|
|
561
688
|
### Finding a checkout session
|
|
689
|
+
|
|
562
690
|
```ruby
|
|
563
691
|
Quaderno::CheckoutSession.find(id) #=> Quaderno::CheckoutSession
|
|
564
692
|
```
|
|
@@ -566,6 +694,7 @@ will create an evidence based on the data pased as parameters.
|
|
|
566
694
|
will return the checkout session with the id passed as parameter.
|
|
567
695
|
|
|
568
696
|
### Creating a new checkout session
|
|
697
|
+
|
|
569
698
|
```ruby
|
|
570
699
|
Quaderno::CheckoutSession.create(params) #=> Quaderno::CheckoutSession
|
|
571
700
|
```
|
|
@@ -573,6 +702,7 @@ will return the checkout session with the id passed as parameter.
|
|
|
573
702
|
will create a checkout session using the information of the hash passed as parameter and return an instance of Quaderno::CheckoutSession with the created checout session.
|
|
574
703
|
|
|
575
704
|
### Updating an existing checkout session
|
|
705
|
+
|
|
576
706
|
```ruby
|
|
577
707
|
Quaderno::CheckoutSession.update(id, params) #=> Quaderno::CheckoutSession
|
|
578
708
|
```
|
|
@@ -580,14 +710,17 @@ will create a checkout session using the information of the hash passed as param
|
|
|
580
710
|
will update the specified checkout session with the data of the hash passed as second parameter.
|
|
581
711
|
|
|
582
712
|
### Deleting a checkout session
|
|
713
|
+
|
|
583
714
|
```ruby
|
|
584
715
|
Quaderno::CheckoutSession.delete(id) #=> Quaderno::CheckoutSession
|
|
585
716
|
```
|
|
717
|
+
|
|
586
718
|
will delete the checkout session with the id passed as parameter. If the deletion was successful, an instance of `Quaderno::CheckoutSession` with the `deleted` attribute set to `true` will be returned.
|
|
587
719
|
|
|
588
720
|
## Managing report requests
|
|
589
721
|
|
|
590
722
|
### Getting report requests
|
|
723
|
+
|
|
591
724
|
```ruby
|
|
592
725
|
Quaderno::ReportRequest.all #=> Array
|
|
593
726
|
```
|
|
@@ -595,6 +728,7 @@ will delete the checkout session with the id passed as parameter. If the deletio
|
|
|
595
728
|
will return an array with all your report requests.
|
|
596
729
|
|
|
597
730
|
### Finding a report request
|
|
731
|
+
|
|
598
732
|
```ruby
|
|
599
733
|
Quaderno::ReportRequest.find(id) #=> Quaderno::ReportRequest
|
|
600
734
|
```
|
|
@@ -609,7 +743,93 @@ will return the report request with the id passed as parameter.
|
|
|
609
743
|
|
|
610
744
|
will create a report request using the information of the hash passed as parameter and return an instance of Quaderno::ReportRequest with the created report request.
|
|
611
745
|
|
|
746
|
+
## Connect: Managing custom accounts
|
|
747
|
+
|
|
748
|
+
### Getting custom accounts
|
|
749
|
+
|
|
750
|
+
```ruby
|
|
751
|
+
Quaderno::Account.all #=> Array
|
|
752
|
+
```
|
|
753
|
+
|
|
754
|
+
will return an array with all your custom accounts
|
|
755
|
+
|
|
756
|
+
### Finding a custom account
|
|
757
|
+
|
|
758
|
+
```ruby
|
|
759
|
+
Quaderno::Account.find(id) #=> Quaderno::Account
|
|
760
|
+
```
|
|
761
|
+
|
|
762
|
+
will return the account with the id passed as parameter.
|
|
763
|
+
|
|
764
|
+
### Creating a new custom account
|
|
765
|
+
|
|
766
|
+
```ruby
|
|
767
|
+
Quaderno::Account.create(params) #=> Quaderno::Account
|
|
768
|
+
```
|
|
769
|
+
|
|
770
|
+
will create a custom account using the information of the hash passed as parameter.
|
|
771
|
+
|
|
772
|
+
### Updating an existing custom account
|
|
773
|
+
|
|
774
|
+
```ruby
|
|
775
|
+
Quaderno::Account.update(id, params) #=> Quaderno::Account
|
|
776
|
+
```
|
|
777
|
+
|
|
778
|
+
will update the specified custom account with the data of the hash passed as second parameter.
|
|
779
|
+
|
|
780
|
+
### Deactivating a custom account
|
|
781
|
+
|
|
782
|
+
```ruby
|
|
783
|
+
Quaderno::Account.deactivate(id) #=> Quaderno::Account
|
|
784
|
+
```
|
|
785
|
+
|
|
786
|
+
will deactivate the custom account with the id passed as parameter.
|
|
787
|
+
|
|
788
|
+
### Activating a custom account
|
|
789
|
+
|
|
790
|
+
```ruby
|
|
791
|
+
Quaderno::Account.activate(id) #=> Quaderno::Account
|
|
792
|
+
```
|
|
793
|
+
|
|
794
|
+
will activate the custom account with the id passed as parameter.
|
|
795
|
+
|
|
796
|
+
## Connect: Managing addresses
|
|
797
|
+
|
|
798
|
+
### Getting addresses
|
|
799
|
+
|
|
800
|
+
```ruby
|
|
801
|
+
Quaderno::Address.all(access_token: ACCESS_TOKEN) #=> Array
|
|
802
|
+
```
|
|
803
|
+
|
|
804
|
+
will return an array with all the addresses of the target custom account
|
|
805
|
+
|
|
806
|
+
### Finding a address
|
|
807
|
+
|
|
808
|
+
```ruby
|
|
809
|
+
Quaderno::Address.find(id, access_token: ACCESS_TOKEN) #=> Quaderno::Address
|
|
810
|
+
```
|
|
811
|
+
|
|
812
|
+
will return the address with the id passed as parameter.
|
|
813
|
+
|
|
814
|
+
### Creating a new address
|
|
815
|
+
|
|
816
|
+
```ruby
|
|
817
|
+
Quaderno::Address.create(params.merge(access_token: ACCESS_TOKEN)) #=> Quaderno::Address
|
|
818
|
+
```
|
|
819
|
+
|
|
820
|
+
will add an address on the target custom account using the information of the hash passed as parameter.
|
|
821
|
+
|
|
822
|
+
### Updating an existing address
|
|
823
|
+
|
|
824
|
+
```ruby
|
|
825
|
+
Quaderno::Address.update(id, params.merge(access_token: ACCESS_TOKEN)) #=> Quaderno::Address
|
|
826
|
+
```
|
|
827
|
+
|
|
828
|
+
will update the specified address with the data of the hash passed as second parameter.
|
|
829
|
+
|
|
830
|
+
|
|
612
831
|
## Exceptions
|
|
832
|
+
|
|
613
833
|
Quaderno-ruby exceptions raise depending on the type of error:
|
|
614
834
|
|
|
615
835
|
```ruby
|
|
@@ -619,6 +839,8 @@ Quaderno-ruby exceptions raise depending on the type of error:
|
|
|
619
839
|
|
|
620
840
|
Quaderno::Exceptions::InvalidID # Raised when the requested resource by ID does not exist in the account context.
|
|
621
841
|
|
|
842
|
+
Quaderno::Exceptions::InvalidRequest # Raised when the requested requirements are not fulfilled.
|
|
843
|
+
|
|
622
844
|
Quaderno::Exceptions::ThrottleLimitExceeded # Raised when the throttle limit is exceeded.
|
|
623
845
|
|
|
624
846
|
Quaderno::Exceptions::RateLimitExceeded # Raised when the rate limit is exceeded.
|
|
@@ -632,7 +854,19 @@ Quaderno-ruby exceptions raise depending on the type of error:
|
|
|
632
854
|
|
|
633
855
|
All those exceptions inherit from `Quaderno::Exceptions::BaseException`.
|
|
634
856
|
|
|
857
|
+
You can inspect a the error response from the API by rescuing the exception and checking `response_body`:
|
|
858
|
+
|
|
859
|
+
```ruby
|
|
860
|
+
begin
|
|
861
|
+
Quaderno::Invoice.find WRONG_ID
|
|
862
|
+
rescue Quaderno::Exceptions::BaseException => e
|
|
863
|
+
e.response_body # => {"error"=>"Unauthorized access or document does not exist."}
|
|
864
|
+
end
|
|
865
|
+
```
|
|
866
|
+
|
|
867
|
+
|
|
635
868
|
### Pagination information
|
|
869
|
+
|
|
636
870
|
Whenever you call the `all` method on one of the classes, the result will be a `Quaderno::Collection`. For example:
|
|
637
871
|
|
|
638
872
|
```ruby
|
|
@@ -701,9 +935,14 @@ Quaderno::Invoice.delete(INVOICE_ID,
|
|
|
701
935
|
|
|
702
936
|
## More information
|
|
703
937
|
|
|
704
|
-
Remember this is only a ruby wrapper for the
|
|
938
|
+
Remember this is only a ruby wrapper for the Quaderno API. Checkout our [OpenAPI documentation](https://developers.quaderno.io/api)!
|
|
939
|
+
|
|
940
|
+
If you need examples of `params` objects, head to our tests. For instance, in case you're an online store and want to register your sales and refunds, [here](https://github.com/quaderno/quaderno-ruby/blob/master/spec/unit/test_quaderno_transaction.rb) you can get examples of parameters to use with this Ruby gem.
|
|
941
|
+
|
|
942
|
+
---
|
|
705
943
|
|
|
706
944
|
## License
|
|
945
|
+
|
|
707
946
|
(The MIT License)
|
|
708
947
|
|
|
709
948
|
Copyright © 2013-2023 Quaderno
|
data/changelog.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 3.0.0
|
|
4
|
+
* Added support for accounts API
|
|
5
|
+
* Added support for addresses API
|
|
6
|
+
* Added support for tax rates API
|
|
7
|
+
* Added support for tax jurisdictions API
|
|
8
|
+
* Added support for tax codes API
|
|
9
|
+
* Clean parameters sent in the create request
|
|
10
|
+
* Phase out legacy `Quaderno::Tax` class in favour of `Quaderno::TaxRate` (the class will be removed in the next release)
|
|
11
|
+
* Relaxed httparty requirements
|
|
12
|
+
* Detect and handle `bad_request` response codes
|
|
13
|
+
* Added `Quaderno::Exceptions::InvalidRequest` to handle `not_acceptable` response codes
|
|
14
|
+
* Added `Quaderno::Exceptions::BaseException#response_body` to check the API response error
|
|
15
|
+
* Removed legacy `Quaderno::Contact.retrieve_customer` in favor of `Quaderno::Contact.retrieve`
|
|
16
|
+
|
|
17
|
+
## 2.2.0
|
|
18
|
+
* Added support for transactions API
|
|
19
|
+
* Bumped webmock to 3.18
|
|
20
|
+
|
|
3
21
|
## 2.1.3
|
|
4
22
|
* Bumped dependency httparty to 0.21.0 by [**adamgiounas**](https://github.com/adamgiounas): https://github.com/quaderno/quaderno-ruby/pull/28
|
|
5
23
|
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class Quaderno::Account < Quaderno::Base
|
|
4
|
+
class << self
|
|
5
|
+
undef :delete
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
api_model Quaderno::Account
|
|
9
|
+
api_path 'accounts'
|
|
10
|
+
|
|
11
|
+
def self.activate(id, options = {})
|
|
12
|
+
setup_account('activate', id, options)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def self.deactivate(id, options = {})
|
|
16
|
+
setup_account('deactivate', id, options)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
private_class_method def self.setup_account(mode, id, options)
|
|
20
|
+
authentication = get_authentication(options.merge(api_model: api_model))
|
|
21
|
+
|
|
22
|
+
response = put("#{authentication[:url]}#{api_model.api_path}/#{id}/#{mode}.json", {
|
|
23
|
+
basic_auth: authentication[:basic_auth],
|
|
24
|
+
headers: default_headers.merge(authentication[:headers]).merge('Content-Type' => 'application/json')
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
check_exception_for(response, { rate_limit: true, required_fields: true, subdomain_or_token: true, id: true })
|
|
28
|
+
|
|
29
|
+
hash = response.parsed_response
|
|
30
|
+
hash[:authentication_data] = authentication
|
|
31
|
+
|
|
32
|
+
object = new hash
|
|
33
|
+
object.rate_limit_info = response
|
|
34
|
+
|
|
35
|
+
object
|
|
36
|
+
end
|
|
37
|
+
end
|
data/lib/quaderno-ruby/base.rb
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module Quaderno::Behavior
|
|
2
4
|
module Crud
|
|
3
|
-
|
|
4
5
|
def self.included(receiver)
|
|
5
6
|
receiver.send :extend, ClassMethods
|
|
6
7
|
end
|
|
@@ -69,7 +70,7 @@ module Quaderno::Behavior
|
|
|
69
70
|
|
|
70
71
|
def create(params = {})
|
|
71
72
|
authentication = get_authentication(params.merge(api_model: api_model))
|
|
72
|
-
params.dup.delete_if { |k,
|
|
73
|
+
params = params.dup.delete_if { |k, _| %w[auth_token access_token api_url mode api_model].include? k.to_s }
|
|
73
74
|
|
|
74
75
|
response = post("#{authentication[:url]}#{api_model.api_path}.json",
|
|
75
76
|
body: params.to_json,
|
|
@@ -91,7 +92,7 @@ module Quaderno::Behavior
|
|
|
91
92
|
|
|
92
93
|
def update(id, params = {})
|
|
93
94
|
authentication = get_authentication(params.merge(api_model: api_model))
|
|
94
|
-
params = params.dup.delete_if { |k,
|
|
95
|
+
params = params.dup.delete_if { |k, _| %w[auth_token access_token api_url mode api_model].include? k.to_s }
|
|
95
96
|
|
|
96
97
|
response = put("#{authentication[:url]}#{api_model.api_path}/#{id}.json",
|
|
97
98
|
body: params.to_json,
|
|
@@ -114,7 +115,7 @@ module Quaderno::Behavior
|
|
|
114
115
|
def delete(id, options = {})
|
|
115
116
|
authentication = get_authentication(options.merge(api_model: api_model))
|
|
116
117
|
|
|
117
|
-
response = HTTParty.delete("#{authentication[:url]}#{
|
|
118
|
+
response = HTTParty.delete("#{authentication[:url]}#{api_model.api_path}/#{id}.json",
|
|
118
119
|
basic_auth: authentication[:basic_auth],
|
|
119
120
|
headers: default_headers.merge(authentication[:headers])
|
|
120
121
|
)
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module Quaderno::Behavior
|
|
2
4
|
module Retrieve
|
|
3
|
-
|
|
4
5
|
def self.included(receiver)
|
|
5
6
|
receiver.send :extend, ClassMethods
|
|
6
7
|
end
|
|
@@ -25,9 +26,9 @@ module Quaderno::Behavior
|
|
|
25
26
|
|
|
26
27
|
object
|
|
27
28
|
end
|
|
28
|
-
alias_method :retrieve_customer, :retrieve
|
|
29
29
|
|
|
30
30
|
private
|
|
31
|
+
|
|
31
32
|
def retrieve_path(path)
|
|
32
33
|
@_retrieve_path = path
|
|
33
34
|
end
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module Quaderno::Exceptions
|
|
2
4
|
class BaseException < StandardError
|
|
3
5
|
include Quaderno::Helpers::RateLimit
|
|
6
|
+
include Quaderno::Helpers::Response
|
|
4
7
|
end
|
|
5
8
|
|
|
6
9
|
class InvalidSubdomainOrToken < BaseException
|
|
@@ -9,6 +12,9 @@ module Quaderno::Exceptions
|
|
|
9
12
|
class InvalidID < BaseException
|
|
10
13
|
end
|
|
11
14
|
|
|
15
|
+
class InvalidRequest < BaseException
|
|
16
|
+
end
|
|
17
|
+
|
|
12
18
|
class RateLimitExceeded < BaseException
|
|
13
19
|
end
|
|
14
20
|
|
|
@@ -35,31 +41,42 @@ module Quaderno::Exceptions
|
|
|
35
41
|
def check_exception_for(party_response, params = {})
|
|
36
42
|
raise_exception(Quaderno::Exceptions::UnsupportedApiVersion, 'Unsupported API version', party_response) if !!(party_response.body =~ /Unsupported API version/)
|
|
37
43
|
|
|
38
|
-
if params[:throttle_limit].nil? == false && party_response.response.
|
|
44
|
+
if params[:throttle_limit].nil? == false && party_response.response.instance_of?(Net::HTTPServiceUnavailable)
|
|
39
45
|
raise_exception(Quaderno::Exceptions::ThrottleLimitExceeded, 'Throttle limit exceeded, please try again later', party_response)
|
|
40
46
|
end
|
|
41
|
-
|
|
47
|
+
|
|
48
|
+
if params[:rate_limit].nil? == false && party_response.response.instance_of?(Net::HTTPForbidden)
|
|
42
49
|
raise_exception(Quaderno::Exceptions::RateLimitExceeded, 'Rate limit exceeded', party_response)
|
|
43
50
|
end
|
|
44
|
-
|
|
45
|
-
|
|
51
|
+
|
|
52
|
+
if params[:subdomain_or_token].nil? == false && party_response.response.instance_of?(Net::HTTPUnauthorized)
|
|
53
|
+
raise_exception(Quaderno::Exceptions::InvalidSubdomainOrToken, 'Invalid subdomain or token', party_response)
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
if params[:id].nil? == false && (party_response.response.instance_of?(Net::HTTPInternalServerError) || party_response.response.instance_of?(Net::HTTPNotFound))
|
|
57
|
+
raise_exception(Quaderno::Exceptions::InvalidID, "Invalid #{api_model} instance identifier", party_response)
|
|
46
58
|
end
|
|
47
|
-
|
|
48
|
-
|
|
59
|
+
|
|
60
|
+
if params[:required_fields].nil? == false && party_response.response.instance_of?(Net::HTTPUnprocessableEntity)
|
|
61
|
+
raise_exception(Quaderno::Exceptions::RequiredFieldsEmptyOrInvalid, party_response.body, party_response)
|
|
49
62
|
end
|
|
50
|
-
|
|
51
|
-
|
|
63
|
+
|
|
64
|
+
if party_response.response.instance_of?(Net::HTTPBadRequest)
|
|
65
|
+
raise_exception(Quaderno::Exceptions::RequiredFieldsEmptyOrInvalid, party_response.body, party_response)
|
|
52
66
|
end
|
|
53
|
-
|
|
54
|
-
|
|
67
|
+
|
|
68
|
+
if params[:has_documents].nil? == false && party_response.response.instance_of?(Net::HTTPClientError)
|
|
69
|
+
raise_exception(Quaderno::Exceptions::HasAssociatedDocuments, party_response.body, party_response)
|
|
55
70
|
end
|
|
56
71
|
|
|
72
|
+
raise_exception(Quaderno::Exceptions::InvalidRequest, 'Invalid request', party_response) if party_response.response.instance_of?(Net::HTTPNotAcceptable)
|
|
57
73
|
raise_exception(Quaderno::Exceptions::ServerError, 'Server error', party_response) if party_response.response.is_a?(Net::HTTPServerError)
|
|
58
74
|
end
|
|
59
75
|
|
|
60
76
|
def raise_exception(klass, message, response)
|
|
61
77
|
exception = klass.new(message)
|
|
62
78
|
exception.rate_limit_info = response
|
|
79
|
+
exception.response_body = response.parsed_response
|
|
63
80
|
|
|
64
81
|
raise exception
|
|
65
82
|
end
|
data/lib/quaderno-ruby/tax.rb
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
class Quaderno::TaxReport < OpenStruct
|
|
2
4
|
end
|
|
3
5
|
|
|
@@ -11,7 +13,7 @@ class Quaderno::Tax < Quaderno::Base
|
|
|
11
13
|
|
|
12
14
|
def self.calculate(options = {})
|
|
13
15
|
authentication = get_authentication(options.merge(api_model: api_model))
|
|
14
|
-
params = options.dup.delete_if { |k,
|
|
16
|
+
params = options.dup.delete_if { |k, _| %w[auth_token access_token api_url mode api_model].include? k.to_s }
|
|
15
17
|
|
|
16
18
|
response = get("#{authentication[:url]}tax_rates/calculate.json",
|
|
17
19
|
query: params,
|
|
@@ -47,7 +49,7 @@ class Quaderno::Tax < Quaderno::Base
|
|
|
47
49
|
|
|
48
50
|
def self.reports(options = {})
|
|
49
51
|
authentication = get_authentication(options.merge(api_model: api_model))
|
|
50
|
-
params = options.dup.delete_if { |k,
|
|
52
|
+
params = options.dup.delete_if { |k, _| %w[auth_token access_token api_url mode api_model].include? k.to_s }
|
|
51
53
|
|
|
52
54
|
response = get("#{authentication[:url]}taxes/reports.json",
|
|
53
55
|
query: params,
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class Quaderno::TaxId < Quaderno::Base
|
|
4
|
+
api_model Quaderno::TaxId
|
|
5
|
+
api_path 'tax_ids'
|
|
6
|
+
is_a_document? false
|
|
7
|
+
|
|
8
|
+
def self.validate(country, tax_id, options = {})
|
|
9
|
+
authentication = get_authentication(options.merge(api_model: api_model))
|
|
10
|
+
|
|
11
|
+
response = get("#{authentication[:url]}#{api_path}/validate.json",
|
|
12
|
+
query: { country: country, tax_id: tax_id },
|
|
13
|
+
basic_auth: authentication[:basic_auth],
|
|
14
|
+
headers: default_headers.merge(authentication[:headers])
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
check_exception_for(response, { rate_limit: true, subdomain_or_token: true, id: true })
|
|
18
|
+
|
|
19
|
+
data = new({ valid: response.parsed_response['valid'] })
|
|
20
|
+
data.rate_limit_info = response
|
|
21
|
+
|
|
22
|
+
data
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class Quaderno::TaxRate < Quaderno::Base
|
|
4
|
+
api_model Quaderno::TaxRate
|
|
5
|
+
api_path 'tax_rates'
|
|
6
|
+
|
|
7
|
+
def self.calculate(options = {})
|
|
8
|
+
authentication = get_authentication(options.merge(api_model: api_model))
|
|
9
|
+
params = options.dup.delete_if { |k, _| %w[auth_token access_token api_url mode api_model].include? k.to_s }
|
|
10
|
+
|
|
11
|
+
response = get("#{authentication[:url]}#{api_path}/calculate.json",
|
|
12
|
+
query: params,
|
|
13
|
+
basic_auth: authentication[:basic_auth],
|
|
14
|
+
headers: default_headers.merge(authentication[:headers])
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
check_exception_for(response, { rate_limit: true, subdomain_or_token: true, id: true })
|
|
18
|
+
data = new response.parsed_response
|
|
19
|
+
data.rate_limit_info = response
|
|
20
|
+
|
|
21
|
+
data
|
|
22
|
+
end
|
|
23
|
+
end
|
data/lib/quaderno-ruby.rb
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
class Quaderno
|
|
2
4
|
end
|
|
3
5
|
|
|
@@ -5,9 +7,10 @@ require 'ostruct'
|
|
|
5
7
|
|
|
6
8
|
require 'quaderno-ruby/version'
|
|
7
9
|
require 'quaderno-ruby/helpers/rate_limit'
|
|
10
|
+
require 'quaderno-ruby/helpers/response'
|
|
8
11
|
require 'quaderno-ruby/exceptions/exceptions'
|
|
9
12
|
require 'quaderno-ruby/helpers/authentication'
|
|
10
13
|
require 'quaderno-ruby/collection'
|
|
11
14
|
|
|
12
|
-
%w
|
|
13
|
-
%w
|
|
15
|
+
%w[block crud deliver payment retrieve].each { |filename| require "quaderno-ruby/behavior/#{filename}" }
|
|
16
|
+
%w[base account address contact item transaction invoice receipt credit income estimate expense recurring document_item report report_request evidence payment webhook tax tax_id tax_rate tax_code tax_jurisdiction checkout_session].each { |filename| require "quaderno-ruby/#{filename}" }
|
data/quaderno.gemspec
CHANGED
|
@@ -21,12 +21,12 @@ Gem::Specification.new do |spec|
|
|
|
21
21
|
spec.date = '2018-05-07'
|
|
22
22
|
spec.extra_rdoc_files = %w(LICENSE.txt README.md)
|
|
23
23
|
|
|
24
|
-
spec.add_dependency('httparty', '~> 0.21
|
|
25
|
-
spec.add_development_dependency('rdoc', '>= 6.3.1')
|
|
24
|
+
spec.add_dependency('httparty', '~> 0.21')
|
|
26
25
|
spec.add_development_dependency('activesupport', '~> 4.2.0')
|
|
27
|
-
spec.add_development_dependency('webmock', '~> 1.22.6')
|
|
28
|
-
spec.add_development_dependency('vcr', '>= 0')
|
|
29
26
|
spec.add_development_dependency('bundler', '~> 2.2')
|
|
30
27
|
spec.add_development_dependency('rake', '>= 12.3.3')
|
|
28
|
+
spec.add_development_dependency('rdoc', '>= 6.3.1')
|
|
31
29
|
spec.add_development_dependency('rspec', '~> 3.0')
|
|
30
|
+
spec.add_development_dependency('vcr', '>= 0')
|
|
31
|
+
spec.add_development_dependency('webmock', '~> 3.18')
|
|
32
32
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: quaderno
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 3.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Recrea
|
|
@@ -16,112 +16,112 @@ dependencies:
|
|
|
16
16
|
requirements:
|
|
17
17
|
- - "~>"
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: 0.21
|
|
19
|
+
version: '0.21'
|
|
20
20
|
type: :runtime
|
|
21
21
|
prerelease: false
|
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
23
|
requirements:
|
|
24
24
|
- - "~>"
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
|
-
version: 0.21
|
|
26
|
+
version: '0.21'
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
|
-
name:
|
|
28
|
+
name: activesupport
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
30
30
|
requirements:
|
|
31
|
-
- - "
|
|
31
|
+
- - "~>"
|
|
32
32
|
- !ruby/object:Gem::Version
|
|
33
|
-
version:
|
|
33
|
+
version: 4.2.0
|
|
34
34
|
type: :development
|
|
35
35
|
prerelease: false
|
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
37
|
requirements:
|
|
38
|
-
- - "
|
|
38
|
+
- - "~>"
|
|
39
39
|
- !ruby/object:Gem::Version
|
|
40
|
-
version:
|
|
40
|
+
version: 4.2.0
|
|
41
41
|
- !ruby/object:Gem::Dependency
|
|
42
|
-
name:
|
|
42
|
+
name: bundler
|
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
|
44
44
|
requirements:
|
|
45
45
|
- - "~>"
|
|
46
46
|
- !ruby/object:Gem::Version
|
|
47
|
-
version:
|
|
47
|
+
version: '2.2'
|
|
48
48
|
type: :development
|
|
49
49
|
prerelease: false
|
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
|
51
51
|
requirements:
|
|
52
52
|
- - "~>"
|
|
53
53
|
- !ruby/object:Gem::Version
|
|
54
|
-
version:
|
|
54
|
+
version: '2.2'
|
|
55
55
|
- !ruby/object:Gem::Dependency
|
|
56
|
-
name:
|
|
56
|
+
name: rake
|
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
|
58
58
|
requirements:
|
|
59
|
-
- - "
|
|
59
|
+
- - ">="
|
|
60
60
|
- !ruby/object:Gem::Version
|
|
61
|
-
version:
|
|
61
|
+
version: 12.3.3
|
|
62
62
|
type: :development
|
|
63
63
|
prerelease: false
|
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
|
65
65
|
requirements:
|
|
66
|
-
- - "
|
|
66
|
+
- - ">="
|
|
67
67
|
- !ruby/object:Gem::Version
|
|
68
|
-
version:
|
|
68
|
+
version: 12.3.3
|
|
69
69
|
- !ruby/object:Gem::Dependency
|
|
70
|
-
name:
|
|
70
|
+
name: rdoc
|
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
|
72
72
|
requirements:
|
|
73
73
|
- - ">="
|
|
74
74
|
- !ruby/object:Gem::Version
|
|
75
|
-
version:
|
|
75
|
+
version: 6.3.1
|
|
76
76
|
type: :development
|
|
77
77
|
prerelease: false
|
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
|
79
79
|
requirements:
|
|
80
80
|
- - ">="
|
|
81
81
|
- !ruby/object:Gem::Version
|
|
82
|
-
version:
|
|
82
|
+
version: 6.3.1
|
|
83
83
|
- !ruby/object:Gem::Dependency
|
|
84
|
-
name:
|
|
84
|
+
name: rspec
|
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
|
86
86
|
requirements:
|
|
87
87
|
- - "~>"
|
|
88
88
|
- !ruby/object:Gem::Version
|
|
89
|
-
version: '
|
|
89
|
+
version: '3.0'
|
|
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: '3.0'
|
|
97
97
|
- !ruby/object:Gem::Dependency
|
|
98
|
-
name:
|
|
98
|
+
name: vcr
|
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
|
100
100
|
requirements:
|
|
101
101
|
- - ">="
|
|
102
102
|
- !ruby/object:Gem::Version
|
|
103
|
-
version:
|
|
103
|
+
version: '0'
|
|
104
104
|
type: :development
|
|
105
105
|
prerelease: false
|
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
|
107
107
|
requirements:
|
|
108
108
|
- - ">="
|
|
109
109
|
- !ruby/object:Gem::Version
|
|
110
|
-
version:
|
|
110
|
+
version: '0'
|
|
111
111
|
- !ruby/object:Gem::Dependency
|
|
112
|
-
name:
|
|
112
|
+
name: webmock
|
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
|
114
114
|
requirements:
|
|
115
115
|
- - "~>"
|
|
116
116
|
- !ruby/object:Gem::Version
|
|
117
|
-
version: '3.
|
|
117
|
+
version: '3.18'
|
|
118
118
|
type: :development
|
|
119
119
|
prerelease: false
|
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
|
121
121
|
requirements:
|
|
122
122
|
- - "~>"
|
|
123
123
|
- !ruby/object:Gem::Version
|
|
124
|
-
version: '3.
|
|
124
|
+
version: '3.18'
|
|
125
125
|
description: " A ruby wrapper for Quaderno API "
|
|
126
126
|
email: carlos@recrea.es
|
|
127
127
|
executables: []
|
|
@@ -140,6 +140,8 @@ files:
|
|
|
140
140
|
- Rakefile
|
|
141
141
|
- changelog.md
|
|
142
142
|
- lib/quaderno-ruby.rb
|
|
143
|
+
- lib/quaderno-ruby/account.rb
|
|
144
|
+
- lib/quaderno-ruby/address.rb
|
|
143
145
|
- lib/quaderno-ruby/base.rb
|
|
144
146
|
- lib/quaderno-ruby/behavior/block.rb
|
|
145
147
|
- lib/quaderno-ruby/behavior/crud.rb
|
|
@@ -157,6 +159,7 @@ files:
|
|
|
157
159
|
- lib/quaderno-ruby/expense.rb
|
|
158
160
|
- lib/quaderno-ruby/helpers/authentication.rb
|
|
159
161
|
- lib/quaderno-ruby/helpers/rate_limit.rb
|
|
162
|
+
- lib/quaderno-ruby/helpers/response.rb
|
|
160
163
|
- lib/quaderno-ruby/income.rb
|
|
161
164
|
- lib/quaderno-ruby/invoice.rb
|
|
162
165
|
- lib/quaderno-ruby/item.rb
|
|
@@ -166,6 +169,11 @@ files:
|
|
|
166
169
|
- lib/quaderno-ruby/report.rb
|
|
167
170
|
- lib/quaderno-ruby/report_request.rb
|
|
168
171
|
- lib/quaderno-ruby/tax.rb
|
|
172
|
+
- lib/quaderno-ruby/tax_code.rb
|
|
173
|
+
- lib/quaderno-ruby/tax_id.rb
|
|
174
|
+
- lib/quaderno-ruby/tax_jurisdiction.rb
|
|
175
|
+
- lib/quaderno-ruby/tax_rate.rb
|
|
176
|
+
- lib/quaderno-ruby/transaction.rb
|
|
169
177
|
- lib/quaderno-ruby/version.rb
|
|
170
178
|
- lib/quaderno-ruby/webhook.rb
|
|
171
179
|
- quaderno.gemspec
|