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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fead9d0f81c3171c55762f7c924017bfc315ae80
4
- data.tar.gz: f6240a493352f56a92f74241f5693388566edec0
3
+ metadata.gz: 737cb0adf3eea01f33d3c9d8add3dd65ef7db522
4
+ data.tar.gz: 3dc3f9e843cd3bbff5357f7cb6d31275289784f6
5
5
  SHA512:
6
- metadata.gz: 0fa0061247b496217a9332440972e3b7d1dc241ad7377a785a7a799ae9b7c239333152cef27e4473f34cdf2bb45083b0bcacd9aeb096a4c425d592bf64cfc1fb
7
- data.tar.gz: b3b77613271f8c7727ca153ee032714369d0a3fce10862efa8bfbc41d2d20c9087e777446958bf0b93685decd636c6d4b8fc07f1265c1480b1e9cdb9b2c0c74d
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
@@ -1,3 +1,3 @@
1
1
  module FsApi
2
- VERSION = "1.0.6"
2
+ VERSION = "1.0.7"
3
3
  end
@@ -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").to_return(body: [json_response(:invoice)].to_json )
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").to_return(body: [json_response(:invoice)].to_json )
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").to_return(body: { 'invoice' => json_response(:invoice)}.to_json )
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fs_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.6
4
+ version: 1.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maarten van Vliet