quaderno 1.11.2 → 1.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +53 -1
- data/VERSION +1 -1
- data/changelog.md +3 -0
- data/lib/quaderno-ruby/base.rb +12 -2
- data/lib/quaderno-ruby/behavior/crud.rb +56 -11
- data/lib/quaderno-ruby/behavior/deliver.rb +10 -2
- data/lib/quaderno-ruby/behavior/payment.rb +23 -4
- data/lib/quaderno-ruby/behavior/retrieve.rb +11 -2
- data/lib/quaderno-ruby/collection.rb +22 -0
- data/lib/quaderno-ruby/helpers/authentication.rb +26 -0
- data/lib/quaderno-ruby.rb +4 -1
- data/quaderno.gemspec +16 -5
- data/test/fixtures/quaderno_cassettes/all_contacts.yml +11 -282
- data/test/fixtures/quaderno_cassettes/all_contacts_by_access_token.yml +56 -0
- data/test/fixtures/quaderno_cassettes/all_contacts_by_authentication_token.yml +57 -0
- data/test/fixtures/quaderno_cassettes/all_estimates.yml +10 -14
- data/test/fixtures/quaderno_cassettes/all_expenses.yml +14 -47
- data/test/fixtures/quaderno_cassettes/all_invoices.yml +13 -2873
- data/test/fixtures/quaderno_cassettes/all_items.yml +8 -8
- data/test/fixtures/quaderno_cassettes/all_receipts.yml +11 -14
- data/test/fixtures/quaderno_cassettes/all_webhooks.yml +40 -36
- data/test/fixtures/quaderno_cassettes/create_estimate_on_downgraded_API.yml +46 -318
- data/test/fixtures/quaderno_cassettes/create_expense_on_downgraded_API.yml +125 -357
- data/test/fixtures/quaderno_cassettes/create_invoice_on_downgraded_API.yml +45 -318
- data/test/fixtures/quaderno_cassettes/create_receipt_on_downgraded_API.yml +56 -53
- data/test/fixtures/quaderno_cassettes/deleted_contact.yml +40 -592
- data/test/fixtures/quaderno_cassettes/deleted_contact_by_access_token.yml +199 -0
- data/test/fixtures/quaderno_cassettes/deleted_contact_by_authentication_token.yml +199 -0
- data/test/fixtures/quaderno_cassettes/deleted_estimate.yml +40 -334
- data/test/fixtures/quaderno_cassettes/deleted_expense.yml +43 -364
- data/test/fixtures/quaderno_cassettes/deleted_invoice.yml +44 -3199
- data/test/fixtures/quaderno_cassettes/deleted_item.yml +22 -22
- data/test/fixtures/quaderno_cassettes/deleted_receipt.yml +43 -42
- data/test/fixtures/quaderno_cassettes/deleted_webhook.yml +48 -44
- data/test/fixtures/quaderno_cassettes/delivered_estimate.yml +25 -32
- data/test/fixtures/quaderno_cassettes/delivered_invoice.yml +29 -2888
- data/test/fixtures/quaderno_cassettes/delivered_receipt.yml +29 -29
- data/test/fixtures/quaderno_cassettes/evidence_invoice.yml +19 -354
- data/test/fixtures/quaderno_cassettes/found_contact.yml +19 -291
- data/test/fixtures/quaderno_cassettes/found_contact_by_access_token.yml +99 -0
- data/test/fixtures/quaderno_cassettes/found_contact_by_authentication_token.yml +100 -0
- data/test/fixtures/quaderno_cassettes/found_estimate.yml +20 -24
- data/test/fixtures/quaderno_cassettes/found_expense.yml +24 -94
- data/test/fixtures/quaderno_cassettes/found_invoice.yml +22 -2886
- data/test/fixtures/quaderno_cassettes/found_item.yml +18 -16
- data/test/fixtures/quaderno_cassettes/found_receipt.yml +21 -24
- data/test/fixtures/quaderno_cassettes/found_webhook.yml +24 -22
- data/test/fixtures/quaderno_cassettes/new_contact.yml +9 -7
- data/test/fixtures/quaderno_cassettes/new_contact_by_access_token.yml +48 -0
- data/test/fixtures/quaderno_cassettes/new_contact_by_authentication_token.yml +48 -0
- data/test/fixtures/quaderno_cassettes/new_estimate.yml +29 -320
- data/test/fixtures/quaderno_cassettes/new_evidence.yml +10 -8
- data/test/fixtures/quaderno_cassettes/new_expense.yml +42 -363
- data/test/fixtures/quaderno_cassettes/new_invoice.yml +29 -324
- data/test/fixtures/quaderno_cassettes/new_item.yml +10 -8
- data/test/fixtures/quaderno_cassettes/new_receipt.yml +28 -24
- data/test/fixtures/quaderno_cassettes/new_webhook.yml +16 -14
- data/test/fixtures/quaderno_cassettes/paid_expense.yml +22 -52
- data/test/fixtures/quaderno_cassettes/paid_invoice.yml +22 -2879
- data/test/fixtures/quaderno_cassettes/rate_limit.yml +5 -5
- data/test/fixtures/quaderno_cassettes/unpay_an_expense.yml +29 -61
- data/test/fixtures/quaderno_cassettes/unpay_an_invoice.yml +28 -2888
- data/test/fixtures/quaderno_cassettes/updated_contact.yml +22 -292
- data/test/fixtures/quaderno_cassettes/updated_contact_by_access_token.yml +101 -0
- data/test/fixtures/quaderno_cassettes/updated_contact_by_authentication_token.yml +102 -0
- data/test/fixtures/quaderno_cassettes/updated_estimate.yml +44 -353
- data/test/fixtures/quaderno_cassettes/updated_expense.yml +43 -346
- data/test/fixtures/quaderno_cassettes/updated_invoice.yml +43 -361
- data/test/fixtures/quaderno_cassettes/updated_item.yml +21 -17
- data/test/fixtures/quaderno_cassettes/updated_receipt.yml +47 -41
- data/test/fixtures/quaderno_cassettes/updated_webhook.yml +35 -31
- data/test/helper.rb +2 -1
- data/test/unit/test_quaderno_contacts.rb +1 -1
- data/test/unit/test_quaderno_contacts_thread_safe.rb +104 -0
- data/test/unit/test_quaderno_expenses.rb +5 -5
- metadata +15 -4
- data/test/fixtures/quaderno_cassettes/calculate_tax.yml +0 -85
- 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/contacts.json
|
6
6
|
body:
|
7
7
|
encoding: UTF-8
|
8
|
-
string: first_name
|
8
|
+
string: '{"first_name":"Test customer"}'
|
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,38 +23,40 @@ http_interactions:
|
|
21
23
|
x-ratelimit-limit:
|
22
24
|
- '2000'
|
23
25
|
x-ratelimit-reset:
|
24
|
-
- '
|
26
|
+
- '13'
|
25
27
|
x-ratelimit-remaining:
|
26
|
-
- '
|
28
|
+
- '98'
|
27
29
|
content-type:
|
28
30
|
- application/json; charset=utf-8
|
29
31
|
etag:
|
30
|
-
- '"
|
32
|
+
- '"9add49064c7cdbb7075d7041400a4793"'
|
31
33
|
cache-control:
|
32
34
|
- max-age=0, private, must-revalidate
|
33
35
|
x-request-id:
|
34
|
-
-
|
36
|
+
- 2febc61d-7841-42a5-910b-fc4b7a801a0f
|
35
37
|
x-runtime:
|
36
|
-
- '
|
38
|
+
- '1.382284'
|
37
39
|
connection:
|
38
40
|
- close
|
39
41
|
server:
|
40
42
|
- thin
|
41
43
|
body:
|
42
44
|
encoding: UTF-8
|
43
|
-
string: '{"id":
|
44
|
-
customer","contact_name":null,"street_line_1":null,"street_line_2":null,"postal_code":null,"city":null,"region":null,"country":"ES","phone_1":null,"phone_2":null,"fax":null,"email":null,"web":null,"discount":null,"tax_id":null,"vat_number":null,"bank_account":null,"language":"ES","notes":null,"secure_id":"
|
45
|
+
string: '{"id":54,"kind":"company","created_at":1497268190,"full_name":"Test
|
46
|
+
customer","contact_name":null,"street_line_1":null,"street_line_2":null,"postal_code":null,"city":null,"region":null,"country":"ES","phone_1":null,"phone_2":null,"fax":null,"email":null,"web":null,"discount":null,"tax_id":null,"vat_number":null,"bank_account":null,"language":"ES","notes":null,"secure_id":"60bdc026b6e7315ebc4a520c729333ce73465abd","permalink":"http://development.lvh.me:3000/billing/60bdc026b6e7315ebc4a520c729333ce73465abd","url":"http://development.lvh.me:3000/api/contacts/54"}'
|
45
47
|
http_version: '1.1'
|
46
|
-
recorded_at:
|
48
|
+
recorded_at: Mon, 12 Jun 2017 11:49:50 GMT
|
47
49
|
- request:
|
48
50
|
method: post
|
49
51
|
uri: http://sk_test_B7xXrTspfeGukQqGN1pK@development.lvh.me:3000/api/receipts.json
|
50
52
|
body:
|
51
53
|
encoding: UTF-8
|
52
|
-
string: contact_id
|
54
|
+
string: '{"contact_id":54,"currency":"EUR","items_attributes":[{"description":"Aircraft","quantity":"1.0","unit_price":"0.0"}],"tags":"tnt","payment_method":"cash","notes":""}'
|
53
55
|
headers:
|
54
56
|
accept:
|
55
57
|
- application/json
|
58
|
+
content-type:
|
59
|
+
- application/json
|
56
60
|
authorization:
|
57
61
|
- Basic c2tfdGVzdF9CN3hYclRzcGZlR3VrUXFHTjFwSzo=
|
58
62
|
response:
|
@@ -65,38 +69,40 @@ http_interactions:
|
|
65
69
|
x-ratelimit-limit:
|
66
70
|
- '2000'
|
67
71
|
x-ratelimit-reset:
|
68
|
-
- '
|
72
|
+
- '12'
|
69
73
|
x-ratelimit-remaining:
|
70
|
-
- '
|
74
|
+
- '97'
|
71
75
|
content-type:
|
72
76
|
- application/json; charset=utf-8
|
73
77
|
etag:
|
74
|
-
- '"
|
78
|
+
- '"91cf83bc0d595ace3687a1b2e122958c"'
|
75
79
|
cache-control:
|
76
80
|
- max-age=0, private, must-revalidate
|
77
81
|
x-request-id:
|
78
|
-
-
|
82
|
+
- 2646602d-8a60-408d-849f-22aa435aa465
|
79
83
|
x-runtime:
|
80
|
-
- '4.
|
84
|
+
- '4.620237'
|
81
85
|
connection:
|
82
86
|
- close
|
83
87
|
server:
|
84
88
|
- thin
|
85
89
|
body:
|
86
90
|
encoding: UTF-8
|
87
|
-
string: '{"id":
|
88
|
-
customer"},"street_line_1":null,"street_line_2":null,"city":null,"region":null,"postal_code":null,"po_number":null,"currency":"EUR","
|
91
|
+
string: '{"id":204,"blocked":false,"number":"0003","issue_date":"2017-06-12","created_at":1497268191,"contact":{"id":54,"full_name":"Test
|
92
|
+
customer"},"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":205,"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":[],"payments":[{"id":54,"date":"2017-06-12","payment_method":"cash","amount_cents":0}],"notes":null,"state":"paid","tag_list":[],"secure_id":"64687022590db95fa97a32ac967b24cb88bad958","permalink":"http://development.lvh.me:3000/receipt/64687022590db95fa97a32ac967b24cb88bad958","pdf":"http://development.lvh.me:3000/receipt/64687022590db95fa97a32ac967b24cb88bad958.pdf","url":"http://development.lvh.me:3000/api/receipts/204.json","processor":null,"processor_id":null,"custom_metadata":{}}'
|
89
93
|
http_version: '1.1'
|
90
|
-
recorded_at:
|
94
|
+
recorded_at: Mon, 12 Jun 2017 11:49:55 GMT
|
91
95
|
- request:
|
92
96
|
method: put
|
93
|
-
uri: http://sk_test_B7xXrTspfeGukQqGN1pK@development.lvh.me:3000/api/receipts/
|
97
|
+
uri: http://sk_test_B7xXrTspfeGukQqGN1pK@development.lvh.me:3000/api/receipts/204.json
|
94
98
|
body:
|
95
99
|
encoding: UTF-8
|
96
|
-
string: notes
|
100
|
+
string: '{"notes":"Show me the moneeeeeeeyy!!!!"}'
|
97
101
|
headers:
|
98
102
|
accept:
|
99
103
|
- application/json
|
104
|
+
content-type:
|
105
|
+
- application/json
|
100
106
|
authorization:
|
101
107
|
- Basic c2tfdGVzdF9CN3hYclRzcGZlR3VrUXFHTjFwSzo=
|
102
108
|
response:
|
@@ -109,33 +115,33 @@ http_interactions:
|
|
109
115
|
x-ratelimit-limit:
|
110
116
|
- '2000'
|
111
117
|
x-ratelimit-reset:
|
112
|
-
- '
|
118
|
+
- '7'
|
113
119
|
x-ratelimit-remaining:
|
114
|
-
- '
|
120
|
+
- '96'
|
115
121
|
content-type:
|
116
122
|
- application/json; charset=utf-8
|
117
123
|
etag:
|
118
|
-
- '"
|
124
|
+
- '"4d11c125cf46e28ca6ed2994d9665b32"'
|
119
125
|
cache-control:
|
120
126
|
- max-age=0, private, must-revalidate
|
121
127
|
x-request-id:
|
122
|
-
-
|
128
|
+
- ec358ced-cca9-4a6a-9bf9-aa7c25050997
|
123
129
|
x-runtime:
|
124
|
-
- '
|
130
|
+
- '3.640285'
|
125
131
|
connection:
|
126
132
|
- close
|
127
133
|
server:
|
128
134
|
- thin
|
129
135
|
body:
|
130
136
|
encoding: UTF-8
|
131
|
-
string: '{"id":
|
132
|
-
customer"},"street_line_1":null,"street_line_2":null,"city":null,"region":null,"postal_code":null,"po_number":null,"currency":"EUR","
|
133
|
-
me the moneeeeeeeyy!!!!","state":"paid","tag_list":[],"secure_id":"
|
137
|
+
string: '{"id":204,"blocked":false,"number":"0003","issue_date":"2017-06-12","created_at":1497268191,"contact":{"id":54,"full_name":"Test
|
138
|
+
customer"},"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":205,"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":[],"payments":[{"id":54,"date":"2017-06-12","payment_method":"cash","amount_cents":0}],"notes":"Show
|
139
|
+
me the moneeeeeeeyy!!!!","state":"paid","tag_list":[],"secure_id":"64687022590db95fa97a32ac967b24cb88bad958","permalink":"http://development.lvh.me:3000/receipt/64687022590db95fa97a32ac967b24cb88bad958","pdf":"http://development.lvh.me:3000/receipt/64687022590db95fa97a32ac967b24cb88bad958.pdf","url":"http://development.lvh.me:3000/api/receipts/204.json","processor":null,"processor_id":null,"custom_metadata":{}}'
|
134
140
|
http_version: '1.1'
|
135
|
-
recorded_at:
|
141
|
+
recorded_at: Mon, 12 Jun 2017 11:49:59 GMT
|
136
142
|
- request:
|
137
143
|
method: delete
|
138
|
-
uri: http://sk_test_B7xXrTspfeGukQqGN1pK@development.lvh.me:3000/api/receipts/
|
144
|
+
uri: http://sk_test_B7xXrTspfeGukQqGN1pK@development.lvh.me:3000/api/receipts/204.json
|
139
145
|
body:
|
140
146
|
encoding: US-ASCII
|
141
147
|
string: ''
|
@@ -154,15 +160,15 @@ http_interactions:
|
|
154
160
|
x-ratelimit-limit:
|
155
161
|
- '2000'
|
156
162
|
x-ratelimit-reset:
|
157
|
-
- '
|
163
|
+
- '3'
|
158
164
|
x-ratelimit-remaining:
|
159
|
-
- '
|
165
|
+
- '95'
|
160
166
|
cache-control:
|
161
167
|
- no-cache
|
162
168
|
x-request-id:
|
163
|
-
-
|
169
|
+
- eef2ba83-87a9-45b8-9493-f0606805b64c
|
164
170
|
x-runtime:
|
165
|
-
- '
|
171
|
+
- '2.957383'
|
166
172
|
connection:
|
167
173
|
- close
|
168
174
|
server:
|
@@ -171,10 +177,10 @@ http_interactions:
|
|
171
177
|
encoding: US-ASCII
|
172
178
|
string: ''
|
173
179
|
http_version: '1.1'
|
174
|
-
recorded_at:
|
180
|
+
recorded_at: Mon, 12 Jun 2017 11:50:02 GMT
|
175
181
|
- request:
|
176
182
|
method: delete
|
177
|
-
uri: http://sk_test_B7xXrTspfeGukQqGN1pK@development.lvh.me:3000/api/contacts/
|
183
|
+
uri: http://sk_test_B7xXrTspfeGukQqGN1pK@development.lvh.me:3000/api/contacts/54.json
|
178
184
|
body:
|
179
185
|
encoding: US-ASCII
|
180
186
|
string: ''
|
@@ -193,15 +199,15 @@ http_interactions:
|
|
193
199
|
x-ratelimit-limit:
|
194
200
|
- '2000'
|
195
201
|
x-ratelimit-reset:
|
196
|
-
- '
|
202
|
+
- '1'
|
197
203
|
x-ratelimit-remaining:
|
198
|
-
- '
|
204
|
+
- '94'
|
199
205
|
cache-control:
|
200
206
|
- no-cache
|
201
207
|
x-request-id:
|
202
|
-
-
|
208
|
+
- cab0ead8-c00f-4179-81e7-5816ef7c81b5
|
203
209
|
x-runtime:
|
204
|
-
- '
|
210
|
+
- '1.099096'
|
205
211
|
connection:
|
206
212
|
- close
|
207
213
|
server:
|
@@ -210,5 +216,5 @@ http_interactions:
|
|
210
216
|
encoding: US-ASCII
|
211
217
|
string: ''
|
212
218
|
http_version: '1.1'
|
213
|
-
recorded_at:
|
219
|
+
recorded_at: Mon, 12 Jun 2017 11:50:03 GMT
|
214
220
|
recorded_with: VCR 2.9.2
|
@@ -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
|
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
|
-
- '
|
26
|
+
- '7'
|
25
27
|
x-ratelimit-remaining:
|
26
|
-
- '
|
28
|
+
- '93'
|
27
29
|
content-type:
|
28
30
|
- application/json; charset=utf-8
|
29
31
|
etag:
|
30
|
-
- '"
|
32
|
+
- '"50272ad49799cb72cebe932d58808877"'
|
31
33
|
cache-control:
|
32
34
|
- max-age=0, private, must-revalidate
|
33
35
|
x-request-id:
|
34
|
-
-
|
36
|
+
- c057b4fb-bdd8-49a4-8fd6-ef2e6eceb20f
|
35
37
|
x-runtime:
|
36
|
-
- '
|
38
|
+
- '1.872855'
|
37
39
|
connection:
|
38
40
|
- close
|
39
41
|
server:
|
40
42
|
- thin
|
41
43
|
body:
|
42
44
|
encoding: UTF-8
|
43
|
-
string: '{"id":
|
45
|
+
string: '{"id":8,"url":"http://quadernoapp.com","auth_key":"JL-KguI89KWWPQfx-j_jVQ","events_types":["invoice.created","expense.updated"],"last_sent_at":null,"last_error":null,"events_sent":0,"created_at":"2017-06-12T11:54:33.493Z","updated_at":"2017-06-12T11:54:33.493Z"}'
|
44
46
|
http_version: '1.1'
|
45
|
-
recorded_at:
|
47
|
+
recorded_at: Mon, 12 Jun 2017 11:54:33 GMT
|
46
48
|
- request:
|
47
49
|
method: get
|
48
|
-
uri: http://sk_test_B7xXrTspfeGukQqGN1pK@development.lvh.me:3000/api/webhooks.json
|
50
|
+
uri: http://sk_test_B7xXrTspfeGukQqGN1pK@development.lvh.me:3000/api/webhooks.json?
|
49
51
|
body:
|
50
52
|
encoding: US-ASCII
|
51
53
|
string: ''
|
@@ -64,37 +66,39 @@ http_interactions:
|
|
64
66
|
x-ratelimit-limit:
|
65
67
|
- '2000'
|
66
68
|
x-ratelimit-reset:
|
67
|
-
- '
|
69
|
+
- '5'
|
68
70
|
x-ratelimit-remaining:
|
69
|
-
- '
|
71
|
+
- '92'
|
70
72
|
content-type:
|
71
73
|
- application/json; charset=utf-8
|
72
74
|
etag:
|
73
|
-
- '"
|
75
|
+
- '"5096b6af7b77b2a57d706dd1434b3970"'
|
74
76
|
cache-control:
|
75
77
|
- max-age=0, private, must-revalidate
|
76
78
|
x-request-id:
|
77
|
-
-
|
79
|
+
- 81b27380-7fc2-42dd-b974-e2c93f9d2315
|
78
80
|
x-runtime:
|
79
|
-
- '0.
|
81
|
+
- '0.645302'
|
80
82
|
connection:
|
81
83
|
- close
|
82
84
|
server:
|
83
85
|
- thin
|
84
86
|
body:
|
85
87
|
encoding: UTF-8
|
86
|
-
string: '[{"id":
|
88
|
+
string: '[{"id":1,"url":"http://quadernoapp.com","auth_key":"Ze024XpO9CJ6Fy2frwWV4Q","events_types":["invoice.created","expense.updated"],"last_sent_at":null,"last_error":null,"events_sent":0,"created_at":"2017-06-12T11:53:54.000Z","updated_at":"2017-06-12T11:53:54.000Z"},{"id":8,"url":"http://quadernoapp.com","auth_key":"JL-KguI89KWWPQfx-j_jVQ","events_types":["invoice.created","expense.updated"],"last_sent_at":null,"last_error":null,"events_sent":0,"created_at":"2017-06-12T11:54:33.000Z","updated_at":"2017-06-12T11:54:33.000Z"}]'
|
87
89
|
http_version: '1.1'
|
88
|
-
recorded_at:
|
90
|
+
recorded_at: Mon, 12 Jun 2017 11:54:34 GMT
|
89
91
|
- request:
|
90
92
|
method: put
|
91
|
-
uri: http://sk_test_B7xXrTspfeGukQqGN1pK@development.lvh.me:3000/api/webhooks/
|
93
|
+
uri: http://sk_test_B7xXrTspfeGukQqGN1pK@development.lvh.me:3000/api/webhooks/8.json
|
92
94
|
body:
|
93
95
|
encoding: UTF-8
|
94
|
-
string: events_types[
|
96
|
+
string: '{"events_types":["invoice.created","invoice.updated","contact.deleted"]}'
|
95
97
|
headers:
|
96
98
|
accept:
|
97
99
|
- application/json
|
100
|
+
content-type:
|
101
|
+
- application/json
|
98
102
|
authorization:
|
99
103
|
- Basic c2tfdGVzdF9CN3hYclRzcGZlR3VrUXFHTjFwSzo=
|
100
104
|
response:
|
@@ -107,31 +111,31 @@ http_interactions:
|
|
107
111
|
x-ratelimit-limit:
|
108
112
|
- '2000'
|
109
113
|
x-ratelimit-reset:
|
110
|
-
- '
|
114
|
+
- '4'
|
111
115
|
x-ratelimit-remaining:
|
112
|
-
- '
|
116
|
+
- '91'
|
113
117
|
content-type:
|
114
118
|
- application/json; charset=utf-8
|
115
119
|
etag:
|
116
|
-
- '"
|
120
|
+
- '"926cdf82d9b90ab6c43e3b76c7cbb096"'
|
117
121
|
cache-control:
|
118
122
|
- max-age=0, private, must-revalidate
|
119
123
|
x-request-id:
|
120
|
-
-
|
124
|
+
- 4ac6d2cf-c1e5-48fc-81e8-20f745a84040
|
121
125
|
x-runtime:
|
122
|
-
- '
|
126
|
+
- '1.871170'
|
123
127
|
connection:
|
124
128
|
- close
|
125
129
|
server:
|
126
130
|
- thin
|
127
131
|
body:
|
128
132
|
encoding: UTF-8
|
129
|
-
string: '{"id":
|
133
|
+
string: '{"id":8,"url":"http://quadernoapp.com","auth_key":"JL-KguI89KWWPQfx-j_jVQ","events_types":["invoice.created","invoice.updated","contact.deleted"],"last_sent_at":null,"last_error":null,"events_sent":0,"created_at":"2017-06-12T11:54:33.000Z","updated_at":"2017-06-12T11:54:36.369Z"}'
|
130
134
|
http_version: '1.1'
|
131
|
-
recorded_at:
|
135
|
+
recorded_at: Mon, 12 Jun 2017 11:54:36 GMT
|
132
136
|
- request:
|
133
137
|
method: delete
|
134
|
-
uri: http://sk_test_B7xXrTspfeGukQqGN1pK@development.lvh.me:3000/api/webhooks/
|
138
|
+
uri: http://sk_test_B7xXrTspfeGukQqGN1pK@development.lvh.me:3000/api/webhooks/8.json
|
135
139
|
body:
|
136
140
|
encoding: US-ASCII
|
137
141
|
string: ''
|
@@ -150,15 +154,15 @@ http_interactions:
|
|
150
154
|
x-ratelimit-limit:
|
151
155
|
- '2000'
|
152
156
|
x-ratelimit-reset:
|
153
|
-
- '
|
157
|
+
- '2'
|
154
158
|
x-ratelimit-remaining:
|
155
|
-
- '
|
159
|
+
- '90'
|
156
160
|
cache-control:
|
157
161
|
- no-cache
|
158
162
|
x-request-id:
|
159
|
-
-
|
163
|
+
- 70e6bc87-63f8-456a-a42f-3ac79d407e94
|
160
164
|
x-runtime:
|
161
|
-
- '0.
|
165
|
+
- '0.936896'
|
162
166
|
connection:
|
163
167
|
- close
|
164
168
|
server:
|
@@ -167,5 +171,5 @@ http_interactions:
|
|
167
171
|
encoding: US-ASCII
|
168
172
|
string: ''
|
169
173
|
http_version: '1.1'
|
170
|
-
recorded_at:
|
174
|
+
recorded_at: Mon, 12 Jun 2017 11:54:37 GMT
|
171
175
|
recorded_with: VCR 2.9.2
|
data/test/helper.rb
CHANGED
@@ -14,7 +14,7 @@ end
|
|
14
14
|
|
15
15
|
require 'vcr'
|
16
16
|
require 'test/unit'
|
17
|
-
require 'shoulda'
|
17
|
+
require 'shoulda-context'
|
18
18
|
require 'quaderno-ruby'
|
19
19
|
|
20
20
|
VCR.configure do |c|
|
@@ -25,6 +25,7 @@ end
|
|
25
25
|
|
26
26
|
TEST_URL = 'http://development.lvh.me:3000/api/'
|
27
27
|
TEST_KEY = 'sk_test_B7xXrTspfeGukQqGN1pK'
|
28
|
+
TEST_OAUTH_ACCESS_TOKEN = '36b82411e6686581fe3d7d10fbe931a3fdc9265a353832f0e3ff6269bd319e12'
|
28
29
|
OLDEST_SUPPORTED_API_VERSION = 20160602
|
29
30
|
|
30
31
|
class Test::Unit::TestCase
|
@@ -1,8 +1,8 @@
|
|
1
1
|
require 'helper'
|
2
2
|
|
3
3
|
class TestQuadernoContact < Test::Unit::TestCase
|
4
|
-
context 'A user with an authenticate token with contacts' do
|
5
4
|
|
5
|
+
context 'using the default configuration with an authentication token' do
|
6
6
|
setup do
|
7
7
|
Quaderno::Base.configure do |config|
|
8
8
|
config.auth_token = TEST_KEY
|
@@ -0,0 +1,104 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class TestQuadernoContactThreadSafe < Test::Unit::TestCase
|
4
|
+
context 'using the thread-safe configuration' do
|
5
|
+
context 'with an authentication token' do
|
6
|
+
should 'get all contacts (populated db)' do
|
7
|
+
VCR.use_cassette('all contacts by authentication token') do
|
8
|
+
puts Quaderno::Base.url
|
9
|
+
contacts = Quaderno::Contact.all(api_url: TEST_URL, auth_token: TEST_KEY)
|
10
|
+
assert_not_nil contacts
|
11
|
+
assert_kind_of Array, contacts
|
12
|
+
contacts.each { |contact| assert_kind_of Quaderno::Contact, contact }
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
should 'find a contact' do
|
17
|
+
VCR.use_cassette('found contact by authentication token') do
|
18
|
+
contacts = Quaderno::Contact.all(api_url: TEST_URL, auth_token: TEST_KEY)
|
19
|
+
contact = Quaderno::Contact.find contacts[2].id, api_url: TEST_URL, auth_token: TEST_KEY
|
20
|
+
assert_kind_of Quaderno::Contact, contact
|
21
|
+
assert_equal contacts[2].id, contact.id
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
should 'create a contact' do
|
26
|
+
VCR.use_cassette('new contact by authentication token') do
|
27
|
+
contact = Quaderno::Contact.create(kind: 'company', first_name: 'Test_Skynet', email: 'my_little@po.ny', api_url: TEST_URL, auth_token: TEST_KEY)
|
28
|
+
assert_kind_of Quaderno::Contact, contact
|
29
|
+
assert_equal 'company', contact.kind
|
30
|
+
assert_equal 'Test_Skynet', contact.full_name
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
should 'update a contact' do
|
35
|
+
VCR.use_cassette('updated contact by authentication token') do
|
36
|
+
contacts = Quaderno::Contact.all(api_url: TEST_URL, auth_token: TEST_KEY)
|
37
|
+
contact = Quaderno::Contact.update(contacts[2].id, first_name: 'Test_OCP', email: 'dont@stop.believing', api_url: TEST_URL, auth_token: TEST_KEY)
|
38
|
+
assert_kind_of Quaderno::Contact, contact
|
39
|
+
assert_equal 'Test_OCP', contact.first_name || contact.full_name
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
should 'delete a contact' do
|
44
|
+
VCR.use_cassette('deleted contact by authentication token') do
|
45
|
+
new_contact = Quaderno::Contact.create(kind: 'company', first_name: 'Z, Mazinger Z', email: 'koji@kabuto.ftw', api_url: TEST_URL, auth_token: TEST_KEY)
|
46
|
+
contacts_before = Quaderno::Contact.all(api_url: TEST_URL, auth_token: TEST_KEY)
|
47
|
+
contact_id = contacts_before.last.id
|
48
|
+
Quaderno::Contact.delete contact_id, api_url: TEST_URL, auth_token: TEST_KEY
|
49
|
+
contacts_after = Quaderno::Contact.all(api_url: TEST_URL, auth_token: TEST_KEY)
|
50
|
+
assert_not_equal contacts_after.last.id, contact_id
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
context 'with an OAuth 2.0 access token' do
|
56
|
+
should 'get all contacts (populated db)' do
|
57
|
+
VCR.use_cassette('all contacts by access token') do
|
58
|
+
contacts = Quaderno::Contact.all(api_url: TEST_URL, access_token: TEST_OAUTH_ACCESS_TOKEN)
|
59
|
+
assert_not_nil contacts
|
60
|
+
assert_kind_of Array, contacts
|
61
|
+
contacts.each { |contact| assert_kind_of Quaderno::Contact, contact }
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
should 'find a contact' do
|
66
|
+
VCR.use_cassette('found contact by access token') do
|
67
|
+
contacts = Quaderno::Contact.all(api_url: TEST_URL, access_token: TEST_OAUTH_ACCESS_TOKEN)
|
68
|
+
contact = Quaderno::Contact.find contacts[2].id, api_url: TEST_URL, access_token: TEST_OAUTH_ACCESS_TOKEN
|
69
|
+
assert_kind_of Quaderno::Contact, contact
|
70
|
+
assert_equal contacts[2].id, contact.id
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
should 'create a contact' do
|
75
|
+
VCR.use_cassette('new contact by access token') do
|
76
|
+
contact = Quaderno::Contact.create(kind: 'company', first_name: 'Test_Skynet', email: 'my_little@po.ny', api_url: TEST_URL, access_token: TEST_OAUTH_ACCESS_TOKEN)
|
77
|
+
assert_kind_of Quaderno::Contact, contact
|
78
|
+
assert_equal 'company', contact.kind
|
79
|
+
assert_equal 'Test_Skynet', contact.full_name
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
should 'update a contact' do
|
84
|
+
VCR.use_cassette('updated contact by access token') do
|
85
|
+
contacts = Quaderno::Contact.all(api_url: TEST_URL, access_token: TEST_OAUTH_ACCESS_TOKEN)
|
86
|
+
contact = Quaderno::Contact.update(contacts[2].id, first_name: 'Test_OCP', email: 'dont@stop.believing', api_url: TEST_URL, access_token: TEST_OAUTH_ACCESS_TOKEN)
|
87
|
+
assert_kind_of Quaderno::Contact, contact
|
88
|
+
assert_equal 'Test_OCP', contact.first_name || contact.full_name
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
should 'delete a contact' do
|
93
|
+
VCR.use_cassette('deleted contact by access token') do
|
94
|
+
new_contact = Quaderno::Contact.create(kind: 'company', first_name: 'Z, Mazinger Z', email: 'koji@kabuto.ftw', api_url: TEST_URL, access_token: TEST_OAUTH_ACCESS_TOKEN)
|
95
|
+
contacts_before = Quaderno::Contact.all(api_url: TEST_URL, access_token: TEST_OAUTH_ACCESS_TOKEN)
|
96
|
+
contact_id = contacts_before.last.id
|
97
|
+
Quaderno::Contact.delete contact_id, api_url: TEST_URL, access_token: TEST_OAUTH_ACCESS_TOKEN
|
98
|
+
contacts_after = Quaderno::Contact.all(api_url: TEST_URL, access_token: TEST_OAUTH_ACCESS_TOKEN)
|
99
|
+
assert_not_equal contacts_after.last.id, contact_id
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
@@ -69,8 +69,8 @@ class TestQuadernoExpense < Test::Unit::TestCase
|
|
69
69
|
|
70
70
|
should 'update an expense' do
|
71
71
|
VCR.use_cassette('updated expense') do
|
72
|
-
|
73
|
-
|
72
|
+
contacts = Quaderno::Contact.all
|
73
|
+
expense = Quaderno::Expense.create(contact_id: contacts.first.id ,
|
74
74
|
contact_name: contacts.first.full_name,
|
75
75
|
currency: 'EUR',
|
76
76
|
items_attributes: [
|
@@ -82,9 +82,9 @@ class TestQuadernoExpense < Test::Unit::TestCase
|
|
82
82
|
],
|
83
83
|
tags: 'tnt', payment_details: '',
|
84
84
|
notes: '')
|
85
|
-
expense = Quaderno::Expense.update(expense.id,
|
85
|
+
expense = Quaderno::Expense.update(expense.id, po_number: 'Updated expense!')
|
86
86
|
assert_kind_of Quaderno::Expense, expense
|
87
|
-
assert_equal '
|
87
|
+
assert_equal 'Updated expense!', expense.po_number
|
88
88
|
Quaderno::Expense.delete(expense.id)
|
89
89
|
end
|
90
90
|
end
|
@@ -127,7 +127,7 @@ class TestQuadernoExpense < Test::Unit::TestCase
|
|
127
127
|
expenses.first.add_payment(payment_method: "cash", amount: "10000")
|
128
128
|
payment = expenses.first.payments.last
|
129
129
|
array_length = expenses.first.payments.length
|
130
|
-
expenses.first.remove_payment(payment.id)
|
130
|
+
expenses.first.remove_payment(payment.id)
|
131
131
|
assert_equal (array_length.zero? ? array_length : array_length-1), expenses.first.payments.length
|
132
132
|
end
|
133
133
|
end
|