column_api 0.0.2 → 0.0.4

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: a503efefcfe39d720cbb939f82acfe1d564c6335746d516d75d96e7e79e35a6f
4
+ data.tar.gz: 012c38bed66d9f244b61be505991595c1543d3958bac7b71ed99b1074a5a84ea
5
5
  SHA512:
6
- metadata.gz: e3af56a1cf2c39c8f2e073fcefb302f9aec329c6f578c63e628c10aac54b88d5ac9493b57d77a270f24895bd8578eecdac02b65848a125399c79a4b056b925ba
7
- data.tar.gz: 319b6972c7d192ad2900d8f7baf805fcdfd9fd90d0ed3a77afb0724b00f4341661abd67be927a4f8757f0ec4dd9a160dcc389dd88340992280b31977becdfa39
6
+ metadata.gz: 9a905c02a3672a528bb39297ad1ca12d3e1969d610f2af95236c47a71fbfe1632600bcd4bfd54501d12916feb0cbd354c85e5f44d5e02a36dbb732505321064e
7
+ data.tar.gz: 106db37b864694cc854e0e43ab3fc7816f0b42a3c718e70e7511b701627559529a0da2d711e38bf9fba3b929ec11ee650b29246838daf7c61bd5ece99e476374
data/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  ## [Unreleased]
2
2
 
3
- ## [0.1.0] - 2023-12-29
3
+ ## [0.0.4] - 2024-01-02
4
+
5
+ - Add ACH Tranfer endpoints
6
+
7
+ ## [0.0.3] - 2024-01-02
8
+
9
+ - Add Bank Account endpoints
10
+
11
+ ## [0.0.2] - 2023-12-31
12
+
13
+ - Add Entity endpoints
14
+
15
+ ## [0.0.1] - 2023-12-29
4
16
 
5
17
  - Initial release
18
+ - Add Faraday client
data/Gemfile CHANGED
@@ -12,3 +12,6 @@ gem "rspec", "~> 3.0"
12
12
  gem "rubocop", "~> 1.21"
13
13
 
14
14
  gem "webmock", "~> 3.19", ">= 3.19.1"
15
+
16
+ gem "simplecov", "~> 0.22", require: false, group: :test
17
+ gem "simplecov_json_formatter"
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.4)
5
5
  faraday (~> 2.8.1)
6
6
  faraday-parse_dates (~> 0.1.1)
7
7
 
@@ -15,6 +15,7 @@ GEM
15
15
  crack (0.4.5)
16
16
  rexml
17
17
  diff-lcs (1.5.0)
18
+ docile (1.4.0)
18
19
  faraday (2.8.1)
19
20
  base64
20
21
  faraday-net_http (>= 2.0, < 3.1)
@@ -63,6 +64,12 @@ GEM
63
64
  parser (>= 3.2.1.0)
64
65
  ruby-progressbar (1.13.0)
65
66
  ruby2_keywords (0.0.5)
67
+ simplecov (0.22.0)
68
+ docile (~> 1.1)
69
+ simplecov-html (~> 0.11)
70
+ simplecov_json_formatter (~> 0.1)
71
+ simplecov-html (0.12.3)
72
+ simplecov_json_formatter (0.1.4)
66
73
  unicode-display_width (2.5.0)
67
74
  webmock (3.19.1)
68
75
  addressable (>= 2.8.0)
@@ -78,6 +85,8 @@ DEPENDENCIES
78
85
  rake (~> 13.0)
79
86
  rspec (~> 3.0)
80
87
  rubocop (~> 1.21)
88
+ simplecov (~> 0.22)
89
+ simplecov_json_formatter
81
90
  webmock (~> 3.19, >= 3.19.1)
82
91
 
83
92
  BUNDLED WITH
data/README.md CHANGED
@@ -1,15 +1,15 @@
1
+ [![Gem Version](https://badge.fury.io/rb/column_api.svg)](https://badge.fury.io/rb/column_api) [![Maintainability](https://api.codeclimate.com/v1/badges/43aa9279fa11d33f6fa3/maintainability)](https://codeclimate.com/github/matiasleidemer/column_api/maintainability) [![Test Coverage](https://api.codeclimate.com/v1/badges/43aa9279fa11d33f6fa3/test_coverage)](https://codeclimate.com/github/matiasleidemer/column_api/test_coverage)
2
+
1
3
  # ColumnApi
2
4
 
3
5
  _This gem is under development and the API is unstable._
4
6
 
5
- [![Gem Version](https://badge.fury.io/rb/column_api.svg)](https://badge.fury.io/rb/column_api)
6
-
7
7
  Ruby bindings for [Column's API](https://column.com/docs/api).
8
8
 
9
9
  ## Installation
10
10
 
11
11
  ```ruby
12
- gem 'column_api', '~> 0.0.2'
12
+ gem 'column_api', '~> 0.0.4'
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:
@@ -41,13 +46,38 @@ https://column.com/docs/api/#entity/object
41
46
 
42
47
  ```ruby
43
48
  client.entities.list({})
44
- client.entities.retrieve(entity_id: "ID")
49
+ client.entities.retrieve(entity_id:)
45
50
  client.entities.create_person({})
46
51
  client.entities.create_business({})
47
52
  client.entities.update_person(entity_id:, params: {})
48
53
  client.entities.update_business(entity_id:, params: {})
49
- client.entities.delete(entity_id: "ID")
50
- client.entities.submit_document(entity_id: "ID", params: {})
54
+ client.entities.delete(entity_id:)
55
+ client.entities.submit_document(entity_id:, params: {})
56
+ ```
57
+
58
+ ### Bank Accounts
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:)
65
+ client.bank_accounts.create({})
66
+ client.bank_accounts.update(bank_account_id:, params: {})
67
+ client.bank_accounts.delete(bank_account_id:)
68
+ client.bank_accounts.history(bank_account_id:, from_date: Date, to_date: Date)
69
+ ```
70
+
71
+ ### ACH Transfers
72
+
73
+ https://column.com/docs/api/#ach-transfer/object
74
+
75
+ ```ruby
76
+ client.ach_transfers.list({})
77
+ client.ach_transfers.retrieve(ach_transfer_id:)
78
+ client.ach_transfers.create({})
79
+ client.ach_transfers.cancel(ach_transfer_id:)
80
+ client.ach_transfers.reverse(ach_transfer_id:, reason:, description: "")
51
81
  ```
52
82
 
53
83
  ## Development
@@ -10,10 +10,18 @@ module ColumnApi
10
10
  @adapter = adapter
11
11
  end
12
12
 
13
+ def ach_transfers
14
+ AchTransferResource.new(self)
15
+ end
16
+
13
17
  def entities
14
18
  EntityResource.new(self)
15
19
  end
16
20
 
21
+ def bank_accounts
22
+ BankAccountResource.new(self)
23
+ end
24
+
17
25
  def connection
18
26
  @connection ||= Faraday.new(BASE_URL) do |conn|
19
27
  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 AchTransfer < Object
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ColumnApi
4
+ class BankAccount < Object
5
+ end
6
+ end
@@ -14,7 +14,7 @@ module ColumnApi
14
14
  handle_response client.connection.get(url, params, headers)
15
15
  end
16
16
 
17
- def post_request(url, body:, headers: {})
17
+ def post_request(url, body: {}, headers: {})
18
18
  handle_response client.connection.post(url, body, headers)
19
19
  end
20
20
 
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ColumnApi
4
+ class AchTransferResource < Resource
5
+ def list(params = {})
6
+ response = get_request("transfers/ach", params: params).body
7
+ Collection.from_response(response, key: "transfers", type: AchTransfer)
8
+ end
9
+
10
+ def retrieve(ach_transfer_id:)
11
+ AchTransfer.new get_request("transfers/ach/#{ach_transfer_id}").body
12
+ end
13
+
14
+ def create(params)
15
+ AchTransfer.new post_request("transfers/ach", body: params).body
16
+ end
17
+
18
+ def cancel(ach_transfer_id:)
19
+ AchTransfer.new post_request("transfers/ach/#{ach_transfer_id}/cancel").body
20
+ end
21
+
22
+ def reverse(ach_transfer_id:, reason:, description: "")
23
+ AchTransfer.new(
24
+ post_request("transfers/ach/#{ach_transfer_id}/reverse",
25
+ body: { reason: reason, description: description }).body
26
+ )
27
+ end
28
+ end
29
+ 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.4"
5
5
  end
data/lib/column_api.rb CHANGED
@@ -15,9 +15,13 @@ module ColumnApi
15
15
  autoload :Resource, "column_api/resource"
16
16
 
17
17
  # Objects
18
+ autoload :AchTransfer, "column_api/objects/ach_transfer"
19
+ autoload :BankAccount, "column_api/objects/bank_account"
18
20
  autoload :BusinessEntity, "column_api/objects/business_entity"
19
21
  autoload :PersonEntity, "column_api/objects/person_entity"
20
22
 
21
23
  # Resources
24
+ autoload :AchTransferResource, "column_api/resources/ach_transfer_resource"
25
+ autoload :BankAccountResource, "column_api/resources/bank_account_resource"
22
26
  autoload :EntityResource, "column_api/resources/entity_resource"
23
27
  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.4
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,13 @@ 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/ach_transfer.rb
63
+ - lib/column_api/objects/bank_account.rb
62
64
  - lib/column_api/objects/business_entity.rb
63
65
  - lib/column_api/objects/person_entity.rb
64
66
  - lib/column_api/resource.rb
67
+ - lib/column_api/resources/ach_transfer_resource.rb
68
+ - lib/column_api/resources/bank_account_resource.rb
65
69
  - lib/column_api/resources/entity_resource.rb
66
70
  - lib/column_api/version.rb
67
71
  - sig/column_api.rbs
@@ -85,7 +89,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
85
89
  - !ruby/object:Gem::Version
86
90
  version: '0'
87
91
  requirements: []
88
- rubygems_version: 3.4.10
92
+ rubygems_version: 3.4.6
89
93
  signing_key:
90
94
  specification_version: 4
91
95
  summary: Ruby bindings for Column API