quaderno 1.4.2 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +27 -1
- data/VERSION +1 -1
- data/changelog.md +7 -0
- data/lib/quaderno-ruby.rb +1 -1
- data/lib/quaderno-ruby/exceptions/exceptions.rb +2 -1
- data/lib/quaderno-ruby/transaction.rb +11 -0
- data/quaderno.gemspec +8 -3
- data/test/fixtures/quaderno_cassettes/deleted_transaction.yml +158 -0
- data/test/fixtures/quaderno_cassettes/found_transaction.yml +56 -0
- data/test/fixtures/quaderno_cassettes/new_transaction.yml +168 -0
- data/test/unit/test_quaderno_transactions.rb +78 -0
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dee08493d1d68c2cc8cbb7473fa52ac770b80733
|
4
|
+
data.tar.gz: fd637ff0b65e876a1df65876b3aafb84cebe7ced
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 08e2bd45a1473d822b39fbfed326d441c499307ed0cbfd59ec943e03a72f4b2842a8c92cb7569e7d03521746164f3cb0512608ba0e7e6ff6eb00667e52f045bf
|
7
|
+
data.tar.gz: 761cfc47e41567b74d15525c70d19e32886024ec588a4de40fa39be75716edb4a95a90144207cdb92cbb4dd8dcd580b32563a8aeb1607eb6ae44fc39a523f701
|
data/README.md
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
Quaderno-ruby is a ruby wrapper for [Quaderno API] (https://github.com/quaderno/quaderno-api).
|
4
4
|
As the API, it's mostly CRUD.
|
5
5
|
|
6
|
-
Current version is 1.
|
6
|
+
Current version is 1.5.0. See the changelog [here](https://github.com/quaderno/quaderno-ruby/blob/master/changelog.md)
|
7
7
|
|
8
8
|
## Installation & Configuration
|
9
9
|
|
@@ -355,6 +355,32 @@ will update the specified webhook with the data of the hash passed as second par
|
|
355
355
|
```ruby
|
356
356
|
Quaderno::Webhook.delete(id) #=> Boolean
|
357
357
|
```
|
358
|
+
will delete the webhook with the id passed as parameter.
|
359
|
+
|
360
|
+
|
361
|
+
## Managing transactions
|
362
|
+
|
363
|
+
### Finding a transaction
|
364
|
+
```ruby
|
365
|
+
Quaderno::Transaction.find(id) #=> Quaderno::Transaction
|
366
|
+
```
|
367
|
+
|
368
|
+
will return the transaction with the id passed as parameter.
|
369
|
+
|
370
|
+
### Creating a new transaction
|
371
|
+
```ruby
|
372
|
+
Quaderno::Transaction.create(params) #=> Quaderno::Transaction
|
373
|
+
```
|
374
|
+
|
375
|
+
will create a transaction using the information of the hash passed as parameter and return an instance of Quaderno::Transaction with the created transaction.
|
376
|
+
|
377
|
+
|
378
|
+
### Deleting a transaction
|
379
|
+
```ruby
|
380
|
+
Quaderno::Transaction.delete(id) #=> Boolean
|
381
|
+
```
|
382
|
+
will delete the transaction with the id passed as parameter.
|
383
|
+
|
358
384
|
|
359
385
|
## Taxes
|
360
386
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.5.0
|
data/changelog.md
CHANGED
data/lib/quaderno-ruby.rb
CHANGED
@@ -2,7 +2,7 @@ require 'ostruct'
|
|
2
2
|
|
3
3
|
require 'quaderno-ruby/exceptions/exceptions'
|
4
4
|
%w(crud deliver payment).each { |filename| require "quaderno-ruby/behavior/#{ filename }" }
|
5
|
-
%w(base contact item invoice estimate expense document_item payment webhook tax).each { |filename| require "quaderno-ruby/#{ filename }" }
|
5
|
+
%w(base contact item invoice estimate expense document_item payment webhook tax transaction).each { |filename| require "quaderno-ruby/#{ filename }" }
|
6
6
|
|
7
7
|
module Quaderno
|
8
8
|
|
@@ -30,8 +30,9 @@ module Quaderno
|
|
30
30
|
if params[:id].nil? == false
|
31
31
|
raise(Quaderno::Exceptions::InvalidID, "Invalid #{ api_model } instance identifier") if (party_response.response.class == Net::HTTPInternalServerError) || (party_response.response.class == Net::HTTPNotFound)
|
32
32
|
end
|
33
|
+
debugger
|
33
34
|
if params[:required_fields].nil? == false
|
34
|
-
raise(Quaderno::Exceptions::RequiredFieldsEmpty, "#{ JSON::parse party_response.body }") if party_response.response.class == Net::
|
35
|
+
raise(Quaderno::Exceptions::RequiredFieldsEmpty, "#{ JSON::parse party_response.body }") if party_response.response.class == Net::HTTPUnprocessableEntity
|
35
36
|
end
|
36
37
|
if params[:has_documents].nil? == false
|
37
38
|
raise(Quaderno::Exceptions::HasAssociatedDocuments, "#{ JSON::parse party_response.body }") if party_response.response.class == Net::HTTPClientError
|
data/quaderno.gemspec
CHANGED
@@ -2,16 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: quaderno 1.
|
5
|
+
# stub: quaderno 1.5.0 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "quaderno"
|
9
|
-
s.version = "1.
|
9
|
+
s.version = "1.5.0"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|
13
13
|
s.authors = ["Recrea"]
|
14
|
-
s.date = "2014-12-
|
14
|
+
s.date = "2014-12-09"
|
15
15
|
s.description = " A ruby wrapper for Quaderno API "
|
16
16
|
s.email = "carlos@recrea.es"
|
17
17
|
s.extra_rdoc_files = [
|
@@ -42,6 +42,7 @@ Gem::Specification.new do |s|
|
|
42
42
|
"lib/quaderno-ruby/item.rb",
|
43
43
|
"lib/quaderno-ruby/payment.rb",
|
44
44
|
"lib/quaderno-ruby/tax.rb",
|
45
|
+
"lib/quaderno-ruby/transaction.rb",
|
45
46
|
"lib/quaderno-ruby/webhook.rb",
|
46
47
|
"quaderno.gemspec",
|
47
48
|
"test/fixtures/quaderno_cassettes/.DS_Store",
|
@@ -57,6 +58,7 @@ Gem::Specification.new do |s|
|
|
57
58
|
"test/fixtures/quaderno_cassettes/deleted_expense.yml",
|
58
59
|
"test/fixtures/quaderno_cassettes/deleted_invoice.yml",
|
59
60
|
"test/fixtures/quaderno_cassettes/deleted_item.yml",
|
61
|
+
"test/fixtures/quaderno_cassettes/deleted_transaction.yml",
|
60
62
|
"test/fixtures/quaderno_cassettes/deleted_webhook.yml",
|
61
63
|
"test/fixtures/quaderno_cassettes/delivered_estimate.yml",
|
62
64
|
"test/fixtures/quaderno_cassettes/delivered_invoice.yml",
|
@@ -65,12 +67,14 @@ Gem::Specification.new do |s|
|
|
65
67
|
"test/fixtures/quaderno_cassettes/found_expense.yml",
|
66
68
|
"test/fixtures/quaderno_cassettes/found_invoice.yml",
|
67
69
|
"test/fixtures/quaderno_cassettes/found_item.yml",
|
70
|
+
"test/fixtures/quaderno_cassettes/found_transaction.yml",
|
68
71
|
"test/fixtures/quaderno_cassettes/found_webhook.yml",
|
69
72
|
"test/fixtures/quaderno_cassettes/new_contact.yml",
|
70
73
|
"test/fixtures/quaderno_cassettes/new_estimate.yml",
|
71
74
|
"test/fixtures/quaderno_cassettes/new_expense.yml",
|
72
75
|
"test/fixtures/quaderno_cassettes/new_invoice.yml",
|
73
76
|
"test/fixtures/quaderno_cassettes/new_item.yml",
|
77
|
+
"test/fixtures/quaderno_cassettes/new_transaction.yml",
|
74
78
|
"test/fixtures/quaderno_cassettes/new_webhook.yml",
|
75
79
|
"test/fixtures/quaderno_cassettes/paid_expense.yml",
|
76
80
|
"test/fixtures/quaderno_cassettes/paid_invoice.yml",
|
@@ -91,6 +95,7 @@ Gem::Specification.new do |s|
|
|
91
95
|
"test/unit/test_quaderno_invoices.rb",
|
92
96
|
"test/unit/test_quaderno_items.rb",
|
93
97
|
"test/unit/test_quaderno_tax.rb",
|
98
|
+
"test/unit/test_quaderno_transactions.rb",
|
94
99
|
"test/unit/test_quaderno_webhooks.rb"
|
95
100
|
]
|
96
101
|
s.homepage = "http://github.com/quaderno/quaderno-ruby"
|
@@ -0,0 +1,158 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: http://rkHqiPxs4VFHgtqqjYqw@test-account.sandbox-quadernoapp.com/api/v1/transactions.json
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: country=ES&postal_code=08080&iin=424242&amount=1200&ip=85.155.156.215
|
9
|
+
headers:
|
10
|
+
authorization:
|
11
|
+
- Basic cmtIcWlQeHM0VkZIZ3RxcWpZcXc6
|
12
|
+
response:
|
13
|
+
status:
|
14
|
+
code: 200
|
15
|
+
message: OK
|
16
|
+
headers:
|
17
|
+
server:
|
18
|
+
- nginx/1.6.2
|
19
|
+
date:
|
20
|
+
- Thu, 04 Dec 2014 13:54:30 GMT
|
21
|
+
content-type:
|
22
|
+
- application/json; charset=utf-8
|
23
|
+
transfer-encoding:
|
24
|
+
- chunked
|
25
|
+
connection:
|
26
|
+
- close
|
27
|
+
status:
|
28
|
+
- 200 OK
|
29
|
+
x-ratelimit-limit:
|
30
|
+
- '2000'
|
31
|
+
x-ratelimit-remaining:
|
32
|
+
- '1895'
|
33
|
+
x-ua-compatible:
|
34
|
+
- IE=Edge,chrome=1
|
35
|
+
etag:
|
36
|
+
- '"f285f54b8a0f537224daee598b6711d4"'
|
37
|
+
cache-control:
|
38
|
+
- max-age=0, private, must-revalidate
|
39
|
+
set-cookie:
|
40
|
+
- ahoy_visitor=0630f037-52d1-40b9-91b9-064ff28c4fc9; domain=.sandbox-quadernoapp.com;
|
41
|
+
path=/; expires=Sun, 04-Dec-2016 13:54:27 GMT
|
42
|
+
- ahoy_visit=a2d8164e-1d18-440c-8aa8-a3e6f5f897aa; domain=.sandbox-quadernoapp.com;
|
43
|
+
path=/; expires=Thu, 04-Dec-2014 17:54:27 GMT
|
44
|
+
- ahoy_track=true; domain=.sandbox-quadernoapp.com; path=/
|
45
|
+
- _quaderno_session=BAh7BkkiD3Nlc3Npb25faWQGOgZFVEkiJTczYzAwMTM2M2Q2YzYwYTIzOWQyMzJlZDhjYWFiMjQ2BjsAVA%3D%3D--bcf144190c60c41ad50a5cf50ae775ab7c6049d4;
|
46
|
+
domain=sandbox-quadernoapp.com; path=/; HttpOnly
|
47
|
+
x-request-id:
|
48
|
+
- 513e1c32a3e2153376043b94b713be4c
|
49
|
+
x-runtime:
|
50
|
+
- '2.340178'
|
51
|
+
x-rack-cache:
|
52
|
+
- invalidate, pass
|
53
|
+
body:
|
54
|
+
encoding: UTF-8
|
55
|
+
string: '{"id":37,"tax_name":null,"tax_rate":0.0,"amount":1200,"tax_amount":0,"total_amount":1200}'
|
56
|
+
http_version: '1.1'
|
57
|
+
recorded_at: Thu, 04 Dec 2014 13:54:30 GMT
|
58
|
+
- request:
|
59
|
+
method: delete
|
60
|
+
uri: http://rkHqiPxs4VFHgtqqjYqw@test-account.sandbox-quadernoapp.com/api/v1/transactions/37.json
|
61
|
+
body:
|
62
|
+
encoding: US-ASCII
|
63
|
+
string: ''
|
64
|
+
headers:
|
65
|
+
authorization:
|
66
|
+
- Basic cmtIcWlQeHM0VkZIZ3RxcWpZcXc6
|
67
|
+
response:
|
68
|
+
status:
|
69
|
+
code: 204
|
70
|
+
message: No Content
|
71
|
+
headers:
|
72
|
+
server:
|
73
|
+
- nginx/1.6.2
|
74
|
+
date:
|
75
|
+
- Thu, 04 Dec 2014 13:54:30 GMT
|
76
|
+
connection:
|
77
|
+
- close
|
78
|
+
status:
|
79
|
+
- 204 No Content
|
80
|
+
x-ratelimit-limit:
|
81
|
+
- '2000'
|
82
|
+
x-ratelimit-remaining:
|
83
|
+
- '1894'
|
84
|
+
x-ua-compatible:
|
85
|
+
- IE=Edge,chrome=1
|
86
|
+
cache-control:
|
87
|
+
- no-cache
|
88
|
+
set-cookie:
|
89
|
+
- ahoy_visitor=0acea62b-ccc1-4889-b7e9-4390320ea7f5; domain=.sandbox-quadernoapp.com;
|
90
|
+
path=/; expires=Sun, 04-Dec-2016 13:54:30 GMT
|
91
|
+
- ahoy_visit=f306e6e8-1ebb-4c54-8312-9cebe4f2b325; domain=.sandbox-quadernoapp.com;
|
92
|
+
path=/; expires=Thu, 04-Dec-2014 17:54:30 GMT
|
93
|
+
- ahoy_track=true; domain=.sandbox-quadernoapp.com; path=/
|
94
|
+
- _quaderno_session=BAh7BkkiD3Nlc3Npb25faWQGOgZFVEkiJWVhYTdiYmU4NmM1ZmY0NGZlZGZhMjM1N2RiODc0YjM1BjsAVA%3D%3D--ef2532e2bad0d52b6a962453dd8ad4873a9cde24;
|
95
|
+
domain=sandbox-quadernoapp.com; path=/; HttpOnly
|
96
|
+
x-request-id:
|
97
|
+
- ba917f6dad1bdba6691958701dda500b
|
98
|
+
x-runtime:
|
99
|
+
- '0.059911'
|
100
|
+
x-rack-cache:
|
101
|
+
- invalidate, pass
|
102
|
+
body:
|
103
|
+
encoding: US-ASCII
|
104
|
+
string: ''
|
105
|
+
http_version: '1.1'
|
106
|
+
recorded_at: Thu, 04 Dec 2014 13:54:30 GMT
|
107
|
+
- request:
|
108
|
+
method: get
|
109
|
+
uri: http://rkHqiPxs4VFHgtqqjYqw@test-account.sandbox-quadernoapp.com/api/v1/transactions/37.json
|
110
|
+
body:
|
111
|
+
encoding: US-ASCII
|
112
|
+
string: ''
|
113
|
+
headers:
|
114
|
+
authorization:
|
115
|
+
- Basic cmtIcWlQeHM0VkZIZ3RxcWpZcXc6
|
116
|
+
response:
|
117
|
+
status:
|
118
|
+
code: 401
|
119
|
+
message: Unauthorized
|
120
|
+
headers:
|
121
|
+
server:
|
122
|
+
- nginx/1.6.2
|
123
|
+
date:
|
124
|
+
- Thu, 04 Dec 2014 13:54:31 GMT
|
125
|
+
content-type:
|
126
|
+
- application/json; charset=utf-8
|
127
|
+
transfer-encoding:
|
128
|
+
- chunked
|
129
|
+
connection:
|
130
|
+
- close
|
131
|
+
status:
|
132
|
+
- 401 Unauthorized
|
133
|
+
x-ratelimit-limit:
|
134
|
+
- '2000'
|
135
|
+
x-ratelimit-remaining:
|
136
|
+
- '1893'
|
137
|
+
x-ua-compatible:
|
138
|
+
- IE=Edge,chrome=1
|
139
|
+
cache-control:
|
140
|
+
- no-cache, private
|
141
|
+
set-cookie:
|
142
|
+
- ahoy_visitor=35e27e33-a940-4f0e-99ac-69428b49a0a7; domain=.sandbox-quadernoapp.com;
|
143
|
+
path=/; expires=Sun, 04-Dec-2016 13:54:31 GMT
|
144
|
+
- ahoy_visit=63e91bd4-65ce-4425-9fa5-b9185fda6785; domain=.sandbox-quadernoapp.com;
|
145
|
+
path=/; expires=Thu, 04-Dec-2014 17:54:31 GMT
|
146
|
+
- ahoy_track=true; domain=.sandbox-quadernoapp.com; path=/
|
147
|
+
x-request-id:
|
148
|
+
- 14c73e0c11b8e38324bbd94d112fe68f
|
149
|
+
x-runtime:
|
150
|
+
- '0.044463'
|
151
|
+
x-rack-cache:
|
152
|
+
- miss
|
153
|
+
body:
|
154
|
+
encoding: UTF-8
|
155
|
+
string: '{"error":"Unauthorized access or transaction does not exist."}'
|
156
|
+
http_version: '1.1'
|
157
|
+
recorded_at: Thu, 04 Dec 2014 13:54:31 GMT
|
158
|
+
recorded_with: VCR 2.9.2
|
@@ -0,0 +1,56 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: http://rkHqiPxs4VFHgtqqjYqw@test-account.sandbox-quadernoapp.com/api/v1/transactions/18.json
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
authorization:
|
11
|
+
- Basic cmtIcWlQeHM0VkZIZ3RxcWpZcXc6
|
12
|
+
response:
|
13
|
+
status:
|
14
|
+
code: 200
|
15
|
+
message: OK
|
16
|
+
headers:
|
17
|
+
server:
|
18
|
+
- nginx/1.6.2
|
19
|
+
date:
|
20
|
+
- Thu, 04 Dec 2014 13:45:20 GMT
|
21
|
+
content-type:
|
22
|
+
- application/json; charset=utf-8
|
23
|
+
transfer-encoding:
|
24
|
+
- chunked
|
25
|
+
connection:
|
26
|
+
- close
|
27
|
+
status:
|
28
|
+
- 200 OK
|
29
|
+
x-ratelimit-limit:
|
30
|
+
- '2000'
|
31
|
+
x-ratelimit-remaining:
|
32
|
+
- '1901'
|
33
|
+
last-modified:
|
34
|
+
- Thu, 04 Dec 2014 12:14:01 GMT
|
35
|
+
cache-control:
|
36
|
+
- must-revalidate, private, max-age=0
|
37
|
+
x-ua-compatible:
|
38
|
+
- IE=Edge,chrome=1
|
39
|
+
set-cookie:
|
40
|
+
- ahoy_visitor=a3a7ea1f-ae44-4804-8509-5b901d685a9f; domain=.sandbox-quadernoapp.com;
|
41
|
+
path=/; expires=Sun, 04-Dec-2016 13:45:20 GMT
|
42
|
+
- ahoy_visit=d449d294-6f7f-4c4c-8710-d0db6010e863; domain=.sandbox-quadernoapp.com;
|
43
|
+
path=/; expires=Thu, 04-Dec-2014 17:45:20 GMT
|
44
|
+
- ahoy_track=true; domain=.sandbox-quadernoapp.com; path=/
|
45
|
+
x-request-id:
|
46
|
+
- 0c57a4f541a26832504285c5d15beb76
|
47
|
+
x-runtime:
|
48
|
+
- '0.056580'
|
49
|
+
x-rack-cache:
|
50
|
+
- miss
|
51
|
+
body:
|
52
|
+
encoding: UTF-8
|
53
|
+
string: '{"id":18,"tax_name":"IGIC","tax_rate":7.0,"amount":1200,"tax_amount":84,"total_amount":1284}'
|
54
|
+
http_version: '1.1'
|
55
|
+
recorded_at: Thu, 04 Dec 2014 13:45:20 GMT
|
56
|
+
recorded_with: VCR 2.9.2
|
@@ -0,0 +1,168 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: http://rkHqiPxs4VFHgtqqjYqw@test-account.sandbox-quadernoapp.com/api/v1/transactions.json
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: country=ES&postal_code=35003&iin=424242&amount=1200&ip=85.155.157.215
|
9
|
+
headers:
|
10
|
+
authorization:
|
11
|
+
- Basic cmtIcWlQeHM0VkZIZ3RxcWpZcXc6
|
12
|
+
response:
|
13
|
+
status:
|
14
|
+
code: 200
|
15
|
+
message: OK
|
16
|
+
headers:
|
17
|
+
server:
|
18
|
+
- nginx/1.6.2
|
19
|
+
date:
|
20
|
+
- Thu, 04 Dec 2014 13:45:16 GMT
|
21
|
+
content-type:
|
22
|
+
- application/json; charset=utf-8
|
23
|
+
transfer-encoding:
|
24
|
+
- chunked
|
25
|
+
connection:
|
26
|
+
- close
|
27
|
+
status:
|
28
|
+
- 200 OK
|
29
|
+
x-ratelimit-limit:
|
30
|
+
- '2000'
|
31
|
+
x-ratelimit-remaining:
|
32
|
+
- '1907'
|
33
|
+
x-ua-compatible:
|
34
|
+
- IE=Edge,chrome=1
|
35
|
+
etag:
|
36
|
+
- '"8e364ca38768f22d2a62dc71be9c223b"'
|
37
|
+
cache-control:
|
38
|
+
- max-age=0, private, must-revalidate
|
39
|
+
set-cookie:
|
40
|
+
- ahoy_visitor=56c36791-5d3b-4f3f-ab5b-99fb0eab2f54; domain=.sandbox-quadernoapp.com;
|
41
|
+
path=/; expires=Sun, 04-Dec-2016 13:45:16 GMT
|
42
|
+
- ahoy_visit=788482b8-87f7-4247-a2d5-840baa45f0ea; domain=.sandbox-quadernoapp.com;
|
43
|
+
path=/; expires=Thu, 04-Dec-2014 17:45:16 GMT
|
44
|
+
- ahoy_track=true; domain=.sandbox-quadernoapp.com; path=/
|
45
|
+
- _quaderno_session=BAh7BkkiD3Nlc3Npb25faWQGOgZFVEkiJTgxZGFkZTY1ZThiZGZjMDljZDI1ZWRkODUxNjA1YzkyBjsAVA%3D%3D--0664177c24eccb156a3e29262d479738760f0fce;
|
46
|
+
domain=sandbox-quadernoapp.com; path=/; HttpOnly
|
47
|
+
x-request-id:
|
48
|
+
- a4dccd55e77728154d72e4a81ca87084
|
49
|
+
x-runtime:
|
50
|
+
- '0.217282'
|
51
|
+
x-rack-cache:
|
52
|
+
- invalidate, pass
|
53
|
+
body:
|
54
|
+
encoding: UTF-8
|
55
|
+
string: '{"id":33,"tax_name":"IGIC","tax_rate":7.0,"amount":1200,"tax_amount":84,"total_amount":1284}'
|
56
|
+
http_version: '1.1'
|
57
|
+
recorded_at: Thu, 04 Dec 2014 13:45:16 GMT
|
58
|
+
- request:
|
59
|
+
method: post
|
60
|
+
uri: http://rkHqiPxs4VFHgtqqjYqw@test-account.sandbox-quadernoapp.com/api/v1/transactions.json
|
61
|
+
body:
|
62
|
+
encoding: UTF-8
|
63
|
+
string: country=ES&postal_code=35003&iin=424242&amount=1200&ip=85.155.157.215
|
64
|
+
headers:
|
65
|
+
authorization:
|
66
|
+
- Basic cmtIcWlQeHM0VkZIZ3RxcWpZcXc6
|
67
|
+
response:
|
68
|
+
status:
|
69
|
+
code: 200
|
70
|
+
message: OK
|
71
|
+
headers:
|
72
|
+
server:
|
73
|
+
- nginx/1.6.2
|
74
|
+
date:
|
75
|
+
- Thu, 04 Dec 2014 13:45:17 GMT
|
76
|
+
content-type:
|
77
|
+
- application/json; charset=utf-8
|
78
|
+
transfer-encoding:
|
79
|
+
- chunked
|
80
|
+
connection:
|
81
|
+
- close
|
82
|
+
status:
|
83
|
+
- 200 OK
|
84
|
+
x-ratelimit-limit:
|
85
|
+
- '2000'
|
86
|
+
x-ratelimit-remaining:
|
87
|
+
- '1906'
|
88
|
+
x-ua-compatible:
|
89
|
+
- IE=Edge,chrome=1
|
90
|
+
etag:
|
91
|
+
- '"4b5cced371158aa38def383d8f0bfb5a"'
|
92
|
+
cache-control:
|
93
|
+
- max-age=0, private, must-revalidate
|
94
|
+
set-cookie:
|
95
|
+
- ahoy_visitor=40bd7748-a4ab-4436-9b66-ea47a0010947; domain=.sandbox-quadernoapp.com;
|
96
|
+
path=/; expires=Sun, 04-Dec-2016 13:45:17 GMT
|
97
|
+
- ahoy_visit=59defdfa-8952-4734-ae0e-94bdda1faaae; domain=.sandbox-quadernoapp.com;
|
98
|
+
path=/; expires=Thu, 04-Dec-2014 17:45:17 GMT
|
99
|
+
- ahoy_track=true; domain=.sandbox-quadernoapp.com; path=/
|
100
|
+
- _quaderno_session=BAh7BkkiD3Nlc3Npb25faWQGOgZFVEkiJWQ5MmJkNGQzNTkzNzc4NGYwYzM1MjNhNzVmZjc1NTAyBjsAVA%3D%3D--45933484fbb855cd8227c0f49e84b4e9a9ca2c9b;
|
101
|
+
domain=sandbox-quadernoapp.com; path=/; HttpOnly
|
102
|
+
x-request-id:
|
103
|
+
- 914fde2d81b31656f5b3e4ac46654380
|
104
|
+
x-runtime:
|
105
|
+
- '0.166646'
|
106
|
+
x-rack-cache:
|
107
|
+
- invalidate, pass
|
108
|
+
body:
|
109
|
+
encoding: UTF-8
|
110
|
+
string: '{"id":34,"tax_name":"IGIC","tax_rate":7.0,"amount":1200,"tax_amount":84,"total_amount":1284}'
|
111
|
+
http_version: '1.1'
|
112
|
+
recorded_at: Thu, 04 Dec 2014 13:45:17 GMT
|
113
|
+
- request:
|
114
|
+
method: post
|
115
|
+
uri: http://rkHqiPxs4VFHgtqqjYqw@test-account.sandbox-quadernoapp.com/api/v1/transactions.json
|
116
|
+
body:
|
117
|
+
encoding: UTF-8
|
118
|
+
string: country=ES&postal_code=08080&iin=424242&amount=1200&ip=85.155.156.215
|
119
|
+
headers:
|
120
|
+
authorization:
|
121
|
+
- Basic cmtIcWlQeHM0VkZIZ3RxcWpZcXc6
|
122
|
+
response:
|
123
|
+
status:
|
124
|
+
code: 200
|
125
|
+
message: OK
|
126
|
+
headers:
|
127
|
+
server:
|
128
|
+
- nginx/1.6.2
|
129
|
+
date:
|
130
|
+
- Thu, 04 Dec 2014 13:45:17 GMT
|
131
|
+
content-type:
|
132
|
+
- application/json; charset=utf-8
|
133
|
+
transfer-encoding:
|
134
|
+
- chunked
|
135
|
+
connection:
|
136
|
+
- close
|
137
|
+
status:
|
138
|
+
- 200 OK
|
139
|
+
x-ratelimit-limit:
|
140
|
+
- '2000'
|
141
|
+
x-ratelimit-remaining:
|
142
|
+
- '1905'
|
143
|
+
x-ua-compatible:
|
144
|
+
- IE=Edge,chrome=1
|
145
|
+
etag:
|
146
|
+
- '"edc2c6a6a28827d40c387eab9e9c8366"'
|
147
|
+
cache-control:
|
148
|
+
- max-age=0, private, must-revalidate
|
149
|
+
set-cookie:
|
150
|
+
- ahoy_visitor=25850cb6-d521-4d42-835c-9107ec548daf; domain=.sandbox-quadernoapp.com;
|
151
|
+
path=/; expires=Sun, 04-Dec-2016 13:45:17 GMT
|
152
|
+
- ahoy_visit=9faf49c4-5639-4869-aced-81da1a6e3073; domain=.sandbox-quadernoapp.com;
|
153
|
+
path=/; expires=Thu, 04-Dec-2014 17:45:17 GMT
|
154
|
+
- ahoy_track=true; domain=.sandbox-quadernoapp.com; path=/
|
155
|
+
- _quaderno_session=BAh7BkkiD3Nlc3Npb25faWQGOgZFVEkiJTVlMzg1ZGZmOWZhZGEzODJhNjk0ZjEyY2VhYjUxYzg3BjsAVA%3D%3D--379bbbe281b0dfbf0766879837ff3d2d7b931a9b;
|
156
|
+
domain=sandbox-quadernoapp.com; path=/; HttpOnly
|
157
|
+
x-request-id:
|
158
|
+
- cf6bc554b8f0659e2595c5dd7e6ff7a9
|
159
|
+
x-runtime:
|
160
|
+
- '0.167067'
|
161
|
+
x-rack-cache:
|
162
|
+
- invalidate, pass
|
163
|
+
body:
|
164
|
+
encoding: UTF-8
|
165
|
+
string: '{"id":35,"tax_name":null,"tax_rate":0.0,"amount":1200,"tax_amount":0,"total_amount":1200}'
|
166
|
+
http_version: '1.1'
|
167
|
+
recorded_at: Thu, 04 Dec 2014 13:45:18 GMT
|
168
|
+
recorded_with: VCR 2.9.2
|
@@ -0,0 +1,78 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class TestQuadernoTransaction < Test::Unit::TestCase
|
4
|
+
context "A user with an authenticate token with transactions" do
|
5
|
+
|
6
|
+
setup do
|
7
|
+
Quaderno::Base.configure do |config|
|
8
|
+
config.auth_token = 'rkHqiPxs4VFHgtqqjYqw'
|
9
|
+
config.subdomain = 'test-account'
|
10
|
+
config.environment = :sandbox
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
should "get exception if pass wrong arguments" do
|
15
|
+
assert_raise ArgumentError do
|
16
|
+
VCR.use_cassette('found transaction') do
|
17
|
+
Quaderno::Transaction.find
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
should "find a transaction" do
|
23
|
+
VCR.use_cassette('found transaction') do
|
24
|
+
transaction = Quaderno::Transaction.find 18
|
25
|
+
|
26
|
+
assert_kind_of Quaderno::Transaction, transaction
|
27
|
+
assert_equal "IGIC", transaction.tax_name
|
28
|
+
assert_equal 7.0, transaction.tax_rate
|
29
|
+
assert_equal 1200, transaction.amount
|
30
|
+
assert_equal 84, transaction.tax_amount
|
31
|
+
assert_equal 1284, transaction.total_amount
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
should "create a transaction" do
|
36
|
+
VCR.use_cassette('new transaction') do
|
37
|
+
#Canarian company to a canarian consumer
|
38
|
+
transaction = Quaderno::Transaction.create(country: 'ES', postal_code: '35003', iin: '424242', amount: 1200, ip: '85.155.157.215')
|
39
|
+
|
40
|
+
assert_kind_of Quaderno::Transaction, transaction
|
41
|
+
assert_equal "IGIC", transaction.tax_name
|
42
|
+
assert_equal 7.0, transaction.tax_rate
|
43
|
+
assert_equal 1200, transaction.amount
|
44
|
+
assert_equal 84, transaction.tax_amount
|
45
|
+
assert_equal 1284, transaction.total_amount
|
46
|
+
|
47
|
+
transaction = Quaderno::Transaction.create(country: 'ES', postal_code: '35003', iin: '424242', amount: 1200, ip: '85.155.157.215')
|
48
|
+
|
49
|
+
assert_kind_of Quaderno::Transaction, transaction
|
50
|
+
assert_equal "IGIC", transaction.tax_name
|
51
|
+
assert_equal 7.0, transaction.tax_rate
|
52
|
+
assert_equal 1200, transaction.amount
|
53
|
+
assert_equal 84, transaction.tax_amount
|
54
|
+
assert_equal 1284, transaction.total_amount
|
55
|
+
|
56
|
+
#Canarian company to a non Canarian Spanish consumer
|
57
|
+
transaction = Quaderno::Transaction.create(country: 'ES', postal_code: '08080', iin: '424242', amount: 1200, ip: '85.155.156.215')
|
58
|
+
|
59
|
+
assert_kind_of Quaderno::Transaction, transaction
|
60
|
+
assert transaction.tax_name.nil?
|
61
|
+
assert_equal 0, transaction.tax_rate
|
62
|
+
assert_equal 1200, transaction.amount
|
63
|
+
assert_equal 0, transaction.tax_amount
|
64
|
+
assert_equal 1200, transaction.total_amount
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
should "delete a transaction" do
|
69
|
+
VCR.use_cassette('deleted transaction') do
|
70
|
+
new_transaction = Quaderno::Transaction.create(country: 'ES', postal_code: '08080', iin: '424242', amount: 1200, ip: '85.155.156.215')
|
71
|
+
Quaderno::Transaction.delete new_transaction.id
|
72
|
+
assert_raise Quaderno::Exceptions::InvalidSubdomainOrToken do
|
73
|
+
Quaderno::Transaction.find new_transaction.id
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: quaderno
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Recrea
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-12-
|
11
|
+
date: 2014-12-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -83,6 +83,7 @@ files:
|
|
83
83
|
- lib/quaderno-ruby/item.rb
|
84
84
|
- lib/quaderno-ruby/payment.rb
|
85
85
|
- lib/quaderno-ruby/tax.rb
|
86
|
+
- lib/quaderno-ruby/transaction.rb
|
86
87
|
- lib/quaderno-ruby/webhook.rb
|
87
88
|
- quaderno.gemspec
|
88
89
|
- test/fixtures/quaderno_cassettes/.DS_Store
|
@@ -98,6 +99,7 @@ files:
|
|
98
99
|
- test/fixtures/quaderno_cassettes/deleted_expense.yml
|
99
100
|
- test/fixtures/quaderno_cassettes/deleted_invoice.yml
|
100
101
|
- test/fixtures/quaderno_cassettes/deleted_item.yml
|
102
|
+
- test/fixtures/quaderno_cassettes/deleted_transaction.yml
|
101
103
|
- test/fixtures/quaderno_cassettes/deleted_webhook.yml
|
102
104
|
- test/fixtures/quaderno_cassettes/delivered_estimate.yml
|
103
105
|
- test/fixtures/quaderno_cassettes/delivered_invoice.yml
|
@@ -106,12 +108,14 @@ files:
|
|
106
108
|
- test/fixtures/quaderno_cassettes/found_expense.yml
|
107
109
|
- test/fixtures/quaderno_cassettes/found_invoice.yml
|
108
110
|
- test/fixtures/quaderno_cassettes/found_item.yml
|
111
|
+
- test/fixtures/quaderno_cassettes/found_transaction.yml
|
109
112
|
- test/fixtures/quaderno_cassettes/found_webhook.yml
|
110
113
|
- test/fixtures/quaderno_cassettes/new_contact.yml
|
111
114
|
- test/fixtures/quaderno_cassettes/new_estimate.yml
|
112
115
|
- test/fixtures/quaderno_cassettes/new_expense.yml
|
113
116
|
- test/fixtures/quaderno_cassettes/new_invoice.yml
|
114
117
|
- test/fixtures/quaderno_cassettes/new_item.yml
|
118
|
+
- test/fixtures/quaderno_cassettes/new_transaction.yml
|
115
119
|
- test/fixtures/quaderno_cassettes/new_webhook.yml
|
116
120
|
- test/fixtures/quaderno_cassettes/paid_expense.yml
|
117
121
|
- test/fixtures/quaderno_cassettes/paid_invoice.yml
|
@@ -132,6 +136,7 @@ files:
|
|
132
136
|
- test/unit/test_quaderno_invoices.rb
|
133
137
|
- test/unit/test_quaderno_items.rb
|
134
138
|
- test/unit/test_quaderno_tax.rb
|
139
|
+
- test/unit/test_quaderno_transactions.rb
|
135
140
|
- test/unit/test_quaderno_webhooks.rb
|
136
141
|
homepage: http://github.com/quaderno/quaderno-ruby
|
137
142
|
licenses:
|