codat 0.1.2 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.gitlab-ci.yml +1 -1
- data/.ruby-version +1 -0
- data/README.md +2 -0
- data/bin/console +2 -2
- data/codat.gemspec +4 -2
- data/lib/codat.rb +2 -1
- data/lib/codat/base_model.rb +6 -0
- data/lib/codat/models/bank_account.rb +1 -1
- data/lib/codat/models/bank_statement.rb +0 -16
- data/lib/codat/models/bank_statement_list.rb +37 -0
- data/lib/codat/models/company.rb +3 -5
- data/lib/codat/models/financial_sheet.rb +1 -1
- data/lib/codat/models/integration.rb +21 -0
- data/lib/codat/models/metadata.rb +11 -0
- data/lib/codat/models/report.rb +1 -1
- data/lib/codat/version.rb +1 -1
- metadata +17 -15
- data/.travis.yml +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0a1b2456d6687df09540e3f231fb900684a379771bece070ac5ca515070fc4b0
|
4
|
+
data.tar.gz: 15b72b23934fcfbfd404affa282ee004316778b69c79f3e349719a5dcd9fbb8b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d5e4e98c94b48af0f8dbda9af71a093f3ff93e69e1b1aeabdc2bb890c9208868b87aae423ca39079f1a990f7ecfa6222b047e54e1b9578ed404ba5e002d15fc9
|
7
|
+
data.tar.gz: 8d70d18e2bd0de1063b0b93fe82be49d0cf4f82369fb3271e37b23c0090b2713ac52016c0ef9c78bdafa2361dfc737721802ee914ce7e7e453120cc7884a49cf
|
data/.gitignore
CHANGED
data/.gitlab-ci.yml
CHANGED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.6.6
|
data/README.md
CHANGED
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/codat.gemspec
CHANGED
@@ -25,13 +25,15 @@ Gem::Specification.new do |spec|
|
|
25
25
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
26
26
|
spec.require_paths = ['lib']
|
27
27
|
|
28
|
+
spec.required_ruby_version = '>= 2.5'
|
29
|
+
|
28
30
|
spec.add_dependency 'faraday', '~> 0.15'
|
29
31
|
spec.add_dependency 'faraday_middleware', '~> 0.12'
|
30
32
|
spec.add_dependency 'faraday_middleware-multi_json', '~> 0.0.6'
|
31
33
|
spec.add_dependency 'multi_json', '~> 1.13'
|
32
34
|
spec.add_dependency 'rainbow', '~> 3.0'
|
33
35
|
|
34
|
-
spec.add_development_dependency 'bundler'
|
36
|
+
spec.add_development_dependency 'bundler'
|
35
37
|
spec.add_development_dependency 'dotenv', '~> 2.5'
|
36
38
|
spec.add_development_dependency 'pry-byebug', '~> 3.6'
|
37
39
|
spec.add_development_dependency 'rake', '~> 10.0'
|
@@ -40,5 +42,5 @@ Gem::Specification.new do |spec|
|
|
40
42
|
spec.add_development_dependency 'rubocop-rspec', '~> 1.27'
|
41
43
|
spec.add_development_dependency 'simplecov', '~> 0.16'
|
42
44
|
spec.add_development_dependency 'vcr', '~> 4.0.0'
|
43
|
-
spec.add_development_dependency 'webmock', '~> 3.
|
45
|
+
spec.add_development_dependency 'webmock', '~> 3.7.2'
|
44
46
|
end
|
data/lib/codat.rb
CHANGED
@@ -7,9 +7,10 @@ require 'codat/client'
|
|
7
7
|
require 'codat/models/bank_account'
|
8
8
|
require 'codat/models/company'
|
9
9
|
require 'codat/models/report'
|
10
|
-
require 'codat/models/
|
10
|
+
require 'codat/models/bank_statement_list'
|
11
11
|
require 'codat/models/balance_sheet'
|
12
12
|
require 'codat/models/profit_and_loss'
|
13
|
+
require 'codat/models/integration'
|
13
14
|
|
14
15
|
module Codat
|
15
16
|
module_function
|
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
|
@@ -6,24 +6,8 @@ module Codat
|
|
6
6
|
module Models
|
7
7
|
# Bank statements for a given company.
|
8
8
|
class BankStatement < BaseModel
|
9
|
-
ENDPOINT = '/companies/:company_id/data/bankStatements'
|
10
|
-
|
11
9
|
attributes :id, :date, :description, :reconciled, :amount, :balance, :transaction_type
|
12
10
|
attributes :modified_date, :source_modifiedDate
|
13
|
-
|
14
|
-
def self.all(company_id:, account_id:, page: 1)
|
15
|
-
url = format_url(ENDPOINT, company_id: company_id.to_s.strip)
|
16
|
-
|
17
|
-
result = get(url, accountId: account_id.to_s.strip, page: page.to_s.strip)
|
18
|
-
|
19
|
-
return [] if result.status == 404
|
20
|
-
|
21
|
-
records = result.body.dig(:results)
|
22
|
-
|
23
|
-
return [] unless records
|
24
|
-
|
25
|
-
records.map { |bank_statement| new(json: bank_statement) }
|
26
|
-
end
|
27
11
|
end
|
28
12
|
end
|
29
13
|
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'codat/base_model'
|
4
|
+
require 'codat/models/bank_statement'
|
5
|
+
require 'codat/models/metadata'
|
6
|
+
|
7
|
+
module Codat
|
8
|
+
module Models
|
9
|
+
# Bank statements for a given company. This endpoint will return an array of records and also
|
10
|
+
# metadata (page size, page number and total results).
|
11
|
+
class BankStatementList < BaseModel
|
12
|
+
ENDPOINT = '/companies/:company_id/data/bankStatements'
|
13
|
+
|
14
|
+
attr_reader :records, :metadata
|
15
|
+
|
16
|
+
def self.for(company_id:, account_id:, page: 1)
|
17
|
+
url = format_url(ENDPOINT, company_id: company_id.to_s.strip)
|
18
|
+
|
19
|
+
result = get(url, accountId: account_id.to_s.strip, page: page.to_s.strip)
|
20
|
+
|
21
|
+
return nil unless successful_response?(result)
|
22
|
+
|
23
|
+
new(json: result.body)
|
24
|
+
end
|
25
|
+
|
26
|
+
def initialize(json:)
|
27
|
+
super
|
28
|
+
|
29
|
+
records = json.delete(:results) || []
|
30
|
+
|
31
|
+
@records = records.map { |bank_statement| BankStatement.new(json: bank_statement) }
|
32
|
+
|
33
|
+
@metadata = Metadata.new(json: json)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
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
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'codat/base_model'
|
4
|
+
|
5
|
+
module Codat
|
6
|
+
module Models
|
7
|
+
class Integration < BaseModel
|
8
|
+
ENDPOINT = '/integrations'
|
9
|
+
|
10
|
+
attributes :key, :logo_url, :name, :enabled, :source_id, :integration_id, :source_type
|
11
|
+
|
12
|
+
def self.all(params = {})
|
13
|
+
result = get(ENDPOINT, params)
|
14
|
+
|
15
|
+
return [] unless successful_response?(result)
|
16
|
+
|
17
|
+
result.body.fetch(:results, []).map { |integration| new(json: integration) }
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
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.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ricardo Otero
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-07-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -84,16 +84,16 @@ dependencies:
|
|
84
84
|
name: bundler
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- - "
|
87
|
+
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
89
|
+
version: '0'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- - "
|
94
|
+
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: '
|
96
|
+
version: '0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: dotenv
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -212,14 +212,14 @@ dependencies:
|
|
212
212
|
requirements:
|
213
213
|
- - "~>"
|
214
214
|
- !ruby/object:Gem::Version
|
215
|
-
version: 3.
|
215
|
+
version: 3.7.2
|
216
216
|
type: :development
|
217
217
|
prerelease: false
|
218
218
|
version_requirements: !ruby/object:Gem::Requirement
|
219
219
|
requirements:
|
220
220
|
- - "~>"
|
221
221
|
- !ruby/object:Gem::Version
|
222
|
-
version: 3.
|
222
|
+
version: 3.7.2
|
223
223
|
description: Codat API wrapper in Ruby
|
224
224
|
email:
|
225
225
|
- oterosantos@gmail.com
|
@@ -231,7 +231,7 @@ files:
|
|
231
231
|
- ".gitlab-ci.yml"
|
232
232
|
- ".rspec"
|
233
233
|
- ".rubocop.yml"
|
234
|
-
- ".
|
234
|
+
- ".ruby-version"
|
235
235
|
- Gemfile
|
236
236
|
- LICENSE.txt
|
237
237
|
- README.md
|
@@ -250,8 +250,11 @@ files:
|
|
250
250
|
- lib/codat/models/balance_sheet_report.rb
|
251
251
|
- lib/codat/models/bank_account.rb
|
252
252
|
- lib/codat/models/bank_statement.rb
|
253
|
+
- lib/codat/models/bank_statement_list.rb
|
253
254
|
- lib/codat/models/company.rb
|
254
255
|
- lib/codat/models/financial_sheet.rb
|
256
|
+
- lib/codat/models/integration.rb
|
257
|
+
- lib/codat/models/metadata.rb
|
255
258
|
- lib/codat/models/profit_and_loss.rb
|
256
259
|
- lib/codat/models/profit_and_loss_report.rb
|
257
260
|
- lib/codat/models/report.rb
|
@@ -261,7 +264,7 @@ homepage: https://gitlab.com/finpoint/codat
|
|
261
264
|
licenses:
|
262
265
|
- MIT
|
263
266
|
metadata: {}
|
264
|
-
post_install_message:
|
267
|
+
post_install_message:
|
265
268
|
rdoc_options: []
|
266
269
|
require_paths:
|
267
270
|
- lib
|
@@ -269,16 +272,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
269
272
|
requirements:
|
270
273
|
- - ">="
|
271
274
|
- !ruby/object:Gem::Version
|
272
|
-
version: '
|
275
|
+
version: '2.5'
|
273
276
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
274
277
|
requirements:
|
275
278
|
- - ">="
|
276
279
|
- !ruby/object:Gem::Version
|
277
280
|
version: '0'
|
278
281
|
requirements: []
|
279
|
-
|
280
|
-
|
281
|
-
signing_key:
|
282
|
+
rubygems_version: 3.2.11
|
283
|
+
signing_key:
|
282
284
|
specification_version: 4
|
283
285
|
summary: Codat API wrapper in Ruby
|
284
286
|
test_files: []
|