-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #42 from retirable/trevor/ret-3407-add-counterpart…
…ies-support Add CounterParty API resource
- Loading branch information
Showing
6 changed files
with
65 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
module Unit | ||
class AchCounterparty < APIResource | ||
path '/counterparties' | ||
|
||
attribute :idempotency_key, Types::String # Optional | ||
attribute :tags, Types::Hash # Optional | ||
|
||
attribute :name, Types::String # Name of the account holder | ||
attribute :created_at, Types::DateTime | ||
attribute :routing_number, Types::String # Routing number of account. | ||
attribute :account_number, Types::String # Account number, together with the routingNumber forms the identifier of the account on the ACH network. | ||
attribute :account_type, Types::String # Account type, either Checking, Savings or Loan. Default is Checking. | ||
attribute :type, Types::String # Type of the counterparty, either Business, Person or Unknown. | ||
|
||
belongs_to :customer, class_name: 'Unit::IndividualCustomer' | ||
|
||
include ResourceOperations::List | ||
include ResourceOperations::Create | ||
include ResourceOperations::Save | ||
include ResourceOperations::Find | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
module Unit | ||
VERSION = '0.5.0' | ||
VERSION = '0.6.0' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
require 'spec_helper' | ||
require 'securerandom' | ||
|
||
RSpec.describe Unit::AchCounterparty do | ||
before do | ||
establish_connection_to_api! | ||
end | ||
|
||
let(:new_individual_customer) do | ||
Factory.create_individual_customer | ||
end | ||
|
||
it 'creates a counter party' do | ||
counterparty = Unit::AchCounterparty.create( | ||
idempotency_key: SecureRandom.uuid, | ||
name: 'Jane Doe', | ||
routing_number: '812345678', | ||
account_number: '12345569', | ||
account_type: 'Checking', | ||
type: 'Person', | ||
tags: { tag1: 'value1', tag2: 'value2' }, | ||
customer: new_individual_customer | ||
) | ||
|
||
expect(counterparty.name).to eq 'Jane Doe' | ||
expect(counterparty.routing_number).to eq '812345678' | ||
expect(counterparty.account_number).to eq '12345569' | ||
expect(counterparty.account_type).to eq 'Checking' | ||
expect(counterparty.type).to eq 'Person' | ||
expect(counterparty.tags[:tag1]).to eq 'value1' | ||
expect(counterparty.tags[:tag2]).to eq 'value2' | ||
expect(counterparty.customer.id).to eq new_individual_customer.id | ||
|
||
expect(Unit::AchCounterparty.find(counterparty.id).id).to eq counterparty.id | ||
expect( | ||
Unit::AchCounterparty.list(where: { customer_id: new_individual_customer.id }) | ||
).not_to be_empty | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters