fs_api 1.0.6 → 1.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/fs_api/service/base_service.rb +4 -0
- data/lib/fs_api/version.rb +1 -1
- data/spec/lib/fs_api/service/invoice_spec.rb +15 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 737cb0adf3eea01f33d3c9d8add3dd65ef7db522
|
4
|
+
data.tar.gz: 3dc3f9e843cd3bbff5357f7cb6d31275289784f6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 32b7ac069457409dee2860bd439c48bdd2f36f693b29f2f34859ed1faba04b9ba307bcc2257fc28051a88f0d55d5d66bedeb6cef064ffb6dfa9584a6b5285ab7
|
7
|
+
data.tar.gz: 9b418d1ae0870a62c94f6a3ed88673fc821f9fde6e0ec0e323507599b7d0d163374e15c6f2ff2ee968696000998310d3e96ada693f137ebe0d795383ba68f9b3
|
@@ -28,6 +28,10 @@ module FsApi
|
|
28
28
|
if response = @api_client.get([path,id].join('/'))
|
29
29
|
if response.code.to_i == success_status_code
|
30
30
|
json_response = JSON.parse(response.body)
|
31
|
+
# Weird case when nothing is found all clients are returned
|
32
|
+
# #find should only return a single record
|
33
|
+
return nil if json_response.is_a? Array
|
34
|
+
# Return instance
|
31
35
|
collection_class.new(json_response[resource_type].merge(from_api: true))
|
32
36
|
end
|
33
37
|
end
|
data/lib/fs_api/version.rb
CHANGED
@@ -8,7 +8,8 @@ describe FsApi::Service::Invoice do
|
|
8
8
|
|
9
9
|
describe "retrieval" do
|
10
10
|
it "retrieves all invoices" do
|
11
|
-
stub_request(:get, "https://username:api_key@www.factuursturen.nl/api/v1/invoices")
|
11
|
+
stub_request(:get, "https://username:api_key@www.factuursturen.nl/api/v1/invoices")
|
12
|
+
.to_return(body: [json_response(:invoice)].to_json )
|
12
13
|
|
13
14
|
invoices = service.all
|
14
15
|
|
@@ -17,7 +18,8 @@ describe FsApi::Service::Invoice do
|
|
17
18
|
end
|
18
19
|
|
19
20
|
it "retrieves all invoices with filter" do
|
20
|
-
stub_request(:get, "https://username:api_key@www.factuursturen.nl/api/v1/invoices?filter=overdue")
|
21
|
+
stub_request(:get, "https://username:api_key@www.factuursturen.nl/api/v1/invoices?filter=overdue")
|
22
|
+
.to_return(body: [json_response(:invoice)].to_json )
|
21
23
|
|
22
24
|
invoices = service.all(filter: :overdue)
|
23
25
|
|
@@ -26,12 +28,22 @@ describe FsApi::Service::Invoice do
|
|
26
28
|
end
|
27
29
|
|
28
30
|
it "retrieves a invoice" do
|
29
|
-
stub_request(:get, "https://username:api_key@www.factuursturen.nl/api/v1/invoices/20150001")
|
31
|
+
stub_request(:get, "https://username:api_key@www.factuursturen.nl/api/v1/invoices/20150001")
|
32
|
+
.to_return(body: { 'invoice' => json_response(:invoice)}.to_json )
|
30
33
|
|
31
34
|
invoice = service.find('20150001')
|
32
35
|
|
33
36
|
expect(invoice.invoicenr).to eq 'F20150001'
|
34
37
|
end
|
38
|
+
|
39
|
+
it "retrieves a invoice" do
|
40
|
+
stub_request(:get, "https://username:api_key@www.factuursturen.nl/api/v1/invoices/bogus").
|
41
|
+
to_return(body: [json_response(:invoice)].to_json )
|
42
|
+
|
43
|
+
invoice = service.find('bogus')
|
44
|
+
|
45
|
+
expect(invoice).to eq nil
|
46
|
+
end
|
35
47
|
end
|
36
48
|
|
37
49
|
describe "deletion" do
|