column_api 0.0.2 → 0.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 73530bf2a0b110c13bd34d55231cc3e0d91ff44046221a7b74ea8ec2b380ef82
4
- data.tar.gz: f41a16e9e40eff65511e43e85238708fe6c54027a8f006cdfe0d8fac8ad02533
3
+ metadata.gz: 1f6201925587745962ca88d181952fb299995347b0bcc66581ea2d39ecccdbc6
4
+ data.tar.gz: 9053f946825a96523e0d86867ded80df66d59b6c69254d814cd24bb135367820
5
5
  SHA512:
6
- metadata.gz: e3af56a1cf2c39c8f2e073fcefb302f9aec329c6f578c63e628c10aac54b88d5ac9493b57d77a270f24895bd8578eecdac02b65848a125399c79a4b056b925ba
7
- data.tar.gz: 319b6972c7d192ad2900d8f7baf805fcdfd9fd90d0ed3a77afb0724b00f4341661abd67be927a4f8757f0ec4dd9a160dcc389dd88340992280b31977becdfa39
6
+ metadata.gz: 4125ef91a2a974c38c935b2665bf1fb8af9e0e151bd42595e3cdb3bba7aa67e951b4c00a3b91a8a9321d3adfe49b635d3701840d178df7a5315f8174db36bcb5
7
+ data.tar.gz: ce6defb6e864690523b481813a1d0c1c0e0be8447712b73ad5c6548f294d8c3d519519b9626eb68176d4ba025165007bafa82e38ccbe83742eda70b20dd4ef75
data/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  ## [Unreleased]
2
2
 
3
- ## [0.1.0] - 2023-12-29
3
+ ## [0.0.3] - 2024-01-02
4
+
5
+ - Add Bank Account endpoints
6
+
7
+ ## [0.0.2] - 2023-12-31
8
+
9
+ - Add Entity endpoints
10
+
11
+ ## [0.0.1] - 2023-12-29
4
12
 
5
13
  - Initial release
14
+ - Add Faraday client
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- column_api (0.0.2)
4
+ column_api (0.0.3)
5
5
  faraday (~> 2.8.1)
6
6
  faraday-parse_dates (~> 0.1.1)
7
7
 
data/README.md CHANGED
@@ -9,7 +9,7 @@ Ruby bindings for [Column's API](https://column.com/docs/api).
9
9
  ## Installation
10
10
 
11
11
  ```ruby
12
- gem 'column_api', '~> 0.0.2'
12
+ gem 'column_api', '~> 0.0.3'
13
13
  ```
14
14
 
15
15
  ## Usage
@@ -17,8 +17,13 @@ gem 'column_api', '~> 0.0.2'
17
17
  ```ruby
18
18
  client = ColumnApi::Client.new(api_key: ENV["COLUMN_API_KEY"])
19
19
 
20
- client.entities.retrieve(entity_id: "enti_2aELWf6D")
21
- # => #<ColumnApi::PersonEntity documents=[], id="enti_2aELWf6D", is_root=true, type="PERSON" (...)>
20
+ person = client.entities.retrieve(entity_id: "enti_2aELWf6D")
21
+ person.id # => enti_2Q1ctiJm1NypVqCt8UBC8e4xTfH
22
+ person.person_details.email # => oliver@column.com
23
+
24
+ bank_accounts = client.bank_accounts.list({ limit: 2 })
25
+ bank_accounts.data # => [#<ColumnApi::BankAccount>, #<ColumnApi::BankAccount>]
26
+ bank_accounts.has_more # => true
22
27
  ```
23
28
 
24
29
  Alternatively, you can query the endpoints directly:
@@ -50,6 +55,19 @@ client.entities.delete(entity_id: "ID")
50
55
  client.entities.submit_document(entity_id: "ID", params: {})
51
56
  ```
52
57
 
58
+ ### BankAccounts
59
+
60
+ https://column.com/docs/api/#bank-account/object
61
+
62
+ ```ruby
63
+ client.bank_accounts.list({})
64
+ client.bank_accounts.retrieve(bank_account_id: "ID")
65
+ client.bank_accounts.create({})
66
+ client.bank_accounts.update(bank_account_id: "ID", params: {})
67
+ client.bank_accounts.delete(bank_account_id: "ID")
68
+ client.bank_accounts.history(bank_account_id: "ID", from_date: Date, to_date: Date)
69
+ ```
70
+
53
71
  ## Development
54
72
 
55
73
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -14,6 +14,10 @@ module ColumnApi
14
14
  EntityResource.new(self)
15
15
  end
16
16
 
17
+ def bank_accounts
18
+ BankAccountResource.new(self)
19
+ end
20
+
17
21
  def connection
18
22
  @connection ||= Faraday.new(BASE_URL) do |conn|
19
23
  conn.request :authorization, :basic, "", api_key
@@ -10,7 +10,13 @@ module ColumnApi
10
10
  end
11
11
 
12
12
  def to_ostruct(obj)
13
- JSON.parse obj.to_json, object_class: OpenStruct
13
+ if obj.is_a?(Hash)
14
+ OpenStruct.new(obj.transform_values { |val| to_ostruct(val) })
15
+ elsif obj.is_a?(Array)
16
+ obj.map { |o| to_ostruct(o) }
17
+ else # Assumed to be a primitive value
18
+ obj
19
+ end
14
20
  end
15
21
  end
16
22
  end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ColumnApi
4
+ class BankAccount < Object
5
+ end
6
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ColumnApi
4
+ class BankAccountResource < Resource
5
+ def list(params = {})
6
+ response = get_request("bank-accounts", params: params).body
7
+ Collection.from_response(response, key: "bank_accounts", type: BankAccount)
8
+ end
9
+
10
+ def retrieve(bank_account_id:)
11
+ BankAccount.new get_request("bank-accounts/#{bank_account_id}").body
12
+ end
13
+
14
+ def create(params)
15
+ BankAccount.new post_request("bank-accounts", body: params).body
16
+ end
17
+
18
+ def update(bank_account_id:, params:)
19
+ BankAccount.new patch_request("bank-accounts/#{bank_account_id}", body: params).body
20
+ end
21
+
22
+ def delete(bank_account_id:)
23
+ delete_request("bank-accounts/#{bank_account_id}")
24
+ true
25
+ end
26
+
27
+ def history(bank_account_id:, from_date:, to_date:)
28
+ params = { from_date: from_date.strftime("%Y-%m-%d"), to_date: to_date.strftime("%Y-%m-%d") }
29
+
30
+ BankAccount.new get_request("bank-accounts/#{bank_account_id}/history", params: params).body
31
+ end
32
+ end
33
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ColumnApi
4
- VERSION = "0.0.2"
4
+ VERSION = "0.0.3"
5
5
  end
data/lib/column_api.rb CHANGED
@@ -15,9 +15,11 @@ module ColumnApi
15
15
  autoload :Resource, "column_api/resource"
16
16
 
17
17
  # Objects
18
+ autoload :BankAccount, "column_api/objects/bank_account"
18
19
  autoload :BusinessEntity, "column_api/objects/business_entity"
19
20
  autoload :PersonEntity, "column_api/objects/person_entity"
20
21
 
21
22
  # Resources
23
+ autoload :BankAccountResource, "column_api/resources/bank_account_resource"
22
24
  autoload :EntityResource, "column_api/resources/entity_resource"
23
25
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: column_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matias Leidemer
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-12-31 00:00:00.000000000 Z
11
+ date: 2024-01-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -59,9 +59,11 @@ files:
59
59
  - lib/column_api/collection.rb
60
60
  - lib/column_api/errors.rb
61
61
  - lib/column_api/object.rb
62
+ - lib/column_api/objects/bank_account.rb
62
63
  - lib/column_api/objects/business_entity.rb
63
64
  - lib/column_api/objects/person_entity.rb
64
65
  - lib/column_api/resource.rb
66
+ - lib/column_api/resources/bank_account_resource.rb
65
67
  - lib/column_api/resources/entity_resource.rb
66
68
  - lib/column_api/version.rb
67
69
  - sig/column_api.rbs
@@ -85,7 +87,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
85
87
  - !ruby/object:Gem::Version
86
88
  version: '0'
87
89
  requirements: []
88
- rubygems_version: 3.4.10
90
+ rubygems_version: 3.4.6
89
91
  signing_key:
90
92
  specification_version: 4
91
93
  summary: Ruby bindings for Column API