unit_ruby_sdk 1.0.3 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +48 -0
- data/lib/unit/api_resources/account_resource.rb +1 -1
- data/lib/unit/api_resources/payment_resource.rb +24 -5
- data/lib/unit/api_resources/transaction_resource.rb +9 -0
- data/lib/unit/models/account/account.rb +108 -0
- data/lib/unit/models/account/credit/balance_history_request.rb +39 -0
- data/lib/unit/models/account/credit/close_account_request.rb +36 -0
- data/lib/unit/models/account/credit/create_account_request.rb +44 -0
- data/lib/unit/models/account/credit/freeze_account_request.rb +36 -0
- data/lib/unit/models/account/credit/list_account_params.rb +51 -0
- data/lib/unit/models/account/credit/patch_account_request.rb +36 -0
- data/lib/unit/models/payment/create_ach_payment_inline_request.rb +60 -0
- data/lib/unit/models/payment/create_payment_linked_request.rb +65 -0
- data/lib/unit/models/payment/create_wire_payment_request.rb +44 -0
- data/lib/unit/models/payment/create_with_plaid_token_request.rb +69 -0
- data/lib/unit/models/payment/get_request.rb +22 -0
- data/lib/unit/models/payment/list_payment_params.rb +79 -0
- data/lib/unit/models/payment/patch_ach_payment_request.rb +31 -0
- data/lib/unit/models/payment/payment.rb +142 -1
- data/lib/unit/models/transaction/patch_book_transaction_request.rb +39 -0
- data/lib/unit/models/transaction/patch_chargeback_transaction_request.rb +39 -0
- data/lib/unit/models/transaction/transaction.rb +24 -0
- data/lib/unit/types/counterparty.rb +31 -0
- data/lib/unit/types/wire_counterparty.rb +31 -0
- data/lib/unit/version.rb +1 -1
- data/lib/unit_ruby_sdk.rb +2 -0
- metadata +19 -2
@@ -0,0 +1,44 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Request to create a wire payment by calling Unit's API
|
4
|
+
# @see https://docs.unit.co/wires#wire-payments
|
5
|
+
module Unit
|
6
|
+
module Payment
|
7
|
+
class CreateWirePaymentRequest
|
8
|
+
attr_reader :account_id, :amount, :description, :counterparty, :idempotency_key, :tags
|
9
|
+
|
10
|
+
# @param account_id [String]
|
11
|
+
# @param amount [Integer]
|
12
|
+
# @param description [String]
|
13
|
+
# @param counterparty [WireCounterparty]
|
14
|
+
# @param idempotency_key [String] - optional
|
15
|
+
# @param tags [Hash] - optional
|
16
|
+
def initialize(account_id, amount, description, counterparty, idempotency_key = nil, tags = nil)
|
17
|
+
@account_id = account_id
|
18
|
+
@amount = amount
|
19
|
+
@description = description
|
20
|
+
@counterparty = counterparty
|
21
|
+
@idempotency_key = idempotency_key
|
22
|
+
@tags = tags
|
23
|
+
end
|
24
|
+
|
25
|
+
def to_json_api
|
26
|
+
payload = {
|
27
|
+
data: {
|
28
|
+
type: "wirePayment",
|
29
|
+
attributes: {
|
30
|
+
amount: amount,
|
31
|
+
description: description,
|
32
|
+
counterparty: counterparty.represent,
|
33
|
+
idempotencyKey: idempotency_key,
|
34
|
+
tags: tags
|
35
|
+
},
|
36
|
+
relationships: { account: Unit::Types::Relationship.new("account", account_id).to_hash }
|
37
|
+
}
|
38
|
+
}
|
39
|
+
payload[:data][:attributes].compact!
|
40
|
+
payload.to_json
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Request to create a new ach payment with a plaid token by calling Unit's API
|
4
|
+
# @see https://docs.unit.co/ach-origination#create-ach-payment-with-plaid-token
|
5
|
+
module Unit
|
6
|
+
module Payment
|
7
|
+
class CreateWithPlaidTokenRequest
|
8
|
+
attr_reader :account_id, :amount, :direction, :description,
|
9
|
+
:plaid_processor_token, :addenda, :idempotency_key,
|
10
|
+
:counterparty_name, :tags, :verify_counterparty_balance,
|
11
|
+
:same_day, :sec_code
|
12
|
+
|
13
|
+
# @param account_id [String]
|
14
|
+
# @param amount [Integer]
|
15
|
+
# @param direction [String]
|
16
|
+
# @param description [String]
|
17
|
+
# @param plaid_processor_token [String]
|
18
|
+
# @param addenda [String] - optional
|
19
|
+
# @param idempotency_key [String] - optional
|
20
|
+
# @param counterparty_name [String] - optional
|
21
|
+
# @param tags [Hash] - optional
|
22
|
+
# @param verify_counterparty_balance [Boolean] - optional
|
23
|
+
# @param same_day [Boolean] - optional
|
24
|
+
# @param sec_code [String] - optional
|
25
|
+
def initialize(account_id, amount, direction, description, plaid_processor_token,
|
26
|
+
addenda = nil, idempotency_key = nil, counterparty_name = nil, tags = nil,
|
27
|
+
verify_counterparty_balance = nil, same_day = nil, sec_code = nil)
|
28
|
+
@account_id = account_id
|
29
|
+
@amount = amount
|
30
|
+
@direction = direction
|
31
|
+
@description = description
|
32
|
+
@plaid_processor_token = plaid_processor_token
|
33
|
+
@addenda = addenda
|
34
|
+
@idempotency_key = idempotency_key
|
35
|
+
@counterparty_name = counterparty_name
|
36
|
+
@tags = tags
|
37
|
+
@verify_counterparty_balance = verify_counterparty_balance
|
38
|
+
@same_day = same_day
|
39
|
+
@sec_code = sec_code
|
40
|
+
end
|
41
|
+
|
42
|
+
def to_json_api
|
43
|
+
payload = {
|
44
|
+
"data": {
|
45
|
+
"type": "achPayment",
|
46
|
+
"attributes": {
|
47
|
+
amount: amount,
|
48
|
+
direction: direction,
|
49
|
+
description: description,
|
50
|
+
plaidProcessorToken: plaid_processor_token,
|
51
|
+
addenda: addenda,
|
52
|
+
idempotencyKey: idempotency_key,
|
53
|
+
counterpartyName: counterparty_name,
|
54
|
+
tags: tags,
|
55
|
+
verifyCounterpartyBalance: verify_counterparty_balance,
|
56
|
+
sameDay: same_day,
|
57
|
+
secCode: sec_code
|
58
|
+
},
|
59
|
+
"relationships": {
|
60
|
+
"account": Unit::Types::Relationship.new("account", account_id).to_hash
|
61
|
+
}
|
62
|
+
}
|
63
|
+
}
|
64
|
+
payload[:data][:attributes].compact!
|
65
|
+
payload.to_json
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Request to get payment by id
|
4
|
+
# @see https://docs.unit.co/payments#get-specific-payment
|
5
|
+
module Unit
|
6
|
+
module Payment
|
7
|
+
class GetRequest
|
8
|
+
attr_reader :payment_id, :include
|
9
|
+
|
10
|
+
# @param payment_id [String]
|
11
|
+
# @param include [Array<String>] - optional
|
12
|
+
def initialize(payment_id, include = nil)
|
13
|
+
@payment_id = payment_id
|
14
|
+
@include = include
|
15
|
+
end
|
16
|
+
|
17
|
+
def to_hash
|
18
|
+
{ include: include&.join(",") }.compact
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Params to list payments
|
4
|
+
# @see https://docs.unit.co/payments#list-payments
|
5
|
+
|
6
|
+
module Unit
|
7
|
+
module Payment
|
8
|
+
class ListPaymentParams
|
9
|
+
attr_reader :limit, :offset, :account_id, :customer_id, :counterparty_account_id, :tags, :status, :type, :direction, :since, :_until, :from_amount, :to_amount, :recurring_payment_id, :feature, :sort, :include
|
10
|
+
|
11
|
+
# @param limit [Integer] - optional
|
12
|
+
# @param offset [Integer] - optional
|
13
|
+
# @param account_id [String] - optional
|
14
|
+
# @param customer_id [String] - optional
|
15
|
+
# @param counterparty_account_id [String] - optional
|
16
|
+
# @param tags [Hash] - optional
|
17
|
+
# @param status [Array<String>] - optional
|
18
|
+
# @param type [Array<String>] - optional
|
19
|
+
# @param direction [Array<String>] - optional
|
20
|
+
# @param since [String] - optional
|
21
|
+
# @param _until [String] - optional
|
22
|
+
# @param from_amount [Integer] - optional
|
23
|
+
# @param to_amount [Integer] - optional
|
24
|
+
# @param recurring_payment_id [String] - optional
|
25
|
+
# @param feature [Array<String>] - optional
|
26
|
+
# @param sort [String] - optional
|
27
|
+
# @param include [Array<String>] - optional
|
28
|
+
def initialize(limit = PAYMENT_LIMIT, offset = PAYMENT_OFFSET, account_id = nil, customer_id = nil,
|
29
|
+
counterparty_account_id = nil, tags = nil, status = nil,
|
30
|
+
type = nil, direction = nil, since = nil, _until = nil,
|
31
|
+
from_amount = nil, to_amount = nil, recurring_payment_id = nil,
|
32
|
+
feature = nil, sort = nil, include = nil)
|
33
|
+
@limit = limit
|
34
|
+
@offset = offset
|
35
|
+
@account_id = account_id
|
36
|
+
@customer_id = customer_id
|
37
|
+
@counterparty_account_id = counterparty_account_id
|
38
|
+
@tags = tags
|
39
|
+
@status = status
|
40
|
+
@type = type
|
41
|
+
@direction = direction
|
42
|
+
@since = since
|
43
|
+
@until = _until
|
44
|
+
@from_amount = from_amount
|
45
|
+
@to_amount = to_amount
|
46
|
+
@recurring_payment_id = recurring_payment_id
|
47
|
+
@feature = feature
|
48
|
+
@sort = sort
|
49
|
+
@include = include
|
50
|
+
end
|
51
|
+
|
52
|
+
def to_hash
|
53
|
+
params = {
|
54
|
+
"page[limit]": limit,
|
55
|
+
"page[offset]": offset,
|
56
|
+
"filter[accountId]": account_id,
|
57
|
+
"filter[customerId]": customer_id,
|
58
|
+
"filter[counterpartyAccountId]": counterparty_account_id,
|
59
|
+
"filter[tags]": tags,
|
60
|
+
"filter[since]": since,
|
61
|
+
"filter[until]": _until,
|
62
|
+
"filter[fromAmount]": from_amount,
|
63
|
+
"filter[toAmount]": to_amount,
|
64
|
+
"filter[recurringPaymentId]": recurring_payment_id,
|
65
|
+
sort: sort,
|
66
|
+
include: include&.join(",")
|
67
|
+
}
|
68
|
+
filters = %i[status type direction feature]
|
69
|
+
filters.each do |filter|
|
70
|
+
values = send(filter)
|
71
|
+
values&.each_with_index&.map do |val, index|
|
72
|
+
params.merge!({ "filter[#{filter}][#{index}]": val })
|
73
|
+
end
|
74
|
+
end
|
75
|
+
params.compact
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Request to update an ACH payment
|
4
|
+
# @see https://docs.unit.co/ach-origination#update-ach-payment
|
5
|
+
module Unit
|
6
|
+
module Payment
|
7
|
+
class PatchAchPaymentRequest
|
8
|
+
attr_reader :payment_id, :tags
|
9
|
+
|
10
|
+
# @param payment_id [String]
|
11
|
+
# @param tags [Hash] - optional
|
12
|
+
def initialize(payment_id, tags = nil)
|
13
|
+
@payment_id = payment_id
|
14
|
+
@tags = tags
|
15
|
+
end
|
16
|
+
|
17
|
+
def to_json_api
|
18
|
+
payload = {
|
19
|
+
"data": {
|
20
|
+
"type": "achPayment",
|
21
|
+
"attributes": {
|
22
|
+
tags: tags
|
23
|
+
}
|
24
|
+
}
|
25
|
+
}
|
26
|
+
payload[:data][:attributes].compact!
|
27
|
+
payload.to_json
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -2,9 +2,17 @@
|
|
2
2
|
|
3
3
|
module Unit
|
4
4
|
module Payment
|
5
|
+
PAYMENT_LIMIT = 100
|
6
|
+
PAYMENT_OFFSET = 0
|
5
7
|
autoload :CreateBookPaymentRequest, "unit/models/payment/create_book_payment_request"
|
6
8
|
autoload :PatchBookPaymentRequest, "unit/models/payment/patch_book_payment_request"
|
7
|
-
|
9
|
+
autoload :CreateAchPaymentInlineRequest, "unit/models/payment/create_ach_payment_inline_request"
|
10
|
+
autoload :CreatePaymentLinkedRequest, "unit/models/payment/create_payment_linked_request"
|
11
|
+
autoload :CreateWithPlaidTokenRequest, "unit/models/payment/create_with_plaid_token_request"
|
12
|
+
autoload :PatchReceivedPaymentRequest, "unit/models/payment/patch_received_payment_request"
|
13
|
+
autoload :CreateWirePaymentRequest, "unit/models/payment/create_wire_payment_request"
|
14
|
+
autoload :ListPaymentParams, "unit/models/payment/list_payment_params"
|
15
|
+
autoload :GetRequest, "unit/models/payment/get_request"
|
8
16
|
class << self
|
9
17
|
# Create a new book payment by calling Unit's API
|
10
18
|
# @see https://docs.unit.co/book-payments#book-payments
|
@@ -32,6 +40,139 @@ module Unit
|
|
32
40
|
request = Unit::Payment::PatchBookPaymentRequest.new(payment_id, tags)
|
33
41
|
Unit::Resource::PaymentResource.update_payment(request)
|
34
42
|
end
|
43
|
+
|
44
|
+
# Create a new ach payment to inline counterparty by calling Unit's API
|
45
|
+
# @see https://docs.unit.co/ach-origination#payment-inline-counterparty
|
46
|
+
# @param account_id [String]
|
47
|
+
# @param amount [Integer]
|
48
|
+
# @param direction [String]
|
49
|
+
# @param counterparty [Counterparty]
|
50
|
+
# @param description [String]
|
51
|
+
# @param addenda [String] - optional
|
52
|
+
# @param idempotency_key [String] - optional
|
53
|
+
# @param tags [Hash] - optional
|
54
|
+
# @param same_day [Boolean] - optional
|
55
|
+
# @param sec_code [String] - optional
|
56
|
+
def create_ach_payment_inline(account_id:, amount:, direction:, counterparty:,
|
57
|
+
description:, addenda: nil, idempotency_key: nil, tags: nil,
|
58
|
+
same_day: nil, sec_code: nil)
|
59
|
+
request = Unit::Payment::CreateAchPaymentInlineRequest.new(account_id, amount, direction, counterparty, description,
|
60
|
+
addenda, idempotency_key, tags, same_day, sec_code)
|
61
|
+
Unit::Resource::PaymentResource.create_payment(request)
|
62
|
+
end
|
63
|
+
|
64
|
+
# Create a new ach payment to linked counterparty by calling Unit's API
|
65
|
+
# @see https://docs.unit.co/ach-origination#payment-linked-counterparty
|
66
|
+
# @param account_id [String]
|
67
|
+
# @param counterparty_id [String]
|
68
|
+
# @param amount [Integer]
|
69
|
+
# @param direction [String]
|
70
|
+
# @param description [String]
|
71
|
+
# @param addenda [String] - optional
|
72
|
+
# @param idempotency_key [String] - optional
|
73
|
+
# @param tags [Hash] - optional
|
74
|
+
# @param verify_counterparty_balance [Boolean] - optional
|
75
|
+
# @param same_day [Boolean] - optional
|
76
|
+
# @param sec_code [String] - optional
|
77
|
+
def create_ach_payment_linked(account_id:, counterparty_id:, amount:, direction:,
|
78
|
+
description:, addenda: nil, idempotency_key: nil, tags: nil,
|
79
|
+
verify_counterparty_balance: nil, same_day: nil, sec_code: nil)
|
80
|
+
request = Unit::Payment::CreatePaymentLinkedRequest.new(account_id, counterparty_id, amount, direction,
|
81
|
+
description, addenda, idempotency_key, tags,
|
82
|
+
verify_counterparty_balance, same_day, sec_code)
|
83
|
+
Unit::Resource::PaymentResource.create_payment(request)
|
84
|
+
end
|
85
|
+
|
86
|
+
# Create a new ach payment with a plaid token by calling Unit's API
|
87
|
+
# @see https://docs.unit.co/ach-origination#create-ach-payment-with-plaid-token
|
88
|
+
# @param account_id [String]
|
89
|
+
# @param amount [Integer]
|
90
|
+
# @param direction [String]
|
91
|
+
# @param description [String]
|
92
|
+
# @param plaid_processor_token [String]
|
93
|
+
# @param addenda [String] - optional
|
94
|
+
# @param idempotency_key [String] - optional
|
95
|
+
# @param counterparty_name [String] - optional
|
96
|
+
# @param tags [Hash] - optional
|
97
|
+
# @param verify_counterparty_balance [Boolean] - optional
|
98
|
+
# @param same_day [Boolean] - optional
|
99
|
+
# @param sec_code [String] - optional
|
100
|
+
def create_ach_payment_with_plaid_token(account_id:, amount:, direction:, description:, plaid_processor_token:,
|
101
|
+
addenda: nil, idempotency_key: nil, counterparty_name: nil, tags: nil,
|
102
|
+
verify_counterparty_balance: nil, same_day: nil, sec_code: nil)
|
103
|
+
request = Unit::Payment::CreateWithPlaidTokenRequest.new(account_id, amount, direction, description, plaid_processor_token,
|
104
|
+
addenda, idempotency_key, counterparty_name, tags,
|
105
|
+
verify_counterparty_balance, same_day, sec_code)
|
106
|
+
Unit::Resource::PaymentResource.create_payment(request)
|
107
|
+
end
|
108
|
+
|
109
|
+
# Update an ACH payment by calling Unit's API
|
110
|
+
# @see https://docs.unit.co/ach-origination#update-ach-payment
|
111
|
+
# @param payment_id [String]
|
112
|
+
# @param tags [Hash] - optional
|
113
|
+
def update_ach_payment(payment_id:, tags: nil)
|
114
|
+
request = Unit::Payment::PatchAchPaymentRequest.new(payment_id, tags)
|
115
|
+
Unit::Resource::PaymentResource.update_payment(request)
|
116
|
+
end
|
117
|
+
|
118
|
+
# Cancel a payment by calling Unit's API
|
119
|
+
# @see https://docs.unit.co/ach-origination#cancel-ach-payment
|
120
|
+
# @param payment_id [String]
|
121
|
+
def cancel_payment(payment_id:)
|
122
|
+
Unit::Resource::PaymentResource.cancel_payment(payment_id)
|
123
|
+
end
|
124
|
+
|
125
|
+
# Create a wire payment by calling Unit's API
|
126
|
+
# @see https://docs.unit.co/wires#wire-payments
|
127
|
+
# @param account_id [String]
|
128
|
+
# @param amount [Integer]
|
129
|
+
# @param description [String]
|
130
|
+
# @param counterparty [WireCounterparty]
|
131
|
+
# @param idempotency_key [String] - optional
|
132
|
+
# @param tags [Hash] - optional
|
133
|
+
def create_wire_payment(account_id:, amount:, description:, counterparty:, idempotency_key: nil, tags: nil)
|
134
|
+
request = Unit::Payment::CreateWirePaymentRequest.new(account_id, amount, description, counterparty, idempotency_key, tags)
|
135
|
+
Unit::Resource::PaymentResource.create_payment(request)
|
136
|
+
end
|
137
|
+
|
138
|
+
# List payments by calling Unit's API
|
139
|
+
# @see https://docs.unit.co/payments#list-payments
|
140
|
+
# @param limit [Integer] - optional
|
141
|
+
# @param offset [Integer] - optional
|
142
|
+
# @param account_id [String] - optional
|
143
|
+
# @param customer_id [String] - optional
|
144
|
+
# @param counterparty_account_id [String] - optional
|
145
|
+
# @param tags [Hash] - optional
|
146
|
+
# @param status [Array<String>] - optional
|
147
|
+
# @param type [Array<String>] - optional
|
148
|
+
# @param direction [Array<String>] - optional
|
149
|
+
# @param since [String] - optional
|
150
|
+
# @param _until [String] - optional
|
151
|
+
# @param from_amount [Integer] - optional
|
152
|
+
# @param to_amount [Integer] - optional
|
153
|
+
# @param recurring_payment_id [String] - optional
|
154
|
+
# @param feature [Array<String>] - optional
|
155
|
+
# @param sort [String] - optional
|
156
|
+
# @param include [Array<String>] - optional
|
157
|
+
def list_payments(limit: PAYMENT_LIMIT, offset: PAYMENT_OFFSET, account_id: nil, customer_id: nil,
|
158
|
+
counterparty_account_id: nil, tags: nil, status: nil,
|
159
|
+
type: nil, direction: nil, since: nil, until_: nil,
|
160
|
+
from_amount: nil, to_amount: nil, recurring_payment_id: nil,
|
161
|
+
feature: nil, sort: nil, include: nil)
|
162
|
+
request = Unit::Payment::ListPaymentParams.new(limit, offset, account_id, customer_id,
|
163
|
+
counterparty_account_id, tags, status, type, direction, since, until_,
|
164
|
+
from_amount, to_amount, recurring_payment_id, feature, sort, include)
|
165
|
+
Unit::Resource::PaymentResource.list_payments(request)
|
166
|
+
end
|
167
|
+
|
168
|
+
# Get a payment by calling Unit's API
|
169
|
+
# @see https://docs.unit.co/payments#get-specific-payment
|
170
|
+
# @param payment_id [String]
|
171
|
+
# @param include [Array<String>] - optional
|
172
|
+
def get_payment(payment_id:, include: nil)
|
173
|
+
request = Unit::Payment::GetRequest.new(payment_id, include)
|
174
|
+
Unit::Resource::PaymentResource.get_payment(request)
|
175
|
+
end
|
35
176
|
end
|
36
177
|
end
|
37
178
|
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Request to update a transaction's tags
|
4
|
+
# @see https://docs.unit.co/transactions#update-transaction-tags
|
5
|
+
module Unit
|
6
|
+
module Transaction
|
7
|
+
class PatchBookTransactionRequest
|
8
|
+
attr_reader :account_id, :transaction_id, :summary, :tags
|
9
|
+
|
10
|
+
# @param account_id [String]
|
11
|
+
# @param transaction_id [String]
|
12
|
+
# @param summary [String] - optional
|
13
|
+
# @param tags [Hash] - optional
|
14
|
+
def initialize(account_id, transaction_id, summary = nil, tags = nil)
|
15
|
+
@account_id = account_id
|
16
|
+
@transaction_id = transaction_id
|
17
|
+
@summary = summary
|
18
|
+
@tags = tags
|
19
|
+
end
|
20
|
+
|
21
|
+
def to_json_api
|
22
|
+
payload = {
|
23
|
+
data: {
|
24
|
+
type: "bookTransaction",
|
25
|
+
attributes: {
|
26
|
+
summary: summary,
|
27
|
+
tags: tags
|
28
|
+
},
|
29
|
+
relationships: {
|
30
|
+
account: Unit::Types::Relationship.new("account", account_id).to_hash
|
31
|
+
}
|
32
|
+
}
|
33
|
+
}
|
34
|
+
payload[:data][:attributes].compact!
|
35
|
+
payload.to_json
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Request to update a transaction's tags
|
4
|
+
# @see https://docs.unit.co/transactions#update-transaction-tags
|
5
|
+
module Unit
|
6
|
+
module Transaction
|
7
|
+
class PatchChargebackTransactionRequest
|
8
|
+
attr_reader :account_id, :transaction_id, :summary, :tags
|
9
|
+
|
10
|
+
# @param account_id [String]
|
11
|
+
# @param transaction_id [String]
|
12
|
+
# @param summary [String] - optional
|
13
|
+
# @param tags [Hash] - optional
|
14
|
+
def initialize(account_id, transaction_id, summary = nil, tags = nil)
|
15
|
+
@account_id = account_id
|
16
|
+
@summary = summary
|
17
|
+
@tags = tags
|
18
|
+
@transaction_id = transaction_id
|
19
|
+
end
|
20
|
+
|
21
|
+
def to_json_api
|
22
|
+
payload = {
|
23
|
+
data: {
|
24
|
+
type: "chargebackTransaction",
|
25
|
+
attributes: {
|
26
|
+
summary: summary,
|
27
|
+
tags: tags
|
28
|
+
},
|
29
|
+
relationships: {
|
30
|
+
account: Unit::Types::Relationship.new("account", account_id).to_hash
|
31
|
+
}
|
32
|
+
}
|
33
|
+
}
|
34
|
+
payload[:data][:attributes].compact!
|
35
|
+
payload.to_json
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -7,6 +7,8 @@ module Unit
|
|
7
7
|
autoload :GetTransactionParams, "unit/models/transaction/get_transaction_params"
|
8
8
|
autoload :ListTransactionParams, "unit/models/transaction/list_transaction_params"
|
9
9
|
autoload :PatchTagsRequest, "unit/models/transaction/patch_tags_request"
|
10
|
+
autoload :PatchBookTransactionRequest, "unit/models/transaction/patch_book_transaction_request"
|
11
|
+
autoload :PatchChargebackTransactionRequest, "unit/models/transaction/patch_chargeback_transaction_request"
|
10
12
|
|
11
13
|
class << self
|
12
14
|
# Get a transaction by id
|
@@ -55,6 +57,28 @@ module Unit
|
|
55
57
|
request = PatchTagsRequest.new(account_id, transaction_id, tags)
|
56
58
|
Unit::Resource::TransactionResource.update_tags(request)
|
57
59
|
end
|
60
|
+
|
61
|
+
# Update a book transaction
|
62
|
+
# @see https://docs.unit.co/transactions#update-book-transaction
|
63
|
+
# @param account_id [String]
|
64
|
+
# @param transaction_id [String]
|
65
|
+
# @param summary [String] - optional
|
66
|
+
# @param tags [Hash] - optional
|
67
|
+
def update_book_transaction(account_id:, transaction_id:, summary:, tags: nil)
|
68
|
+
request = PatchBookTransactionRequest.new(account_id, transaction_id, summary, tags)
|
69
|
+
Unit::Resource::TransactionResource.update_transaction(request)
|
70
|
+
end
|
71
|
+
|
72
|
+
# Update a chargeback transaction
|
73
|
+
# @see https://docs.unit.co/transactions#update-chargeback-transaction
|
74
|
+
# @param account_id [String]
|
75
|
+
# @param transaction_id [String]
|
76
|
+
# @param summary [String] - optional
|
77
|
+
# @param tags [Hash] - optional
|
78
|
+
def update_chargeback_transaction(account_id:, transaction_id:, summary:, tags: nil)
|
79
|
+
request = PatchChargebackTransactionRequest.new(account_id, transaction_id, summary, tags)
|
80
|
+
Unit::Resource::TransactionResource.update_transaction(request)
|
81
|
+
end
|
58
82
|
end
|
59
83
|
end
|
60
84
|
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# @see https://docs.unit.co/types/#counterparty
|
4
|
+
module Unit
|
5
|
+
module Types
|
6
|
+
class Counterparty
|
7
|
+
attr_reader :name, :account_number, :routing_number, :account_type
|
8
|
+
|
9
|
+
# @param name [String]
|
10
|
+
# @param account_number [String]
|
11
|
+
# @param routing_number [String]
|
12
|
+
# @param account_type [String]
|
13
|
+
def initialize(name, account_number, routing_number, account_type)
|
14
|
+
@name = name
|
15
|
+
@account_number = account_number
|
16
|
+
@routing_number = routing_number
|
17
|
+
@account_type = account_type
|
18
|
+
end
|
19
|
+
|
20
|
+
def represent
|
21
|
+
params = {
|
22
|
+
name: name,
|
23
|
+
accountNumber: account_number,
|
24
|
+
routingNumber: routing_number,
|
25
|
+
accountType: account_type
|
26
|
+
}
|
27
|
+
params.compact
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# @see https://docs.unit.co/types/#wire-counterparty
|
4
|
+
module Unit
|
5
|
+
module Types
|
6
|
+
class WireCounterparty
|
7
|
+
attr_reader :name, :account_number, :routing_number, :address
|
8
|
+
|
9
|
+
# @param name [String]
|
10
|
+
# @param account_number [String]
|
11
|
+
# @param routing_number [String]
|
12
|
+
# @param address [Address]
|
13
|
+
def initialize(name, account_number, routing_number, address)
|
14
|
+
@name = name
|
15
|
+
@account_number = account_number
|
16
|
+
@routing_number = routing_number
|
17
|
+
@address = address
|
18
|
+
end
|
19
|
+
|
20
|
+
def represent
|
21
|
+
params = {
|
22
|
+
name: name,
|
23
|
+
accountNumber: account_number,
|
24
|
+
routingNumber: routing_number,
|
25
|
+
address: address&.represent
|
26
|
+
}
|
27
|
+
params.compact
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/lib/unit/version.rb
CHANGED
data/lib/unit_ruby_sdk.rb
CHANGED
@@ -36,6 +36,8 @@ module Unit
|
|
36
36
|
autoload :BusinessContact, "unit/types/business_contact"
|
37
37
|
autoload :DeviceFingerprint, "unit/types/device_fingerprint"
|
38
38
|
autoload :EvaluationParams, "unit/types/evaluation_params"
|
39
|
+
autoload :Counterparty, "unit/types/counterparty"
|
40
|
+
autoload :WireCounterparty, "unit/types/wire_counterparty"
|
39
41
|
autoload :FullName, "unit/types/full_name"
|
40
42
|
autoload :Officer, "unit/types/officer"
|
41
43
|
autoload :Phone, "unit/types/phone"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unit_ruby_sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Unit
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-03-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: factory_bot_rails
|
@@ -109,6 +109,12 @@ files:
|
|
109
109
|
- lib/unit/errors/unit_error.rb
|
110
110
|
- lib/unit/errors/unit_error_payload.rb
|
111
111
|
- lib/unit/models/account/account.rb
|
112
|
+
- lib/unit/models/account/credit/balance_history_request.rb
|
113
|
+
- lib/unit/models/account/credit/close_account_request.rb
|
114
|
+
- lib/unit/models/account/credit/create_account_request.rb
|
115
|
+
- lib/unit/models/account/credit/freeze_account_request.rb
|
116
|
+
- lib/unit/models/account/credit/list_account_params.rb
|
117
|
+
- lib/unit/models/account/credit/patch_account_request.rb
|
112
118
|
- lib/unit/models/account/deposit/account_owners_request.rb
|
113
119
|
- lib/unit/models/account/deposit/balance_history_request.rb
|
114
120
|
- lib/unit/models/account/deposit/close_deposit_account_request.rb
|
@@ -157,7 +163,14 @@ files:
|
|
157
163
|
- lib/unit/models/customer/patch_business_customer_request.rb
|
158
164
|
- lib/unit/models/customer/patch_individual_customer_request.rb
|
159
165
|
- lib/unit/models/customer/remove_authorized_users_request.rb
|
166
|
+
- lib/unit/models/payment/create_ach_payment_inline_request.rb
|
160
167
|
- lib/unit/models/payment/create_book_payment_request.rb
|
168
|
+
- lib/unit/models/payment/create_payment_linked_request.rb
|
169
|
+
- lib/unit/models/payment/create_wire_payment_request.rb
|
170
|
+
- lib/unit/models/payment/create_with_plaid_token_request.rb
|
171
|
+
- lib/unit/models/payment/get_request.rb
|
172
|
+
- lib/unit/models/payment/list_payment_params.rb
|
173
|
+
- lib/unit/models/payment/patch_ach_payment_request.rb
|
161
174
|
- lib/unit/models/payment/patch_book_payment_request.rb
|
162
175
|
- lib/unit/models/payment/payment.rb
|
163
176
|
- lib/unit/models/statement/get_bank_verification_pdf.rb
|
@@ -167,6 +180,8 @@ files:
|
|
167
180
|
- lib/unit/models/statement/statement.rb
|
168
181
|
- lib/unit/models/transaction/get_transaction_params.rb
|
169
182
|
- lib/unit/models/transaction/list_transaction_params.rb
|
183
|
+
- lib/unit/models/transaction/patch_book_transaction_request.rb
|
184
|
+
- lib/unit/models/transaction/patch_chargeback_transaction_request.rb
|
170
185
|
- lib/unit/models/transaction/patch_tags_request.rb
|
171
186
|
- lib/unit/models/transaction/transaction.rb
|
172
187
|
- lib/unit/models/unit_resource.rb
|
@@ -176,6 +191,7 @@ files:
|
|
176
191
|
- lib/unit/types/beneficial_owner.rb
|
177
192
|
- lib/unit/types/business_contact.rb
|
178
193
|
- lib/unit/types/coordinates.rb
|
194
|
+
- lib/unit/types/counterparty.rb
|
179
195
|
- lib/unit/types/device_fingerprint.rb
|
180
196
|
- lib/unit/types/document_file_type.rb
|
181
197
|
- lib/unit/types/evaluation_params.rb
|
@@ -186,6 +202,7 @@ files:
|
|
186
202
|
- lib/unit/types/relationship.rb
|
187
203
|
- lib/unit/types/relationship_array.rb
|
188
204
|
- lib/unit/types/restricted_resource.rb
|
205
|
+
- lib/unit/types/wire_counterparty.rb
|
189
206
|
- lib/unit/utils/http_helper.rb
|
190
207
|
- lib/unit/version.rb
|
191
208
|
- lib/unit_ruby_sdk.rb
|