quaderno 1.15.2 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: d88e283d2865f257d6d5c3ce29eb4d9fe2f0e749
4
- data.tar.gz: 11cb11199deb03cd17b9178eccc15bf3dd5bb432
2
+ SHA256:
3
+ metadata.gz: 18ba0623ca695fdd9f95f1bb922e7002f6482224aa8b793b307bbe233327b0d9
4
+ data.tar.gz: 0d3719afdbbfc2739a64513d451444f7bfd268fe9a521e6522f24d160acf7612
5
5
  SHA512:
6
- metadata.gz: 30ea0846d2cebbd5e7e89a1627f5d6b7ad09306653ed002e35e1a65aeb1cda704011e13c9fd20d68206e0e6c5bb4213b217442fa6b9e4123705e207e74af63c1
7
- data.tar.gz: 24baa78f3ea03595912cce861676edd2f139733d6ac4835d266baf23dc8eae6fe287c8045a3116c7fdb0e9c43dfd34020d4c31f5389b9b4af89231e3ca152eb3
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 1.15.2 See the changelog [here](https://github.com/quaderno/quaderno-ruby/blob/master/changelog.md)
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
- # => {"identity"=>{"id"=>737000, "name"=>"Walter White", "email"=>"cooking@br.bd", "href"=>"https://my_subdomain.quadernoapp.com/api/"}}
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 #=> Boolean
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.rate_limit_info #=> {:reset=>4, :remaining=>0}
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() #=> Array
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 on the first page. You can also pass query strings using the attribute :q in order to filter the results by contact name. For example:
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) #=> Boolean
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() #=> Array
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) #=> Boolean
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 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
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) #=> Boolean
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
- In order to deliver the receipt to the default recipient you will need the receipt you want to send.
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 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
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(params) #=> Quaderno::Credit
285
+ Quaderno::Credit.create(invoice_id: 42) #=> Quaderno::Credit
308
286
  ```
309
287
 
310
- will create a credit using the information of the hash passed as parameter.
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) #=> Boolean
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) #=> Boolean
320
+ credit.remove_payment(payment_id) #=> Quaderno::Payment
343
321
  ```
344
322
 
345
- ###Delivering the credit
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() #=> Array
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 on the first page.
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) #=> Boolean
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() #=> Array
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 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.
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) #=> Boolean
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 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
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) #=> Boolean
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() #=> Array
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) #=> Boolean
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
@@ -548,10 +529,12 @@ will calculate the taxes applied for a customer based on the data pased as param
548
529
 
549
530
  ### Validate VAT numbers
550
531
  ```ruby
551
- country = 'IE'
552
- vat_number = 'IE6388047V'
532
+ country = 'IE'
533
+ vat_number = 'IE6388047V'
553
534
 
554
- Quaderno::Tax.validate_vat_number(country, vat_number) #=> Boolean
535
+ result = Quaderno::Tax.validate_vat_number(country, vat_number) #=> Quaderno::Tax
536
+
537
+ result.valid #=> Boolean or nil
555
538
  ```
556
539
 
557
540
  will validate the vat number for the passed country.
@@ -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(page: 2)
614
+ collection = Quaderno::Contact.all
595
615
 
596
616
  collection.class #=> Quaderno::Collection
597
- collection.pagination_info #=> {:current_page=>"1", :total_pages=>"3"}
598
- collection.current_page #=> "2"
599
- collection.total_pages #=> "3"
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
-