unit_ruby_sdk 1.3.0 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +7 -1
- data/lib/unit/api_resources/check_payment_resource.rb +59 -0
- data/lib/unit/models/application/create_individual_application_request.rb +1 -0
- data/lib/unit/models/check_payment/check_payment.rb +74 -0
- data/lib/unit/models/check_payment/get_image_request.rb +19 -0
- data/lib/unit/models/check_payment/get_request.rb +22 -0
- data/lib/unit/models/check_payment/list_check_payment_params.rb +63 -0
- data/lib/unit/models/check_payment/return_check_payment_request.rb +29 -0
- data/lib/unit/version.rb +1 -1
- data/lib/unit_ruby_sdk.rb +2 -0
- metadata +9 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4427f4ca95ba8cf893f2e7c9ff5c21605419518429095a8aff3a41cd8876fed9
|
4
|
+
data.tar.gz: 672fd892ed734631361b0f94b52b3ca95bc88780a6f4f9942b278c956526f245
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bef4edade650df1097bda85a10b7d81c614a4dc0d9e05247335e25d079a00fb2da81b71fd440963bd7bce69fede707bafd2c5c56230725dc9998b2ffdc8418af
|
7
|
+
data.tar.gz: a5db0ecc8a1baa2a2d48f523f4e4e05ad8dc98c58ba9da7fb82bd4acd8be4ef22e1502607f764eec055bdc92e2b3b947fef9b479f8ac83841725c90bacc14c5a
|
data/README.md
CHANGED
@@ -262,7 +262,7 @@ puts counterparty["id"]
|
|
262
262
|
response = Unit::RecurringPayment.create_recurring_credit_book_payment(account_id: "27573", counterparty_id: "36099", amount: 1000,
|
263
263
|
description: "test payme", schedule: schedule)
|
264
264
|
recurring_payment = response.data
|
265
|
-
puts recurring_payment
|
265
|
+
puts recurring_payment["id"]
|
266
266
|
```
|
267
267
|
|
268
268
|
|
@@ -323,6 +323,12 @@ control_agreement = response.data
|
|
323
323
|
puts control_agreement["id"]
|
324
324
|
```
|
325
325
|
|
326
|
+
### Get a check payment by id
|
327
|
+
```ruby
|
328
|
+
response = Unit::CheckPayment.get_payment(payment_id: "199")
|
329
|
+
check_payment = response.data
|
330
|
+
puts check_payment["id"]
|
331
|
+
```
|
326
332
|
### Logging Errors
|
327
333
|
|
328
334
|
### Handling Response
|
@@ -0,0 +1,59 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "./base_resource"
|
4
|
+
require_relative "../utils/http_helper"
|
5
|
+
require "json"
|
6
|
+
|
7
|
+
# class for creating request for check payments to Unit API and parsing responses
|
8
|
+
# @see https://docs.unit.co/check-payments
|
9
|
+
module Unit
|
10
|
+
module Resource
|
11
|
+
class CheckPaymentResource < Unit::Resource::BaseResource
|
12
|
+
class << self
|
13
|
+
# Get a check payment by id by calling Unit's API
|
14
|
+
# @param params [GetRequest]
|
15
|
+
# @return [UnitResponse, UnitError]
|
16
|
+
def get(params)
|
17
|
+
payload = params.to_hash
|
18
|
+
response = HttpHelper.get("#{api_url}/check-payments/#{params.payment_id}", params: payload, headers: headers)
|
19
|
+
response_handler(response)
|
20
|
+
end
|
21
|
+
|
22
|
+
# Get a list of check payments by calling Unit's API
|
23
|
+
# @param params [ListCheckPaymentParams]
|
24
|
+
# @return [UnitResponse, UnitError]
|
25
|
+
def list(params = nil)
|
26
|
+
response = HttpHelper.get("#{api_url}/check-payments", params: params.to_hash, headers: headers)
|
27
|
+
response_handler(response)
|
28
|
+
end
|
29
|
+
|
30
|
+
# Get a check payment image by calling Unit's API
|
31
|
+
# @param request [GetImageRequest]
|
32
|
+
# @return [UnitResponse, UnitError]
|
33
|
+
def get_image(request)
|
34
|
+
side = request.is_front_side ? "front" : "back"
|
35
|
+
response = HttpHelper.get("#{api_url}/check-payments/#{request.payment_id}/#{side}", headers: headers, response_type: "image")
|
36
|
+
file_response_handler(response)
|
37
|
+
end
|
38
|
+
|
39
|
+
# Return a check payment by calling Unit's API
|
40
|
+
# @param request [ReturnCheckPaymentRequest]
|
41
|
+
# @return [UnitResponse, UnitError]
|
42
|
+
def return_payment(request)
|
43
|
+
payload = request.to_json_api
|
44
|
+
response = HttpHelper.post("#{api_url}/check-payments/#{request.payment_id}/return", body: payload, headers: headers)
|
45
|
+
response_handler(response)
|
46
|
+
end
|
47
|
+
|
48
|
+
# Approve Check Payment Additional Verification by calling Unit's API
|
49
|
+
# @param payment_id [String]
|
50
|
+
# @return [UnitResponse, UnitError]
|
51
|
+
def approve_payment_verification(payment_id)
|
52
|
+
payload = { data: { type: "additionalVerification" } }.to_json
|
53
|
+
response = HttpHelper.post("#{api_url}/check-payments/#{payment_id}/approve", body: payload, headers: headers)
|
54
|
+
response_handler(response)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Unit
|
4
|
+
module CheckPayment
|
5
|
+
CHECK_PAYMENT_LIMIT = 100
|
6
|
+
CHECK_PAYMENT_OFFSET = 0
|
7
|
+
|
8
|
+
autoload :GetRequest, "unit/models/check_payment/get_request"
|
9
|
+
autoload :ListPaymentParams, "unit/models/check_payment/list_check_payment_params"
|
10
|
+
autoload :GetImageRequest, "unit/models/check_payment/get_image_request"
|
11
|
+
autoload :ReturnCheckPaymentRequest, "unit/models/check_payment/return_check_payment_request"
|
12
|
+
|
13
|
+
class << self
|
14
|
+
# Get a check payment by id
|
15
|
+
# @see https://docs.unit.co/check-payments#get-specific-check-payment
|
16
|
+
# @param payment_id [String]
|
17
|
+
# @param include [Array<String>] - optional
|
18
|
+
def get_payment(payment_id:, include: nil)
|
19
|
+
request = GetRequest.new(payment_id, include)
|
20
|
+
Unit::Resource::CheckPaymentResource.get(request)
|
21
|
+
end
|
22
|
+
|
23
|
+
# Request to list check payments
|
24
|
+
# @see https://docs.unit.co/check-payments#list-check-payments
|
25
|
+
# @param limit [Integer] - optional
|
26
|
+
# @param offset [Integer] - optional
|
27
|
+
# @param account_id [String] - optional
|
28
|
+
# @param customer_id [String] - optional
|
29
|
+
# @param tags [Hash] - optional
|
30
|
+
# @param sort [String] - optional
|
31
|
+
# @param since [String] - optional
|
32
|
+
# @param _until [String] - optional
|
33
|
+
# @param status [Array<String>] - optional
|
34
|
+
# @param from_amount [String] - optional
|
35
|
+
# @param to_amount [String] - optional
|
36
|
+
# @param check_number [String] - optional
|
37
|
+
# @param include [Array<String>] - optional
|
38
|
+
def list_payment(limit: CHECK_PAYMENT_LIMIT, offset: CHECK_PAYMENT_OFFSET, account_id: nil,
|
39
|
+
customer_id: nil, tags: nil, sort: nil, since: nil, _until: nil, status: nil,
|
40
|
+
from_amount: nil, to_amount: nil, check_number: nil, include: nil)
|
41
|
+
|
42
|
+
request = ListPaymentParams.new(limit, offset, account_id, customer_id, tags, sort, since, _until,
|
43
|
+
status, from_amount, to_amount, check_number, include)
|
44
|
+
Unit::Resource::CheckPaymentResource.list(request)
|
45
|
+
end
|
46
|
+
|
47
|
+
# Get a check deposit image front or back side
|
48
|
+
# @see https://docs.unit.co/check-payments#get-specific-check-payment-front-image
|
49
|
+
# @see https://docs.unit.co/check-payments#get-specific-check-payment-back-image
|
50
|
+
# @param payment_id [String]
|
51
|
+
# @param is_front_side [Boolean] - optional
|
52
|
+
def get_image(payment_id:, is_front_side: true)
|
53
|
+
request = GetImageRequest.new(payment_id, is_front_side: is_front_side)
|
54
|
+
Unit::Resource::CheckPaymentResource.get_image(request)
|
55
|
+
end
|
56
|
+
|
57
|
+
# Return check payment by id
|
58
|
+
# @see https://docs.unit.co/check-payments#return-check-payment
|
59
|
+
# @param payment_id [String]
|
60
|
+
# @param return_reason_code [String]
|
61
|
+
def return_payment(payment_id:, return_reason_code:)
|
62
|
+
request = ReturnCheckPaymentRequest.new(payment_id, return_reason_code)
|
63
|
+
Unit::Resource::CheckPaymentResource.return_payment(request)
|
64
|
+
end
|
65
|
+
|
66
|
+
# Approve Check Payment Additional Verification
|
67
|
+
# @see https://docs.unit.co/check-payments#approve-check-payment-additional-verification
|
68
|
+
# @param payment_id [String]
|
69
|
+
def approve_payment_verification(payment_id:)
|
70
|
+
Unit::Resource::CheckPaymentResource.approve_payment_verification(payment_id)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Request to get a check deposit image
|
4
|
+
# @see https://docs.unit.co/check-payments#get-specific-check-payment-front-image
|
5
|
+
# @see https://docs.unit.co/check-payments#get-specific-check-payment-back-image
|
6
|
+
module Unit
|
7
|
+
module CheckPayment
|
8
|
+
class GetImageRequest
|
9
|
+
attr_reader :payment_id, :is_front_side
|
10
|
+
|
11
|
+
# @param payment_id [String]
|
12
|
+
# @param is_front_side [Boolean] - optional
|
13
|
+
def initialize(payment_id, is_front_side: true)
|
14
|
+
@payment_id = payment_id
|
15
|
+
@is_front_side = is_front_side
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Request to get check payment by id
|
4
|
+
# @see https://docs.unit.co/check-payments#get-specific-check-payment
|
5
|
+
module Unit
|
6
|
+
module CheckPayment
|
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,63 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Request to list check payments
|
4
|
+
# @see https://docs.unit.co/check-payments#list-check-payments
|
5
|
+
module Unit
|
6
|
+
module CheckPayment
|
7
|
+
class ListPaymentParams
|
8
|
+
attr_reader :limit, :offset, :account_id, :customer_id, :tags, :sort,
|
9
|
+
:since, :_until, :status, :from_amount, :to_amount, :check_number, :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 tags [Hash] - optional
|
16
|
+
# @param sort [String] - optional
|
17
|
+
# @param since [String] - optional
|
18
|
+
# @param _until [String] - optional
|
19
|
+
# @param status [Array<String>] - optional
|
20
|
+
# @param from_amount [String] - optional
|
21
|
+
# @param to_amount [String] - optional
|
22
|
+
# @param check_number [String] - optional
|
23
|
+
# @param include [Array<String>] - optional
|
24
|
+
def initialize(limit = CHECK_PAYMENT_LIMIT, offset = CHECK_PAYMENT_OFFSET, account_id = nil,
|
25
|
+
customer_id = nil, tags = nil, sort = nil, since = nil, _until = nil, status = nil, from_amount = nil,
|
26
|
+
to_amount = nil, check_number = nil, include = nil)
|
27
|
+
@limit = limit
|
28
|
+
@offset = offset
|
29
|
+
@account_id = account_id
|
30
|
+
@customer_id = customer_id
|
31
|
+
@tags = tags
|
32
|
+
@sort = sort
|
33
|
+
@since = since
|
34
|
+
@until = _until
|
35
|
+
@status = status
|
36
|
+
@from_amount = from_amount
|
37
|
+
@to_amount = to_amount
|
38
|
+
@check_number = check_number
|
39
|
+
@include = include
|
40
|
+
end
|
41
|
+
|
42
|
+
def to_hash
|
43
|
+
params = {
|
44
|
+
"page[limit]": limit,
|
45
|
+
"page[offset]": offset,
|
46
|
+
"filter[accountId]": account_id,
|
47
|
+
"filter[customerId]": customer_id,
|
48
|
+
"filter[tags]": tags,
|
49
|
+
"sort": sort,
|
50
|
+
"filter[since]": since,
|
51
|
+
"filter[until]": _until,
|
52
|
+
"filter[fromAmount]": from_amount,
|
53
|
+
"filter[toAmount]": to_amount,
|
54
|
+
"filter[checkNumber]": check_number,
|
55
|
+
"include": include&.join(",")
|
56
|
+
}
|
57
|
+
status&.each_with_index&.map do |val, index|
|
58
|
+
params.merge!({ "filter[status][#{index}]": val })
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Request to return check payment by id
|
4
|
+
# @see https://docs.unit.co/check-payments#return-check-payment
|
5
|
+
module Unit
|
6
|
+
module CheckPayment
|
7
|
+
class ReturnCheckPaymentRequest
|
8
|
+
attr_reader :payment_id, :return_reason_code
|
9
|
+
|
10
|
+
# @param payment_id [String]
|
11
|
+
# @param return_reason_code [String]
|
12
|
+
def initialize(payment_id, return_reason_code)
|
13
|
+
@payment_id = payment_id
|
14
|
+
@return_reason_code = return_reason_code
|
15
|
+
end
|
16
|
+
|
17
|
+
def to_json_api
|
18
|
+
payload = {
|
19
|
+
data: {
|
20
|
+
type: "checkPaymentReturn",
|
21
|
+
attributes: { returnReasonCode: return_reason_code }
|
22
|
+
}
|
23
|
+
}
|
24
|
+
payload[:data][:attributes].compact!
|
25
|
+
payload.to_json
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
data/lib/unit/version.rb
CHANGED
data/lib/unit_ruby_sdk.rb
CHANGED
@@ -10,6 +10,7 @@ module Unit
|
|
10
10
|
autoload :ApiToken, "unit/models/api_token/api_token"
|
11
11
|
autoload :Payment, "unit/models/payment/payment"
|
12
12
|
autoload :ReceivedPayment, "unit/models/received_payment/received_payment"
|
13
|
+
autoload :CheckPayment, "unit/models/check_payment/check_payment"
|
13
14
|
autoload :Transaction, "unit/models/transaction/transaction"
|
14
15
|
autoload :Card, "unit/models/card/card"
|
15
16
|
autoload :Statement, "unit/models/statement/statement"
|
@@ -35,6 +36,7 @@ module Unit
|
|
35
36
|
autoload :ApiTokenResource, "unit/api_resources/api_token_resource"
|
36
37
|
autoload :PaymentResource, "unit/api_resources/payment_resource"
|
37
38
|
autoload :ReceivedPaymentResource, "unit/api_resources/received_payment_resource"
|
39
|
+
autoload :CheckPaymentResource, "unit/api_resources/check_payment_resource"
|
38
40
|
autoload :TransactionResource, "unit/api_resources/transaction_resource"
|
39
41
|
autoload :CardResource, "unit/api_resources/card_resource"
|
40
42
|
autoload :StatementResource, "unit/api_resources/statement_resource"
|
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.
|
4
|
+
version: 1.4.0
|
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-08-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: factory_bot_rails
|
@@ -104,6 +104,7 @@ files:
|
|
104
104
|
- lib/unit/api_resources/base_resource.rb
|
105
105
|
- lib/unit/api_resources/card_resource.rb
|
106
106
|
- lib/unit/api_resources/check_deposit_resource.rb
|
107
|
+
- lib/unit/api_resources/check_payment_resource.rb
|
107
108
|
- lib/unit/api_resources/counterparty_resource.rb
|
108
109
|
- lib/unit/api_resources/customer_resource.rb
|
109
110
|
- lib/unit/api_resources/event_resource.rb
|
@@ -181,6 +182,11 @@ files:
|
|
181
182
|
- lib/unit/models/check_deposit/list_deposit_params.rb
|
182
183
|
- lib/unit/models/check_deposit/patch_deposit_request.rb
|
183
184
|
- lib/unit/models/check_deposit/upload_image_request.rb
|
185
|
+
- lib/unit/models/check_payment/check_payment.rb
|
186
|
+
- lib/unit/models/check_payment/get_image_request.rb
|
187
|
+
- lib/unit/models/check_payment/get_request.rb
|
188
|
+
- lib/unit/models/check_payment/list_check_payment_params.rb
|
189
|
+
- lib/unit/models/check_payment/return_check_payment_request.rb
|
184
190
|
- lib/unit/models/counterparty/counterparty.rb
|
185
191
|
- lib/unit/models/counterparty/create_counterparty_request.rb
|
186
192
|
- lib/unit/models/counterparty/create_with_plaid_token_request.rb
|
@@ -292,7 +298,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
292
298
|
- !ruby/object:Gem::Version
|
293
299
|
version: '0'
|
294
300
|
requirements: []
|
295
|
-
rubygems_version: 3.
|
301
|
+
rubygems_version: 3.4.10
|
296
302
|
signing_key:
|
297
303
|
specification_version: 4
|
298
304
|
summary: This library provides a Ruby wrapper to http://unit.co API. See https://docs.unit.co/
|