codat 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/console +2 -2
- data/lib/codat/base_model.rb +6 -0
- data/lib/codat/models/bank_account.rb +1 -1
- data/lib/codat/models/bank_statement_list.rb +1 -1
- data/lib/codat/models/company.rb +3 -5
- data/lib/codat/models/financial_sheet.rb +1 -1
- data/lib/codat/models/integration.rb +1 -3
- data/lib/codat/models/report.rb +1 -1
- data/lib/codat/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d09022df4a8325e87d98203d4441da3bb0767abc37b654c2ed2b0901d0f45f4b
|
4
|
+
data.tar.gz: f75d4d5a4e8ef1f66201e53d70ea8449d289e18ca0b7355dbd8484a112bb6a6b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ee8f01dfbe68c0b176164b054e6191bf9bf2b68dc6c87740eaf6bab195c6dc9e8724b35dd3179612bb2778d12a69da7b20c9db5adbec0595c6330392504c85af
|
7
|
+
data.tar.gz: f94df3242b171c2c63d5c130505484143c81697dce53b9d714817f53f28f329f3872c9b147376abcc57fe5664034e844b1a000c49f67ef00beb1fe0387b041be
|
data/bin/console
CHANGED
@@ -12,8 +12,8 @@ Codat.configure do |config|
|
|
12
12
|
end
|
13
13
|
|
14
14
|
# To avoid having to namespace everything when inside the console.
|
15
|
-
Object.
|
16
|
-
Object.
|
15
|
+
Object.include(Codat)
|
16
|
+
Object.include(Codat::Models)
|
17
17
|
|
18
18
|
require 'pry'
|
19
19
|
Pry.start
|
data/lib/codat/base_model.rb
CHANGED
@@ -39,6 +39,12 @@ module Codat
|
|
39
39
|
|
40
40
|
formatted
|
41
41
|
end
|
42
|
+
|
43
|
+
# As per Codat API doc
|
44
|
+
# https://docs.codat.io/reference/errors
|
45
|
+
def successful_response?(result)
|
46
|
+
result.status < 400
|
47
|
+
end
|
42
48
|
end
|
43
49
|
|
44
50
|
# Sets all the instance variables by reading the JSON from Codat and converting the keys from
|
data/lib/codat/models/company.rb
CHANGED
@@ -18,9 +18,7 @@ module Codat
|
|
18
18
|
def self.all(params = {})
|
19
19
|
result = get(ENDPOINTS[:collection], params)
|
20
20
|
|
21
|
-
return []
|
22
|
-
|
23
|
-
return result.body if result.status == 400
|
21
|
+
return [] unless successful_response?(result)
|
24
22
|
|
25
23
|
result.body[:results].map { |company| new(json: company) }
|
26
24
|
end
|
@@ -30,7 +28,7 @@ module Codat
|
|
30
28
|
|
31
29
|
result = get(url)
|
32
30
|
|
33
|
-
return nil
|
31
|
+
return nil unless successful_response?(result)
|
34
32
|
|
35
33
|
new(json: result.body)
|
36
34
|
end
|
@@ -38,7 +36,7 @@ module Codat
|
|
38
36
|
def self.create(params = {})
|
39
37
|
result = post(ENDPOINTS[:collection], params)
|
40
38
|
|
41
|
-
return { error: 'An error occured.' }
|
39
|
+
return { error: 'An error occured.' } unless successful_response?(result)
|
42
40
|
|
43
41
|
new(json: result.body)
|
44
42
|
end
|
@@ -12,9 +12,7 @@ module Codat
|
|
12
12
|
def self.all(params = {})
|
13
13
|
result = get(ENDPOINT, params)
|
14
14
|
|
15
|
-
return []
|
16
|
-
|
17
|
-
return result.body if result.status == 400
|
15
|
+
return [] unless successful_response?(result)
|
18
16
|
|
19
17
|
result.body.map { |integration| new(json: integration) }
|
20
18
|
end
|
data/lib/codat/models/report.rb
CHANGED
data/lib/codat/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: codat
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ricardo Otero
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-01-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|