quaderno 1.15.2 → 2.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +142 -109
- data/changelog.md +77 -44
- data/lib/quaderno-ruby.rb +3 -1
- data/lib/quaderno-ruby/base.rb +31 -14
- data/lib/quaderno-ruby/behavior/block.rb +5 -2
- data/lib/quaderno-ruby/behavior/crud.rb +64 -30
- data/lib/quaderno-ruby/behavior/deliver.rb +6 -2
- data/lib/quaderno-ruby/behavior/payment.rb +12 -6
- data/lib/quaderno-ruby/behavior/retrieve.rb +5 -2
- data/lib/quaderno-ruby/checkout_session.rb +4 -0
- data/lib/quaderno-ruby/collection.rb +17 -11
- data/lib/quaderno-ruby/exceptions/exceptions.rb +17 -9
- data/lib/quaderno-ruby/helpers/rate_limit.rb +12 -0
- data/lib/quaderno-ruby/payment.rb +1 -0
- data/lib/quaderno-ruby/report.rb +7 -7
- data/lib/quaderno-ruby/tax.rb +20 -11
- data/lib/quaderno-ruby/version.rb +1 -1
- data/quaderno.gemspec +3 -3
- metadata +14 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 87cd629b645c9dccf37590027c38d2f32582e4ecb5f746882a9e4c5e8dce951b
|
4
|
+
data.tar.gz: 5b3f2271733c94ba33a0968c647c221a1ae35fe972b85eba28bfda2e847baf4e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 680f294a15ab5efc78d7457de2ad43ff26df3cfb719ff9d5ddfc19d23832488eb7e624092dff185414aa6867a8e142a3b03c21d35808c736d7c93fdc2418c3a5
|
7
|
+
data.tar.gz: af06b1277320b63e3df52dd9be2984d61ce17c1418c4e31b68ba91349ad76f7b59e0428e0e697daf9f7569811d892ab4ff7bf8756b25a08fe41635c4883dad0d
|
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
|
|
@@ -29,8 +29,8 @@ To configure just add this to your initializers
|
|
29
29
|
You can get your account subdomain by grabbing it from your account url or by calling the authorization method with your personal api token.
|
30
30
|
|
31
31
|
```ruby
|
32
|
-
Quaderno::Base.authorization 'my_authenticate_token', environment
|
33
|
-
# => {"
|
32
|
+
response = Quaderno::Base.authorization 'my_authenticate_token', environment #=> Quaderno::Base
|
33
|
+
response.identity # => {"id"=>737000, "name"=>"Walter White", "email"=>"cooking@br.bd", "href"=>"https://my_subdomain.quadernoapp.com/api/"}
|
34
34
|
```
|
35
35
|
|
36
36
|
`environment` is an optional argument. By passing `:sandbox`, you will retrieve your credentials for the sandbox environment and not for production.
|
@@ -41,19 +41,48 @@ This will return a hash with the information about your api url, which includes
|
|
41
41
|
You can ping the service in order to check if it is up with:
|
42
42
|
|
43
43
|
```ruby
|
44
|
-
Quaderno::Base.ping #=>
|
44
|
+
response = Quaderno::Base.ping #=> Quaderno::Base
|
45
|
+
|
46
|
+
response.status #=> Boolean
|
45
47
|
```
|
46
48
|
|
47
|
-
This will return true if the service is up or false if it is not.
|
49
|
+
This will return `status: true` if the service is up or `status: false` if it is not.
|
48
50
|
|
49
51
|
## Check the rate limit
|
50
52
|
|
51
53
|
```ruby
|
52
|
-
Quaderno::Base.
|
54
|
+
response = Quaderno::Base.ping #=> Quaderno::Base
|
55
|
+
response.rate_limit_info #=> { :reset=> 4, :remaining=> 0 }
|
56
|
+
|
53
57
|
```
|
54
58
|
|
55
59
|
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://github.com/quaderno/quaderno-api#rate-limiting)).
|
56
60
|
|
61
|
+
You can also check the rate limit for each request by checking the `rate_limit_info` method on the response:
|
62
|
+
|
63
|
+
```ruby
|
64
|
+
|
65
|
+
invoices = Quaderno::Invoice.all #=> Quaderno::Collection
|
66
|
+
invoices.rate_limit_info #=> {:reset=> 5, :remaning=>6}
|
67
|
+
|
68
|
+
invoice = Quaderno::Invoice.find INVOICE_ID #=> Quaderno::Invoice
|
69
|
+
invoice.rate_limit_info #=> {:reset=>4, :remaining=>5}
|
70
|
+
|
71
|
+
result = invoice.deliver #=> Quaderno::Base
|
72
|
+
result.rate_limit_info #=> {:reset=>3, :remaining=>4}
|
73
|
+
|
74
|
+
begin
|
75
|
+
deleted_invoice = Quaderno::Invoice.delete(ANOTHER_INVOICE_ID) #=> Quaderno::Invoice
|
76
|
+
rescue Quaderno::Exceptions::InvalidSubdomainOrToken => e
|
77
|
+
# If the exception is triggered you can check the rate limit on the raised exception
|
78
|
+
e.rate_limit_info #=> {:reset=>2, :remaining=>3}
|
79
|
+
end
|
80
|
+
|
81
|
+
deleted_invoice.rate_limit_info #=> {:reset=>2, :remaining=>3}
|
82
|
+
|
83
|
+
# etc.
|
84
|
+
```
|
85
|
+
|
57
86
|
## Reading the values
|
58
87
|
|
59
88
|
Quaderno-ruby parses all the json responses in human readable data, so you can access each value just like this:
|
@@ -69,11 +98,10 @@ Quaderno-ruby parses all the json responses in human readable data, so you can a
|
|
69
98
|
|
70
99
|
### Getting contacts
|
71
100
|
```ruby
|
72
|
-
Quaderno::Contact.all
|
73
|
-
Quaderno::Contact.all(page: 1) #=> Array
|
101
|
+
Quaderno::Contact.all #=> Array
|
74
102
|
```
|
75
103
|
|
76
|
-
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:
|
77
105
|
|
78
106
|
```ruby
|
79
107
|
Quaderno::Contact.all(q: 'John Doe') #=> Array
|
@@ -111,16 +139,16 @@ will update the specified contact with the data of the hash passed as second par
|
|
111
139
|
|
112
140
|
### Deleting a contact
|
113
141
|
```ruby
|
114
|
-
Quaderno::Contact.delete(id) #=>
|
142
|
+
Quaderno::Contact.delete(id) #=> Quaderno::Contact
|
115
143
|
```
|
116
144
|
|
117
|
-
will delete the contact with the id passed as parameter.
|
145
|
+
will delete the contact 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.
|
118
146
|
|
119
147
|
## Managing items
|
120
148
|
|
121
149
|
### Getting items
|
122
150
|
```ruby
|
123
|
-
Quaderno::Item.all
|
151
|
+
Quaderno::Item.all #=> Array
|
124
152
|
```
|
125
153
|
|
126
154
|
will return an array with all your items.
|
@@ -148,10 +176,10 @@ will update the specified item with the data of the hash passed as second parame
|
|
148
176
|
|
149
177
|
### Deleting an item
|
150
178
|
```ruby
|
151
|
-
Quaderno::Item.delete(id) #=>
|
179
|
+
Quaderno::Item.delete(id) #=> Quaderno::Item
|
152
180
|
```
|
153
181
|
|
154
|
-
will delete the item with the id passed as parameter.
|
182
|
+
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.
|
155
183
|
|
156
184
|
|
157
185
|
## Managing invoices
|
@@ -159,10 +187,9 @@ will delete the item with the id passed as parameter.
|
|
159
187
|
### Getting invoices
|
160
188
|
```ruby
|
161
189
|
Quaderno::Invoice.all #=> Array
|
162
|
-
Quaderno::Invoice.all(page: 1) #=> Array
|
163
190
|
```
|
164
191
|
|
165
|
-
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
|
166
193
|
|
167
194
|
### Finding an invoice
|
168
195
|
```ruby
|
@@ -196,10 +223,10 @@ will update the specified invoice with the data of the hash passed as second par
|
|
196
223
|
### Deleting an invoice
|
197
224
|
|
198
225
|
```ruby
|
199
|
-
Quaderno::Invoice.delete(id) #=>
|
226
|
+
Quaderno::Invoice.delete(id) #=> Quaderno::Invoice
|
200
227
|
```
|
201
228
|
|
202
|
-
will delete the invoice with the id passed as parameter.
|
229
|
+
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.
|
203
230
|
|
204
231
|
|
205
232
|
###Adding or removing a payment
|
@@ -219,74 +246,25 @@ In order to remove a payment you will need the Invoice instance you want to upd
|
|
219
246
|
invoice.remove_payment(payment_id) #=> Boolean
|
220
247
|
```
|
221
248
|
|
222
|
-
###Delivering the invoice
|
249
|
+
### Delivering the invoice
|
223
250
|
|
224
251
|
In order to deliver the invoice to the default recipient you will need the invoice you want to send.
|
225
252
|
|
226
253
|
```ruby
|
227
254
|
invoice = Quaderno::Invoice.find(invoice_id)
|
228
|
-
invoice.deliver
|
229
|
-
```
|
230
|
-
|
231
|
-
## Managing receipts
|
232
|
-
|
233
|
-
### Getting receipts
|
234
|
-
```ruby
|
235
|
-
Quaderno::Receipt.all #=> Array
|
236
|
-
Quaderno::Receipt.all(page: 1) #=> Array
|
237
|
-
```
|
238
|
-
|
239
|
-
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
|
240
|
-
|
241
|
-
### Finding a receipt
|
242
|
-
```ruby
|
243
|
-
Quaderno::Receipt.find(id) #=> Quaderno::Receipt
|
244
|
-
```
|
245
|
-
|
246
|
-
will return the receipt with the id passed as parameter.
|
247
|
-
|
248
|
-
### Creating a new receipt
|
249
|
-
|
250
|
-
```ruby
|
251
|
-
Quaderno::Receipt.create(params) #=> Quaderno::Receipt
|
252
|
-
```
|
253
|
-
|
254
|
-
will create an receipt using the information of the hash passed as parameter.
|
255
|
-
|
256
|
-
### Updating an existing receipt
|
257
|
-
```ruby
|
258
|
-
Quaderno::Receipt.update(id, params) #=> Quaderno::Receipt
|
259
|
-
```
|
260
|
-
|
261
|
-
will update the specified receipt with the data of the hash passed as second parameter.
|
262
|
-
|
263
|
-
### Deleting an receipt
|
264
|
-
|
265
|
-
```ruby
|
266
|
-
Quaderno::Receipt.delete(id) #=> Boolean
|
267
|
-
```
|
268
|
-
|
269
|
-
will delete the receipt with the id passed as parameter.
|
270
|
-
|
271
|
-
###Delivering the receipt
|
255
|
+
result = invoice.deliver #=> Quaderno::Base
|
272
256
|
|
273
|
-
|
274
|
-
|
275
|
-
```ruby
|
276
|
-
receipt = Quaderno::Receipt.find(receipt_id)
|
277
|
-
receipt.deliver
|
257
|
+
result.success #=> Boolean
|
278
258
|
```
|
279
259
|
|
280
|
-
|
281
260
|
## Managing credits
|
282
261
|
|
283
262
|
### Getting credits
|
284
263
|
```ruby
|
285
264
|
Quaderno::Credit.all #=> Array
|
286
|
-
Quaderno::Credit.all(page: 1) #=> Array
|
287
265
|
```
|
288
266
|
|
289
|
-
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
|
290
268
|
|
291
269
|
### Finding a credit
|
292
270
|
```ruby
|
@@ -304,10 +282,10 @@ will return the credit note with the transaction id passed as parameter.
|
|
304
282
|
### Creating a new credit
|
305
283
|
|
306
284
|
```ruby
|
307
|
-
Quaderno::Credit.create(
|
285
|
+
Quaderno::Credit.create(invoice_id: 42) #=> Quaderno::Credit
|
308
286
|
```
|
309
287
|
|
310
|
-
will create a credit
|
288
|
+
will create a credit from the invoice specified in the parameter.
|
311
289
|
|
312
290
|
### Updating an existing credit
|
313
291
|
```ruby
|
@@ -319,13 +297,13 @@ will update the specified credit with the data of the hash passed as second para
|
|
319
297
|
### Deleting a credit
|
320
298
|
|
321
299
|
```ruby
|
322
|
-
Quaderno::Credit.delete(id) #=>
|
300
|
+
Quaderno::Credit.delete(id) #=> Quaderno::Credit
|
323
301
|
```
|
324
302
|
|
325
|
-
will delete the credit with the id passed as parameter.
|
303
|
+
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.
|
326
304
|
|
327
305
|
|
328
|
-
###Adding or removing a payment
|
306
|
+
### Adding or removing a payment
|
329
307
|
In order to add a payment you will need the Credit instance you want to update.
|
330
308
|
|
331
309
|
```ruby
|
@@ -339,16 +317,20 @@ In order to remove a payment you will need the Credit instance you want to upda
|
|
339
317
|
|
340
318
|
```ruby
|
341
319
|
credit = Quaderno::Credit.find(credit_id)
|
342
|
-
credit.remove_payment(payment_id) #=>
|
320
|
+
credit.remove_payment(payment_id) #=> Quaderno::Payment
|
343
321
|
```
|
344
322
|
|
345
|
-
|
323
|
+
If the deletion was successful, an instance of `Quaderno::Payment` with the `deleted` attribute set to `true` will be returned.
|
324
|
+
|
325
|
+
### Delivering the credit
|
346
326
|
|
347
327
|
In order to deliver the credit to the default recipient you will need the credit you want to send.
|
348
328
|
|
349
329
|
```ruby
|
350
330
|
credit = Quaderno::Credit.find(credit_id)
|
351
|
-
credit.deliver
|
331
|
+
result = credit.deliver #=> Quaderno::Base
|
332
|
+
|
333
|
+
result.success #=> Boolean
|
352
334
|
```
|
353
335
|
|
354
336
|
|
@@ -357,11 +339,10 @@ In order to remove a payment you will need the Credit instance you want to upda
|
|
357
339
|
|
358
340
|
### Getting estimates
|
359
341
|
```ruby
|
360
|
-
Quaderno::Estimate.all
|
361
|
-
Quaderno::Estimate.all(page: 1) #=> Array
|
342
|
+
Quaderno::Estimate.all #=> Array
|
362
343
|
```
|
363
344
|
|
364
|
-
will return an array with all your estimates
|
345
|
+
will return an array with all your estimates.
|
365
346
|
|
366
347
|
### Finding an estimate
|
367
348
|
```ruby
|
@@ -388,10 +369,10 @@ will update the specified estimate with the data of the hash passed as second pa
|
|
388
369
|
### Deleting an estimate
|
389
370
|
|
390
371
|
```ruby
|
391
|
-
Quaderno::Estimate.delete(id) #=>
|
372
|
+
Quaderno::Estimate.delete(id) #=> Quaderno::Estimate
|
392
373
|
```
|
393
374
|
|
394
|
-
will delete the estimate with the id passed as parameter.
|
375
|
+
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.
|
395
376
|
|
396
377
|
|
397
378
|
###Adding or removing a payment
|
@@ -411,12 +392,14 @@ In order to remove a payment you will need the estimate you want to update.
|
|
411
392
|
estimate.remove_payment(payment_id) #=> Boolean
|
412
393
|
```
|
413
394
|
|
414
|
-
###Delivering the estimate
|
395
|
+
### Delivering the estimate
|
415
396
|
In order to deliver the estimate to the default recipient you will need the estimate you want to send.
|
416
397
|
|
417
398
|
```ruby
|
418
399
|
estimate = Quaderno::Estimate.find(estimate_id)
|
419
|
-
estimate.deliver
|
400
|
+
result = estimate.deliver #=> Quaderno::Base
|
401
|
+
|
402
|
+
result.success #=> Boolean
|
420
403
|
```
|
421
404
|
|
422
405
|
|
@@ -424,11 +407,10 @@ In order to remove a payment you will need the estimate you want to update.
|
|
424
407
|
|
425
408
|
### Getting expenses
|
426
409
|
```ruby
|
427
|
-
Quaderno::Expense.all
|
428
|
-
Quaderno::Expense.all(page: 1) #=> Array
|
410
|
+
Quaderno::Expense.all #=> Array
|
429
411
|
```
|
430
412
|
|
431
|
-
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.
|
432
414
|
|
433
415
|
### Finding an expense
|
434
416
|
```ruby
|
@@ -453,10 +435,10 @@ will update the specified expense with the data of the hash passed as second par
|
|
453
435
|
|
454
436
|
### Deleting an expense
|
455
437
|
```ruby
|
456
|
-
Quaderno::Expense.delete(id) #=>
|
438
|
+
Quaderno::Expense.delete(id) #=> Quaderno::Expense
|
457
439
|
```
|
458
440
|
|
459
|
-
will delete the expense with the id passed as parameter.
|
441
|
+
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.
|
460
442
|
|
461
443
|
|
462
444
|
## Managing recurrings
|
@@ -464,10 +446,9 @@ will delete the expense with the id passed as parameter.
|
|
464
446
|
### Getting recurrings
|
465
447
|
```ruby
|
466
448
|
Quaderno::Recurring.all #=> Array
|
467
|
-
Quaderno::Recurring.all(page: 1) #=> Array
|
468
449
|
```
|
469
450
|
|
470
|
-
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
|
471
452
|
|
472
453
|
### Finding a recurring
|
473
454
|
```ruby
|
@@ -494,17 +475,17 @@ will update the specified recurring with the data of the hash passed as second p
|
|
494
475
|
### Deleting a recurring
|
495
476
|
|
496
477
|
```ruby
|
497
|
-
Quaderno::Recurring.delete(id) #=>
|
478
|
+
Quaderno::Recurring.delete(id) #=> Quaderno::Recurring
|
498
479
|
```
|
499
480
|
|
500
|
-
will delete the recurring with the id passed as parameter.
|
481
|
+
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.
|
501
482
|
|
502
483
|
|
503
484
|
## Managing webhooks
|
504
485
|
|
505
486
|
### Getting webhooks
|
506
487
|
```ruby
|
507
|
-
Quaderno::Webhook.all
|
488
|
+
Quaderno::Webhook.all #=> Array
|
508
489
|
```
|
509
490
|
|
510
491
|
will return an array with all the webhooks you have subscribed.
|
@@ -532,9 +513,9 @@ will update the specified webhook with the data of the hash passed as second par
|
|
532
513
|
|
533
514
|
### Deleting a webhook
|
534
515
|
```ruby
|
535
|
-
Quaderno::Webhook.delete(id) #=>
|
516
|
+
Quaderno::Webhook.delete(id) #=> Quaderno::Webhook
|
536
517
|
```
|
537
|
-
will delete the webhook with the id passed as parameter.
|
518
|
+
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.
|
538
519
|
|
539
520
|
|
540
521
|
## Taxes
|
@@ -546,15 +527,17 @@ will delete the webhook with the id passed as parameter.
|
|
546
527
|
|
547
528
|
will calculate the taxes applied for a customer based on the data pased as parameters.
|
548
529
|
|
549
|
-
### Validate
|
530
|
+
### Validate tax ID
|
550
531
|
```ruby
|
551
|
-
country = 'IE'
|
552
|
-
|
532
|
+
country = 'IE'
|
533
|
+
tax_id = 'IE6388047V'
|
553
534
|
|
554
|
-
Quaderno::Tax.
|
535
|
+
result = Quaderno::Tax.validate_tax_id(country, tax_id) #=> Quaderno::Tax
|
536
|
+
|
537
|
+
result.valid #=> Boolean or nil
|
555
538
|
```
|
556
539
|
|
557
|
-
will validate the
|
540
|
+
will validate the tax ID or business number for the specified country.
|
558
541
|
|
559
542
|
## Evidences
|
560
543
|
|
@@ -565,6 +548,43 @@ will validate the vat number for the passed country.
|
|
565
548
|
|
566
549
|
will create an evidence based on the data pased as parameters.
|
567
550
|
|
551
|
+
## Checkout Sessions
|
552
|
+
|
553
|
+
### Getting checkout sessions
|
554
|
+
```ruby
|
555
|
+
Quaderno::CheckoutSession.all #=> Array
|
556
|
+
```
|
557
|
+
|
558
|
+
will return an array with all the checkout sessions in your account.
|
559
|
+
|
560
|
+
### Finding a checkout session
|
561
|
+
```ruby
|
562
|
+
Quaderno::CheckoutSession.find(id) #=> Quaderno::CheckoutSession
|
563
|
+
```
|
564
|
+
|
565
|
+
will return the checkout session with the id passed as parameter.
|
566
|
+
|
567
|
+
### Creating a new checkout session
|
568
|
+
```ruby
|
569
|
+
Quaderno::CheckoutSession.create(params) #=> Quaderno::CheckoutSession
|
570
|
+
```
|
571
|
+
|
572
|
+
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.
|
573
|
+
|
574
|
+
### Updating an existing checkout session
|
575
|
+
```ruby
|
576
|
+
Quaderno::CheckoutSession.update(id, params) #=> Quaderno::CheckoutSession
|
577
|
+
```
|
578
|
+
|
579
|
+
will update the specified checkout session with the data of the hash passed as second parameter.
|
580
|
+
|
581
|
+
### Deleting a checkout session
|
582
|
+
```ruby
|
583
|
+
Quaderno::CheckoutSession.delete(id) #=> Quaderno::CheckoutSession
|
584
|
+
```
|
585
|
+
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.
|
586
|
+
|
587
|
+
|
568
588
|
## Exceptions
|
569
589
|
Quaderno-ruby exceptions raise depending on the type of error:
|
570
590
|
|
@@ -591,12 +611,27 @@ All those exceptions inherit from `Quaderno::Exceptions::BaseException`.
|
|
591
611
|
Whenever you call the `all` method on one of the classes, the result will be a `Quaderno::Collection`. For example:
|
592
612
|
|
593
613
|
```ruby
|
594
|
-
collection = Quaderno::Contact.all
|
614
|
+
collection = Quaderno::Contact.all
|
595
615
|
|
596
616
|
collection.class #=> Quaderno::Collection
|
597
|
-
collection.
|
598
|
-
collection.
|
599
|
-
|
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
|
600
635
|
```
|
601
636
|
|
602
637
|
### Thread-safe configuration
|
@@ -653,5 +688,3 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
653
688
|
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
654
689
|
|
655
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.
|
656
|
-
|
657
|
-
|