codat 0.1.2 → 0.1.3
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 +2 -0
- data/lib/codat.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/metadata.rb +11 -0
- data/lib/codat/version.rb +1 -1
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 815e3180acc27e45f704e7cd9ba4893d55774b47d6b0417020568538ba780490
|
4
|
+
data.tar.gz: fcb66e4ccb57663cb4a1581d53271d2faecbba03602101e1758c981327101f63
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 84e5b6c95805735f2f9429dd28f7edb3b74037796528a481ac991fadbf62148544007624b39228ada5c1747ed3adf7d933042baa76690898e8bb40134f67be91
|
7
|
+
data.tar.gz: be197f35c8353eeb0136159c25517ff9af4609ca9f8b055dee54d08ad96251d7b952956edfec29452f4d0fa6abc798a2cd906d5ce75d7daf9c0bff09bde6ca80
|
data/README.md
CHANGED
data/lib/codat.rb
CHANGED
@@ -7,7 +7,7 @@ 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
13
|
|
@@ -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 if result.status == 404
|
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/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ricardo Otero
|
@@ -250,8 +250,10 @@ 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/metadata.rb
|
255
257
|
- lib/codat/models/profit_and_loss.rb
|
256
258
|
- lib/codat/models/profit_and_loss_report.rb
|
257
259
|
- lib/codat/models/report.rb
|