quaderno 1.11.2 → 1.12.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.
Files changed (80) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +1 -1
  3. data/README.md +53 -1
  4. data/VERSION +1 -1
  5. data/changelog.md +3 -0
  6. data/lib/quaderno-ruby/base.rb +12 -2
  7. data/lib/quaderno-ruby/behavior/crud.rb +56 -11
  8. data/lib/quaderno-ruby/behavior/deliver.rb +10 -2
  9. data/lib/quaderno-ruby/behavior/payment.rb +23 -4
  10. data/lib/quaderno-ruby/behavior/retrieve.rb +11 -2
  11. data/lib/quaderno-ruby/collection.rb +22 -0
  12. data/lib/quaderno-ruby/helpers/authentication.rb +26 -0
  13. data/lib/quaderno-ruby.rb +4 -1
  14. data/quaderno.gemspec +16 -5
  15. data/test/fixtures/quaderno_cassettes/all_contacts.yml +11 -282
  16. data/test/fixtures/quaderno_cassettes/all_contacts_by_access_token.yml +56 -0
  17. data/test/fixtures/quaderno_cassettes/all_contacts_by_authentication_token.yml +57 -0
  18. data/test/fixtures/quaderno_cassettes/all_estimates.yml +10 -14
  19. data/test/fixtures/quaderno_cassettes/all_expenses.yml +14 -47
  20. data/test/fixtures/quaderno_cassettes/all_invoices.yml +13 -2873
  21. data/test/fixtures/quaderno_cassettes/all_items.yml +8 -8
  22. data/test/fixtures/quaderno_cassettes/all_receipts.yml +11 -14
  23. data/test/fixtures/quaderno_cassettes/all_webhooks.yml +40 -36
  24. data/test/fixtures/quaderno_cassettes/create_estimate_on_downgraded_API.yml +46 -318
  25. data/test/fixtures/quaderno_cassettes/create_expense_on_downgraded_API.yml +125 -357
  26. data/test/fixtures/quaderno_cassettes/create_invoice_on_downgraded_API.yml +45 -318
  27. data/test/fixtures/quaderno_cassettes/create_receipt_on_downgraded_API.yml +56 -53
  28. data/test/fixtures/quaderno_cassettes/deleted_contact.yml +40 -592
  29. data/test/fixtures/quaderno_cassettes/deleted_contact_by_access_token.yml +199 -0
  30. data/test/fixtures/quaderno_cassettes/deleted_contact_by_authentication_token.yml +199 -0
  31. data/test/fixtures/quaderno_cassettes/deleted_estimate.yml +40 -334
  32. data/test/fixtures/quaderno_cassettes/deleted_expense.yml +43 -364
  33. data/test/fixtures/quaderno_cassettes/deleted_invoice.yml +44 -3199
  34. data/test/fixtures/quaderno_cassettes/deleted_item.yml +22 -22
  35. data/test/fixtures/quaderno_cassettes/deleted_receipt.yml +43 -42
  36. data/test/fixtures/quaderno_cassettes/deleted_webhook.yml +48 -44
  37. data/test/fixtures/quaderno_cassettes/delivered_estimate.yml +25 -32
  38. data/test/fixtures/quaderno_cassettes/delivered_invoice.yml +29 -2888
  39. data/test/fixtures/quaderno_cassettes/delivered_receipt.yml +29 -29
  40. data/test/fixtures/quaderno_cassettes/evidence_invoice.yml +19 -354
  41. data/test/fixtures/quaderno_cassettes/found_contact.yml +19 -291
  42. data/test/fixtures/quaderno_cassettes/found_contact_by_access_token.yml +99 -0
  43. data/test/fixtures/quaderno_cassettes/found_contact_by_authentication_token.yml +100 -0
  44. data/test/fixtures/quaderno_cassettes/found_estimate.yml +20 -24
  45. data/test/fixtures/quaderno_cassettes/found_expense.yml +24 -94
  46. data/test/fixtures/quaderno_cassettes/found_invoice.yml +22 -2886
  47. data/test/fixtures/quaderno_cassettes/found_item.yml +18 -16
  48. data/test/fixtures/quaderno_cassettes/found_receipt.yml +21 -24
  49. data/test/fixtures/quaderno_cassettes/found_webhook.yml +24 -22
  50. data/test/fixtures/quaderno_cassettes/new_contact.yml +9 -7
  51. data/test/fixtures/quaderno_cassettes/new_contact_by_access_token.yml +48 -0
  52. data/test/fixtures/quaderno_cassettes/new_contact_by_authentication_token.yml +48 -0
  53. data/test/fixtures/quaderno_cassettes/new_estimate.yml +29 -320
  54. data/test/fixtures/quaderno_cassettes/new_evidence.yml +10 -8
  55. data/test/fixtures/quaderno_cassettes/new_expense.yml +42 -363
  56. data/test/fixtures/quaderno_cassettes/new_invoice.yml +29 -324
  57. data/test/fixtures/quaderno_cassettes/new_item.yml +10 -8
  58. data/test/fixtures/quaderno_cassettes/new_receipt.yml +28 -24
  59. data/test/fixtures/quaderno_cassettes/new_webhook.yml +16 -14
  60. data/test/fixtures/quaderno_cassettes/paid_expense.yml +22 -52
  61. data/test/fixtures/quaderno_cassettes/paid_invoice.yml +22 -2879
  62. data/test/fixtures/quaderno_cassettes/rate_limit.yml +5 -5
  63. data/test/fixtures/quaderno_cassettes/unpay_an_expense.yml +29 -61
  64. data/test/fixtures/quaderno_cassettes/unpay_an_invoice.yml +28 -2888
  65. data/test/fixtures/quaderno_cassettes/updated_contact.yml +22 -292
  66. data/test/fixtures/quaderno_cassettes/updated_contact_by_access_token.yml +101 -0
  67. data/test/fixtures/quaderno_cassettes/updated_contact_by_authentication_token.yml +102 -0
  68. data/test/fixtures/quaderno_cassettes/updated_estimate.yml +44 -353
  69. data/test/fixtures/quaderno_cassettes/updated_expense.yml +43 -346
  70. data/test/fixtures/quaderno_cassettes/updated_invoice.yml +43 -361
  71. data/test/fixtures/quaderno_cassettes/updated_item.yml +21 -17
  72. data/test/fixtures/quaderno_cassettes/updated_receipt.yml +47 -41
  73. data/test/fixtures/quaderno_cassettes/updated_webhook.yml +35 -31
  74. data/test/helper.rb +2 -1
  75. data/test/unit/test_quaderno_contacts.rb +1 -1
  76. data/test/unit/test_quaderno_contacts_thread_safe.rb +104 -0
  77. data/test/unit/test_quaderno_expenses.rb +5 -5
  78. metadata +15 -4
  79. data/test/fixtures/quaderno_cassettes/calculate_tax.yml +0 -85
  80. data/test/fixtures/quaderno_cassettes/wrong_token.yml +0 -36
@@ -5,10 +5,12 @@ http_interactions:
5
5
  uri: http://sk_test_B7xXrTspfeGukQqGN1pK@development.lvh.me:3000/api/webhooks.json
6
6
  body:
7
7
  encoding: UTF-8
8
- string: url=http%3A%2F%2Fquadernoapp.com&events_types[]=invoice.created&events_types[]=expense.updated
8
+ string: '{"url":"http://quadernoapp.com","events_types":["invoice.created","expense.updated"]}'
9
9
  headers:
10
10
  accept:
11
11
  - application/json
12
+ content-type:
13
+ - application/json
12
14
  authorization:
13
15
  - Basic c2tfdGVzdF9CN3hYclRzcGZlR3VrUXFHTjFwSzo=
14
16
  response:
@@ -21,31 +23,31 @@ http_interactions:
21
23
  x-ratelimit-limit:
22
24
  - '2000'
23
25
  x-ratelimit-reset:
24
- - '1'
26
+ - '15'
25
27
  x-ratelimit-remaining:
26
- - '86'
28
+ - '99'
27
29
  content-type:
28
30
  - application/json; charset=utf-8
29
31
  etag:
30
- - '"475f88b59f6bef096313afee14053207"'
32
+ - '"91b6be83c4e4a2d47fb90561fe7c4f2f"'
31
33
  cache-control:
32
34
  - max-age=0, private, must-revalidate
33
35
  x-request-id:
34
- - 97e9184c-c112-48f5-899c-a42a50d091fb
36
+ - 8073f345-66c4-466c-821c-7215445b37d5
35
37
  x-runtime:
36
- - '12.199711'
38
+ - '4.655960'
37
39
  connection:
38
40
  - close
39
41
  server:
40
42
  - thin
41
43
  body:
42
44
  encoding: UTF-8
43
- string: '{"id":29,"url":"http://quadernoapp.com","auth_key":"rYi9rfhxKYLlxqcH1w_hdA","events_types":["invoice.created","expense.updated"],"last_sent_at":null,"last_error":null,"events_sent":0,"created_at":"2016-06-23T11:28:35.817Z","updated_at":"2016-06-23T11:28:35.817Z"}'
45
+ string: '{"id":2,"url":"http://quadernoapp.com","auth_key":"YbgPZCXR-7M5Y3sN5SI9qg","events_types":["invoice.created","expense.updated"],"last_sent_at":null,"last_error":null,"events_sent":0,"created_at":"2017-06-12T11:54:12.622Z","updated_at":"2017-06-12T11:54:12.622Z"}'
44
46
  http_version: '1.1'
45
- recorded_at: Thu, 23 Jun 2016 11:28:36 GMT
47
+ recorded_at: Mon, 12 Jun 2017 11:54:12 GMT
46
48
  - request:
47
49
  method: delete
48
- uri: http://sk_test_B7xXrTspfeGukQqGN1pK@development.lvh.me:3000/api/webhooks/29.json
50
+ uri: http://sk_test_B7xXrTspfeGukQqGN1pK@development.lvh.me:3000/api/webhooks/2.json
49
51
  body:
50
52
  encoding: US-ASCII
51
53
  string: ''
@@ -64,15 +66,15 @@ http_interactions:
64
66
  x-ratelimit-limit:
65
67
  - '2000'
66
68
  x-ratelimit-reset:
67
- - '15'
69
+ - '10'
68
70
  x-ratelimit-remaining:
69
- - '100'
71
+ - '98'
70
72
  cache-control:
71
73
  - no-cache
72
74
  x-request-id:
73
- - fefeea97-3ebd-423d-8208-f22c3093bece
75
+ - b61a6386-ff61-4ad8-82a8-72473f13889e
74
76
  x-runtime:
75
- - '0.540545'
77
+ - '0.977874'
76
78
  connection:
77
79
  - close
78
80
  server:
@@ -81,5 +83,5 @@ http_interactions:
81
83
  encoding: US-ASCII
82
84
  string: ''
83
85
  http_version: '1.1'
84
- recorded_at: Thu, 23 Jun 2016 11:28:36 GMT
86
+ recorded_at: Mon, 12 Jun 2017 11:54:13 GMT
85
87
  recorded_with: VCR 2.9.2
@@ -2,7 +2,7 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: get
5
- uri: http://sk_test_B7xXrTspfeGukQqGN1pK@development.lvh.me:3000/api/expenses.json
5
+ uri: http://sk_test_B7xXrTspfeGukQqGN1pK@development.lvh.me:3000/api/expenses.json?
6
6
  body:
7
7
  encoding: US-ASCII
8
8
  string: ''
@@ -21,9 +21,9 @@ http_interactions:
21
21
  x-ratelimit-limit:
22
22
  - '2000'
23
23
  x-ratelimit-reset:
24
- - '14'
24
+ - '15'
25
25
  x-ratelimit-remaining:
26
- - '98'
26
+ - '100'
27
27
  x-pages-currentpage:
28
28
  - '1'
29
29
  x-pages-totalpages:
@@ -31,60 +31,30 @@ http_interactions:
31
31
  content-type:
32
32
  - application/json; charset=utf-8
33
33
  etag:
34
- - '"59ac3e6be65e8f6b3cab1f2c5dfb0fa0"'
34
+ - '"04eba45c4062d412570b79904d65d4c7"'
35
35
  cache-control:
36
36
  - max-age=0, private, must-revalidate
37
37
  x-request-id:
38
- - 35baa3eb-bcec-469f-8781-698b18adcc95
38
+ - 3a8c1ecc-a2a8-46e1-a8fa-09a26b1f7833
39
39
  x-runtime:
40
- - '0.556730'
40
+ - '4.103498'
41
41
  connection:
42
42
  - close
43
43
  server:
44
44
  - thin
45
45
  body:
46
- encoding: ASCII-8BIT
47
- string: !binary |-
48
- W3siaWQiOjk5NCwiaXNzdWVfZGF0ZSI6IjIwMTYtMDYtMDgiLCJjcmVhdGVk
49
- X2F0IjoxNDY1Mzg1NjQwLCJjb250YWN0Ijp7ImlkIjo1MywiZnVsbF9uYW1l
50
- IjoiVGVzdF9PQ1AgVW1wacOpcnJleiJ9LCJzdHJlZXRfbGluZV8xIjpudWxs
51
- LCJzdHJlZXRfbGluZV8yIjpudWxsLCJjaXR5IjpudWxsLCJyZWdpb24iOm51
52
- bGwsInBvc3RhbF9jb2RlIjpudWxsLCJwb19udW1iZXIiOm51bGwsImN1cnJl
53
- bmN5IjoiRVVSIiwiZXhjaGFuZ2VfcmF0ZSI6IjEuMCIsIml0ZW1zIjpbeyJp
54
- ZCI6MTAwNCwiZGVzY3JpcHRpb24iOiJTb21ldGhpbmciLCJxdWFudGl0eSI6
55
- IjEuMCIsInVuaXRfcHJpY2VfY2VudHMiOiIyMDAwLjAiLCJkaXNjb3VudF9y
56
- YXRlIjoiMC4wIiwidGF4XzFfbmFtZSI6Ik13U3QuL1VTdC4iLCJ0YXhfMV9y
57
- YXRlIjoxOS4wLCJ0YXhfMl9uYW1lIjoiIiwidGF4XzJfcmF0ZSI6bnVsbCwi
58
- cmVmZXJlbmNlIjpudWxsLCJzdWJ0b3RhbF9jZW50cyI6IjIwMDAuMCIsImRp
59
- c2NvdW50X2NlbnRzIjoiMC4wIiwiZ3Jvc3NfYW1vdW50X2NlbnRzIjoiMjAw
60
- MC4wIn1dLCJzdWJ0b3RhbF9jZW50cyI6IjIwMDAuMCIsImRpc2NvdW50X2Nl
61
- bnRzIjoiMC4wIiwidGF4ZXMiOlt7ImxhYmVsIjoiTXdTdC4vVVN0LiAoMTku
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xvcG1lbnQu
79
- bHZoLm1lOjMwMDAvYXBpL2V4cGVuc2VzLzk5NC9wYXltZW50cy8yMS5qc29u
80
- In1dLCJub3RlcyI6bnVsbCwic3RhdGUiOiJwYWlkIiwidGFnX2xpc3QiOltd
81
- LCJ1cmwiOiJodHRwOi8vZGV2ZWxvcG1lbnQubHZoLm1lOjMwMDAvYXBpL2V4
82
- cGVuc2VzLzk5NC5qc29uIn1d
46
+ encoding: UTF-8
47
+ string: '[{"id":184,"blocked":false,"issue_date":"2017-06-12","created_at":1497266330,"contact":{"id":44,"full_name":"Albus
48
+ Dumbledoge"},"country":"BE","street_line_1":null,"street_line_2":null,"city":null,"region":null,"postal_code":null,"po_number":null,"currency":"EUR","subject":null,"items":[{"id":185,"description":"Aircraft","quantity":"1.0","unit_price_cents":"0.0","discount_rate":"0.0","tax_1_name":null,"tax_1_rate":null,"tax_2_name":null,"tax_2_rate":null,"reference":null,"subtotal_cents":"0.0","discount_cents":"0.0","gross_amount_cents":"0.0"}],"subtotal_cents":"0.0","discount_cents":"0.0","taxes":[],"extract":{"total_cents":0},"payments":[{"id":40,"date":"2017-06-12","payment_method":"cash","amount_cents":1000000,"url":"http://development.lvh.me:3000/api/expenses/184/payments/40.json"},{"id":41,"date":"2017-06-12","payment_method":"cash","amount_cents":1000000,"url":"http://development.lvh.me:3000/api/expenses/184/payments/41.json"}],"notes":null,"state":"paid","tag_list":[],"url":"http://development.lvh.me:3000/api/expenses/184.json","custom_metadata":{}},{"id":137,"blocked":true,"issue_date":"2017-05-29","created_at":1496060112,"contact":{"id":42,"full_name":"Cidi
49
+ Campidocti"},"country":"ES","street_line_1":null,"street_line_2":null,"city":null,"region":null,"postal_code":null,"po_number":null,"currency":"EUR","subject":null,"items":[{"id":138,"description":"asdasd","quantity":"1.0","unit_price_cents":"0.0","discount_rate":"0.0","tax_1_name":"","tax_1_rate":null,"tax_2_name":"","tax_2_rate":null,"reference":"","subtotal_cents":"0.0","discount_cents":"0.0","gross_amount_cents":"0.0"}],"subtotal_cents":"0.0","discount_cents":"0.0","taxes":[],"extract":{"total_cents":0},"payments":[],"notes":null,"state":"paid","tag_list":["dundundugan","rap"],"url":"http://development.lvh.me:3000/api/expenses/137.json","custom_metadata":{}},{"id":135,"blocked":false,"issue_date":"2017-05-26","created_at":1495789529,"contact":{"id":42,"full_name":"Cidi
50
+ Campidocti"},"country":"ES","street_line_1":null,"street_line_2":null,"city":null,"region":null,"postal_code":null,"po_number":null,"currency":"EUR","subject":null,"items":[{"id":136,"description":"Dreamhack
51
+ valencia","quantity":"1.0","unit_price_cents":"23000.0","discount_rate":"0.0","tax_1_name":"","tax_1_rate":null,"tax_2_name":"","tax_2_rate":null,"reference":"","subtotal_cents":"23000.0","discount_cents":"0.0","gross_amount_cents":"23000.0"}],"subtotal_cents":"23000.0","discount_cents":"0.0","taxes":[],"extract":{"total_cents":23000},"payments":[{"id":7,"date":"2017-05-31","payment_method":"credit_card","amount_cents":23000,"url":"http://development.lvh.me:3000/api/expenses/135/payments/7.json"}],"notes":null,"state":"paid","tag_list":["balls"],"url":"http://development.lvh.me:3000/api/expenses/135.json","custom_metadata":{}},{"id":134,"blocked":false,"issue_date":"2017-05-26","created_at":1495789490,"contact":{"id":42,"full_name":"Cidi
52
+ Campidocti"},"country":"ES","street_line_1":null,"street_line_2":null,"city":null,"region":null,"postal_code":null,"po_number":null,"currency":"EUR","subject":null,"items":[{"id":135,"description":"Something","quantity":"1.0","unit_price_cents":"1000.0","discount_rate":"0.0","tax_1_name":"","tax_1_rate":null,"tax_2_name":"","tax_2_rate":null,"reference":"","subtotal_cents":"1000.0","discount_cents":"0.0","gross_amount_cents":"1000.0"}],"subtotal_cents":"1000.0","discount_cents":"0.0","taxes":[],"extract":{"total_cents":1000},"payments":[{"id":4,"date":"2017-05-31","payment_method":"credit_card","amount_cents":1000,"url":"http://development.lvh.me:3000/api/expenses/134/payments/4.json"}],"notes":null,"state":"paid","tag_list":["rap","god"],"url":"http://development.lvh.me:3000/api/expenses/134.json","custom_metadata":{}}]'
83
53
  http_version: '1.1'
84
- recorded_at: Thu, 23 Jun 2016 11:25:47 GMT
54
+ recorded_at: Mon, 12 Jun 2017 11:38:02 GMT
85
55
  - request:
86
56
  method: post
87
- uri: http://sk_test_B7xXrTspfeGukQqGN1pK@development.lvh.me:3000/api/expenses/994/payments.json
57
+ uri: http://sk_test_B7xXrTspfeGukQqGN1pK@development.lvh.me:3000/api/expenses/184/payments.json
88
58
  body:
89
59
  encoding: UTF-8
90
60
  string: payment_method=cash&amount=10000
@@ -103,26 +73,26 @@ http_interactions:
103
73
  x-ratelimit-limit:
104
74
  - '2000'
105
75
  x-ratelimit-reset:
106
- - '13'
76
+ - '15'
107
77
  x-ratelimit-remaining:
108
- - '97'
78
+ - '99'
109
79
  content-type:
110
80
  - application/json; charset=utf-8
111
81
  etag:
112
- - '"af24184b6dc180c109241ef24104c67b"'
82
+ - '"cdd717fecdd357b86d86cc70298657c1"'
113
83
  cache-control:
114
84
  - max-age=0, private, must-revalidate
115
85
  x-request-id:
116
- - 81798cc6-2ea5-4bb0-b248-d78c0dd518dd
86
+ - e3ae0b07-2a32-4dab-962c-554209c21bc9
117
87
  x-runtime:
118
- - '0.776857'
88
+ - '2.063114'
119
89
  connection:
120
90
  - close
121
91
  server:
122
92
  - thin
123
93
  body:
124
94
  encoding: UTF-8
125
- string: '{"id":28,"date":"2016-06-23","payment_method":"cash","amount_cents":1000000,"url":"http://development.lvh.me:3000/api/expenses/994/payments/28.json"}'
95
+ string: '{"id":42,"date":"2017-06-12","payment_method":"cash","amount_cents":1000000,"url":"http://development.lvh.me:3000/api/expenses/184/payments/42.json"}'
126
96
  http_version: '1.1'
127
- recorded_at: Thu, 23 Jun 2016 11:25:48 GMT
97
+ recorded_at: Mon, 12 Jun 2017 11:38:04 GMT
128
98
  recorded_with: VCR 2.9.2