jortt 4.1.0 → 4.2.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.
- checksums.yaml +4 -4
- data/README.md +54 -1
- data/jortt.gemspec +1 -1
- data/lib/jortt/client/customers.rb +12 -0
- data/lib/jortt/client/invoices.rb +7 -1
- data/lib/jortt/client/version.rb +1 -1
- data/spec/jortt/client/customers_spec.rb +28 -0
- data/spec/jortt/client/invoices_spec.rb +9 -0
- metadata +4 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0888e091fcb1156dc527b9cd815d0629b60e411e
|
4
|
+
data.tar.gz: e254535aeb502a1c3358df8b0af23eb782b0691e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 11c08eb54b2d3b3f844e17df78c2e580bdb2b036a0d6322624ff352e8f5baf8e8c58cfd6db1340c209872e8513f21ae881216aeb65b6ef69d34aeeaa1220f667
|
7
|
+
data.tar.gz: 968c299166179d4d3c43ac37ef500a547c3f9ceea81db998e291dd6bf63593bda65fda12a2252bdbf75dd24bc0cd566cf2f4c93d5c6f3417a87de0f33fec7aaa
|
data/README.md
CHANGED
@@ -27,6 +27,30 @@ jortt = Jortt.client(
|
|
27
27
|
|
28
28
|
### Customers
|
29
29
|
|
30
|
+
All customers (`jortt.customers.all(page: 2, per_page: 25)`) returns:
|
31
|
+
```ruby
|
32
|
+
[{
|
33
|
+
company_name: 'Jortt',
|
34
|
+
address: {
|
35
|
+
street: "Transistorstraat 71C",
|
36
|
+
postal_code: "1322 CK",
|
37
|
+
city: "Almere",
|
38
|
+
country_code: "NL"
|
39
|
+
}
|
40
|
+
},
|
41
|
+
{
|
42
|
+
company_name: 'Zilverline',
|
43
|
+
address: {
|
44
|
+
street: "Cruquiusweg",
|
45
|
+
...
|
46
|
+
}
|
47
|
+
},
|
48
|
+
...
|
49
|
+
page: 2,
|
50
|
+
per_page: 25
|
51
|
+
]
|
52
|
+
```
|
53
|
+
|
30
54
|
Searching customers (`jortt.customers.search('Jortt')`) returns:
|
31
55
|
```ruby
|
32
56
|
[{
|
@@ -38,6 +62,7 @@ Searching customers (`jortt.customers.search('Jortt')`) returns:
|
|
38
62
|
country_code: "NL"
|
39
63
|
}
|
40
64
|
},
|
65
|
+
{
|
41
66
|
company_name: 'ttroj',
|
42
67
|
address: {
|
43
68
|
street: "Jorttweg",
|
@@ -62,13 +87,39 @@ jortt.customers.create(
|
|
62
87
|
```
|
63
88
|
|
64
89
|
### Invoices
|
90
|
+
Get invoices by ID (`jortt.invoices.get('934d59dd-76f6-4716-9e0f-82a618e1be21')`) returns:
|
91
|
+
```ruby
|
92
|
+
{
|
93
|
+
"invoice_id": "934d59dd-76f6-4716-9e0f-82a618e1be21",
|
94
|
+
"recipient": {
|
95
|
+
"company_name": "Zilverline B.V.",
|
96
|
+
"attn": null,
|
97
|
+
"address": {
|
98
|
+
"street": "Cruquisweg 109F",
|
99
|
+
"city": "Amsterdam",
|
100
|
+
"postal_code": "1111SX",
|
101
|
+
"country": {
|
102
|
+
"code": "NL",
|
103
|
+
"name": "Nederland"
|
104
|
+
}
|
105
|
+
},
|
106
|
+
"email": "ben@jortt.nl",
|
107
|
+
"customer_id": "e1c5e15b-e34e-423e-a291-4ed43226a190",
|
108
|
+
"extra_information": null,
|
109
|
+
...
|
110
|
+
}
|
111
|
+
...
|
112
|
+
}
|
113
|
+
```
|
114
|
+
|
115
|
+
|
65
116
|
Searching invoices (`jortt.invoices.search('201606-012')`) returns:
|
66
117
|
```ruby
|
67
118
|
[
|
68
119
|
{
|
69
120
|
"invoice_id": "934d59dd-76f6-4716-9e0f-82a618e1be21",
|
70
121
|
"recipient": {
|
71
|
-
"company_name": "
|
122
|
+
"company_name": "Zilverline B.V.",
|
72
123
|
"attn": null,
|
73
124
|
"address": {
|
74
125
|
"street": "Cruquisweg 109F",
|
@@ -188,3 +239,5 @@ by `require 'jortt/client'` and do your stuff).
|
|
188
239
|
Make a fix, commit and push. Make sure the build is green. Then bump the
|
189
240
|
version (edit `lib/jortt/client/version.rb`). Now `rake release` and follow
|
190
241
|
the instructions (you need a rubygems.org account and permissions ;-)).
|
242
|
+
|
243
|
+
Otherwise `gem build jortt.gemspec` and `gem push jortt-[version].gem`.
|
data/jortt.gemspec
CHANGED
@@ -27,7 +27,7 @@ Gem::Specification.new do |spec|
|
|
27
27
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
28
28
|
spec.require_paths = ['lib']
|
29
29
|
|
30
|
-
spec.add_runtime_dependency 'rest-client', '~>
|
30
|
+
spec.add_runtime_dependency 'rest-client', '~> 2.0'
|
31
31
|
|
32
32
|
spec.add_development_dependency 'bundler', '~> 1.0'
|
33
33
|
spec.add_development_dependency 'codecov', '~> 0.1'
|
@@ -18,6 +18,18 @@ module Jortt # :nodoc:
|
|
18
18
|
)
|
19
19
|
end
|
20
20
|
|
21
|
+
##
|
22
|
+
# Returns all customers using the GET /customers/all endpoint.
|
23
|
+
#
|
24
|
+
# @example
|
25
|
+
# Jortt::Client.customers.all(page: 3, per_page: 10)
|
26
|
+
#
|
27
|
+
def all(page: 1, per_page: 50)
|
28
|
+
resource['all'].get(params: {page: page, per_page: per_page}) do |res|
|
29
|
+
JSON.parse(res.body)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
21
33
|
##
|
22
34
|
# Creates a Customer using the POST /customers endpoint.
|
23
35
|
# See https://app.jortt.nl/api-documentatie#klant-aanmaken
|
@@ -40,8 +40,14 @@ module Jortt # :nodoc:
|
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
|
+
def get(id)
|
44
|
+
resource["id/#{id}"].get do |response|
|
45
|
+
JSON.parse(response.body)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
43
49
|
def search(query)
|
44
|
-
resource[
|
50
|
+
resource['search'].get(params: {query: query}) do |response|
|
45
51
|
JSON.parse(response.body)
|
46
52
|
end
|
47
53
|
end
|
data/lib/jortt/client/version.rb
CHANGED
@@ -8,6 +8,34 @@ describe Jortt::Client::Customers do
|
|
8
8
|
)
|
9
9
|
end
|
10
10
|
|
11
|
+
describe '#all' do
|
12
|
+
context 'without params' do
|
13
|
+
subject { customers.all }
|
14
|
+
|
15
|
+
before do
|
16
|
+
url = 'http://app:secret@foo/customers/all?page=1&per_page=50'
|
17
|
+
stub_request(:get, url).
|
18
|
+
to_return(status: 200, body: '{"customers": ["foo"]}')
|
19
|
+
end
|
20
|
+
|
21
|
+
it { should eq('customers' => ['foo']) }
|
22
|
+
end
|
23
|
+
|
24
|
+
context 'with params' do
|
25
|
+
subject { customers.all(page: page, per_page: per_page) }
|
26
|
+
let(:page) { 3 }
|
27
|
+
let(:per_page) { 25 }
|
28
|
+
|
29
|
+
before do
|
30
|
+
url = 'http://app:secret@foo/customers/all?page=3&per_page=25'
|
31
|
+
stub_request(:get, url).
|
32
|
+
to_return(status: 200, body: '{"customers": ["bar"]}')
|
33
|
+
end
|
34
|
+
|
35
|
+
it { should eq('customers' => ['bar']) }
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
11
39
|
describe '#create' do
|
12
40
|
let(:request_body) { JSON.generate(customer: {line_items: []}) }
|
13
41
|
let(:response_body) { JSON.generate(customer_id: 'abc') }
|
@@ -20,6 +20,15 @@ describe Jortt::Client::Invoices do
|
|
20
20
|
it { should eq('invoice_id' => 'abc') }
|
21
21
|
end
|
22
22
|
|
23
|
+
describe '#get' do
|
24
|
+
subject { invoices.get('foo') }
|
25
|
+
before do
|
26
|
+
stub_request(:get, 'http://app:secret@foo/invoices/id/foo').
|
27
|
+
to_return(status: 200, body: '{"id": "foo"}')
|
28
|
+
end
|
29
|
+
it { should eq('id' => 'foo') }
|
30
|
+
end
|
31
|
+
|
23
32
|
describe '#search' do
|
24
33
|
subject { invoices.search('terms') }
|
25
34
|
before do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jortt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bob Forma
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date:
|
14
|
+
date: 2017-06-26 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: rest-client
|
@@ -19,14 +19,14 @@ dependencies:
|
|
19
19
|
requirements:
|
20
20
|
- - "~>"
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: '
|
22
|
+
version: '2.0'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
27
|
- - "~>"
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: '
|
29
|
+
version: '2.0'
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: bundler
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
@@ -201,4 +201,3 @@ test_files:
|
|
201
201
|
- spec/jortt/client_spec.rb
|
202
202
|
- spec/jortt_spec.rb
|
203
203
|
- spec/spec_helper.rb
|
204
|
-
has_rdoc:
|