Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CounterParty API resource #42

Merged
merged 1 commit into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
unit-ruby (0.5.0)
unit-ruby (0.6.0)
activesupport (>= 6.1.5, < 7.1.0)
faraday (~> 1.8.0)
faraday_middleware (~> 1.0.0)
Expand Down
1 change: 1 addition & 0 deletions lib/unit-ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
require 'unit-ruby/application_form'
require 'unit-ruby/atm_location'
require 'unit-ruby/authorization'
require 'unit-ruby/ach_counterparty'
require 'unit-ruby/customer_token_verification'
require 'unit-ruby/customer_token'
require 'unit-ruby/deposit_account'
Expand Down
22 changes: 22 additions & 0 deletions lib/unit-ruby/ach_counterparty.rb
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
2 changes: 1 addition & 1 deletion lib/unit-ruby/version.rb
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
39 changes: 39 additions & 0 deletions spec/features/ach_counterparty_spec.rb
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
2 changes: 1 addition & 1 deletion spec/version_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

RSpec.describe Unit do
it 'returns the correct version' do
expect(Unit::VERSION).to eq '0.5.0'
expect(Unit::VERSION).to eq '0.6.0'
end
end
Loading