unit_ruby_sdk 1.1.0 → 1.2.0
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 +4 -4
- data/README.md +175 -20
- data/lib/unit/api_resources/application_form_resource.rb +40 -0
- data/lib/unit/api_resources/authorization_request_resource.rb +49 -0
- data/lib/unit/api_resources/authorization_resource.rb +31 -0
- data/lib/unit/api_resources/card_resource.rb +8 -0
- data/lib/unit/api_resources/event_resource.rb +40 -0
- data/lib/unit/api_resources/fee_resource.rb +32 -0
- data/lib/unit/api_resources/payment_resource.rb +9 -0
- data/lib/unit/api_resources/received_payment_resource.rb +47 -0
- data/lib/unit/api_resources/recurring_payment_resource.rb +55 -0
- data/lib/unit/api_resources/repayment_resource.rb +41 -0
- data/lib/unit/api_resources/reward_resource.rb +41 -0
- data/lib/unit/api_resources/webhook_resource.rb +65 -0
- data/lib/unit/models/application/application.rb +98 -10
- data/lib/unit/models/application/create_business_application_request.rb +34 -13
- data/lib/unit/models/application/create_individual_application_request.rb +12 -8
- data/lib/unit/models/application/create_sole_proprietor_application_request.rb +113 -0
- data/lib/unit/models/application/create_trust_application_request.rb +67 -0
- data/lib/unit/models/application/patch_trust_application_request.rb +31 -0
- data/lib/unit/models/application_form/application_form.rb +43 -0
- data/lib/unit/models/application_form/create_application_form_request.rb +48 -0
- data/lib/unit/models/application_form/list_application_form_params.rb +30 -0
- data/lib/unit/models/authorization/authorization.rb +42 -0
- data/lib/unit/models/authorization/get_request.rb +22 -0
- data/lib/unit/models/authorization/list_request.rb +67 -0
- data/lib/unit/models/authorization_request/approve_request.rb +37 -0
- data/lib/unit/models/authorization_request/authorization_request.rb +55 -0
- data/lib/unit/models/authorization_request/decline_request.rb +31 -0
- data/lib/unit/models/authorization_request/list_authorization_params.rb +44 -0
- data/lib/unit/models/card/card.rb +102 -4
- data/lib/unit/models/card/create_business_credit_card_request.rb +29 -0
- data/lib/unit/models/card/create_business_debit_card_request.rb +10 -6
- data/lib/unit/models/card/create_business_virtual_credit_card_request.rb +25 -0
- data/lib/unit/models/card/create_business_virtual_debit_card_request.rb +10 -6
- data/lib/unit/models/card/create_individual_debit_card_request.rb +7 -3
- data/lib/unit/models/card/create_individual_virtual_card_request.rb +6 -3
- data/lib/unit/models/card/patch_business_card_request.rb +50 -0
- data/lib/unit/models/card/patch_business_credit_card_request.rb +22 -0
- data/lib/unit/models/card/patch_business_virtual_card_request.rb +43 -0
- data/lib/unit/models/card/patch_business_virtual_credit_card_request.rb +20 -0
- data/lib/unit/models/customer/list_customer_params.rb +4 -2
- data/lib/unit/models/event/event.rb +37 -0
- data/lib/unit/models/event/list_event_params.rb +37 -0
- data/lib/unit/models/fee/create_fee_request.rb +43 -0
- data/lib/unit/models/fee/fee.rb +34 -0
- data/lib/unit/models/fee/reverse_fee_request.rb +43 -0
- data/lib/unit/models/payment/batch_release_request_builder.rb +21 -0
- data/lib/unit/models/payment/create_batch_release_request.rb +54 -0
- data/lib/unit/models/payment/payment.rb +21 -1
- data/lib/unit/models/received_payment/list_payment_params.rb +51 -0
- data/lib/unit/models/received_payment/patch_payment_request.rb +31 -0
- data/lib/unit/models/received_payment/received_payment.rb +54 -0
- data/lib/unit/models/recurring_payment/create_recurring_credit_ach_payment_request.rb +52 -0
- data/lib/unit/models/recurring_payment/create_recurring_credit_book_payment_request.rb +54 -0
- data/lib/unit/models/recurring_payment/create_recurring_debit_ach_payment_request.rb +60 -0
- data/lib/unit/models/recurring_payment/list_recurring_payment_params.rb +60 -0
- data/lib/unit/models/recurring_payment/recurring_payment.rb +106 -0
- data/lib/unit/models/repayment/create_ach_repayment_request.rb +57 -0
- data/lib/unit/models/repayment/create_book_repayment_request.rb +53 -0
- data/lib/unit/models/repayment/list_repayment_params.rb +48 -0
- data/lib/unit/models/repayment/repayment.rb +67 -0
- data/lib/unit/models/reward/create_reward_request.rb +49 -0
- data/lib/unit/models/reward/get_request.rb +22 -0
- data/lib/unit/models/reward/list_reward_params.rb +65 -0
- data/lib/unit/models/reward/reward.rb +55 -0
- data/lib/unit/models/unit_response.rb +1 -1
- data/lib/unit/models/webhook/create_webhook_request.rb +49 -0
- data/lib/unit/models/webhook/list_webhook_params.rb +39 -0
- data/lib/unit/models/webhook/patch_webhook_request.rb +47 -0
- data/lib/unit/models/webhook/webhook.rb +80 -0
- data/lib/unit/types/application_form_prefill.rb +84 -0
- data/lib/unit/types/application_form_settings_override.rb +51 -0
- data/lib/unit/types/beneficial_owner.rb +15 -10
- data/lib/unit/types/beneficiary.rb +25 -0
- data/lib/unit/types/create_schedule.rb +38 -0
- data/lib/unit/types/evaluation_params.rb +4 -4
- data/lib/unit/types/grantor.rb +37 -0
- data/lib/unit/types/officer.rb +26 -13
- data/lib/unit/types/power_of_attorney_agent.rb +5 -12
- data/lib/unit/types/require_id_verification.rb +29 -0
- data/lib/unit/types/trust_contact.rb +34 -0
- data/lib/unit/types/trustee.rb +37 -0
- data/lib/unit/version.rb +1 -1
- data/lib/unit_ruby_sdk.rb +28 -0
- metadata +66 -2
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Unit
|
|
4
|
+
module Repayment
|
|
5
|
+
REPAYMENT_LIMIT = 100
|
|
6
|
+
REPAYMENT_OFFSET = 0
|
|
7
|
+
|
|
8
|
+
autoload :CreateAchRepaymentRequest, "unit/models/repayment/create_ach_repayment_request"
|
|
9
|
+
autoload :CreateBookRepaymentRequest, "unit/models/repayment/create_book_repayment_request"
|
|
10
|
+
autoload :ListRepaymentParams, "unit/models/repayment/list_repayment_params"
|
|
11
|
+
|
|
12
|
+
class << self
|
|
13
|
+
# Get a repayment by calling Unit's API
|
|
14
|
+
# @see https://docs.unit.co/repayments#get-specific-repayment
|
|
15
|
+
# @param repayment_id [String]
|
|
16
|
+
def get_repayment(repayment_id:)
|
|
17
|
+
Unit::Resource::RepaymentResource.get(repayment_id)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# Create a book repayment by calling Unit's API
|
|
21
|
+
# @see https://docs.unit.co/repayments#book-repayment
|
|
22
|
+
# @param account_id [String]
|
|
23
|
+
# @param credit_account_id [String]
|
|
24
|
+
# @param counterparty_account_id [String]
|
|
25
|
+
# @param description [String]
|
|
26
|
+
# @param amount [Integer]
|
|
27
|
+
# @param transaction_summary_override [String]
|
|
28
|
+
# @param tags [Array<String>] - optional
|
|
29
|
+
# @param idempotency_key [String] - optional
|
|
30
|
+
def create_book_repayment(account_id:, credit_account_id:, counterparty_account_id:, description:, amount:, transaction_summary_override:, tags: nil, idempotency_key: nil)
|
|
31
|
+
request = Unit::Repayment::CreateBookRepaymentRequest.new(account_id, credit_account_id, counterparty_account_id, description, amount, transaction_summary_override, tags, idempotency_key)
|
|
32
|
+
Unit::Resource::RepaymentResource.create(request)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# Create an ach repayment by calling Unit's API
|
|
36
|
+
# @see https://docs.unit.co/repayments#create-ach-repayment
|
|
37
|
+
# @param account_id [String]
|
|
38
|
+
# @param credit_account_id [String]
|
|
39
|
+
# @param counterparty_id [String]
|
|
40
|
+
# @param description [String]
|
|
41
|
+
# @param amount [Integer]
|
|
42
|
+
# @param addenda [String] - optional
|
|
43
|
+
# @param tags [Hash] - optional
|
|
44
|
+
# @param same_day [Boolean] - optional
|
|
45
|
+
# @param idempotency_key [String] - optional
|
|
46
|
+
def create_ach_repayment(account_id:, credit_account_id:, counterparty_id:, description:, amount:, addenda: nil, tags: nil, idempotency_key: nil, same_day: false)
|
|
47
|
+
request = Unit::Repayment::CreateAchRepaymentRequest.new(account_id, credit_account_id, counterparty_id, description, amount, addenda, tags, idempotency_key, same_day: same_day)
|
|
48
|
+
Unit::Resource::RepaymentResource.create(request)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
# List repayments by calling Unit's API
|
|
52
|
+
# @see https://docs.unit.co/repayments#list-repayments
|
|
53
|
+
# @param limit [Integer] - optional
|
|
54
|
+
# @param offset [Integer] - optional
|
|
55
|
+
# @param account_id [String] - optional
|
|
56
|
+
# @param credit_account_id [String] - optional
|
|
57
|
+
# @param customer_id [String] - optional
|
|
58
|
+
# @param status [Array<String>] - optional
|
|
59
|
+
# @param type [Array<String>] - optional
|
|
60
|
+
def list_repayments(limit: REPAYMENT_LIMIT, offset: REPAYMENT_OFFSET, account_id: nil,
|
|
61
|
+
credit_account_id: nil, customer_id: nil, status: nil, type: nil)
|
|
62
|
+
request = Unit::Repayment::ListRepaymentParams.new(limit, offset, account_id, credit_account_id, customer_id, status, type)
|
|
63
|
+
Unit::Resource::RepaymentResource.list(request)
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Create a reward request
|
|
4
|
+
# @see https://docs.unit.co/rewards/#create-reward
|
|
5
|
+
module Unit
|
|
6
|
+
module Reward
|
|
7
|
+
class CreateRewardRequest
|
|
8
|
+
attr_reader :receiving_account_id, :funding_account_id, :rewarded_transaction_id, :amount, :description, :tags, :idempotency_key
|
|
9
|
+
|
|
10
|
+
# @param receiving_account_id [String]
|
|
11
|
+
# @param amount [Integer]
|
|
12
|
+
# @param description [String]
|
|
13
|
+
# @param tags [Hash]
|
|
14
|
+
# @param idempotency_key [String]
|
|
15
|
+
# @param funding_account_id [String] - optional
|
|
16
|
+
# @param rewarded_transaction_id [String] - optional
|
|
17
|
+
def initialize(receiving_account_id, amount, description, tags = nil, idempotency_key = nil, funding_account_id = nil, rewarded_transaction_id = nil)
|
|
18
|
+
@receiving_account_id = receiving_account_id
|
|
19
|
+
@amount = amount
|
|
20
|
+
@description = description
|
|
21
|
+
@tags = tags
|
|
22
|
+
@idempotency_key = idempotency_key
|
|
23
|
+
@funding_account_id = funding_account_id
|
|
24
|
+
@rewarded_transaction = rewarded_transaction_id
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def to_json_api
|
|
28
|
+
payload = {
|
|
29
|
+
data: {
|
|
30
|
+
type: "reward",
|
|
31
|
+
attributes: {
|
|
32
|
+
amount: amount,
|
|
33
|
+
description: description,
|
|
34
|
+
tags: tags,
|
|
35
|
+
idempotencyKey: idempotency_key
|
|
36
|
+
},
|
|
37
|
+
relationships: {
|
|
38
|
+
receivingAccount: Unit::Types::Relationship.new("depositAccount", receiving_account_id).to_hash
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
payload[:data][:relationships][:funding_account] = Unit::Types::Relationship.new("fundingAccount", funding_account_id).to_hash if funding_account_id
|
|
43
|
+
payload[:data][:relationships][:rewardedTransaction] = Unit::Types::Relationship.new("rewardedTransaction", rewarded_transaction).to_hash if rewarded_transaction_id
|
|
44
|
+
payload[:data][:attributes].compact!
|
|
45
|
+
payload.to_json
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Get a reward by id request
|
|
4
|
+
# @see https://docs.unit.co/rewards/#get-specific-reward
|
|
5
|
+
module Unit
|
|
6
|
+
module Reward
|
|
7
|
+
class GetRequest
|
|
8
|
+
attr_reader :reward_id, :include
|
|
9
|
+
|
|
10
|
+
# @param reward_id [String]
|
|
11
|
+
# @param include [Array<String>] - optional
|
|
12
|
+
def initialize(reward_id, include = nil)
|
|
13
|
+
@reward_id = reward_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,65 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# List reward params request
|
|
4
|
+
# @see https://docs.unit.co/rewards/#list-rewards
|
|
5
|
+
module Unit
|
|
6
|
+
module Reward
|
|
7
|
+
class ListRewardParams
|
|
8
|
+
attr_reader :limit, :offset, :transaction_id, :rewarded_transaction_id,
|
|
9
|
+
:receiving_account_id, :customer_id, :card_id, :status, :since,
|
|
10
|
+
:until_, :tags, :sort, :include
|
|
11
|
+
|
|
12
|
+
# @param limit [Integer] - optional
|
|
13
|
+
# @param offset [Integer] - optional
|
|
14
|
+
# @param transaction_id [String] - optional
|
|
15
|
+
# @param rewarded_transaction_id [String] - optional
|
|
16
|
+
# @param receiving_account_id [String] - optional
|
|
17
|
+
# @param customer_id [String] - optional
|
|
18
|
+
# @param card_id [String] - optional
|
|
19
|
+
# @param status [String] - optional
|
|
20
|
+
# @param since [String] - optional
|
|
21
|
+
# @param until_ [String] - optional
|
|
22
|
+
# @param tags [Hash] - optional
|
|
23
|
+
# @param sort [String] - optional
|
|
24
|
+
# @param include [Array<String>] - optional
|
|
25
|
+
def initialize(limit = REWARD_LIMIT, offset = REWARD_OFFSET, transaction_id = nil, rewarded_transaction_id = nil,
|
|
26
|
+
receiving_account_id = nil, customer_id = nil, card_id = nil, status = nil, since = nil,
|
|
27
|
+
until_ = nil, tags = nil, sort = nil, include = nil)
|
|
28
|
+
@limit = limit
|
|
29
|
+
@offset = offset
|
|
30
|
+
@transaction_id = transaction_id
|
|
31
|
+
@rewarded_transaction_id = rewarded_transaction_id
|
|
32
|
+
@receiving_account_id = receiving_account_id
|
|
33
|
+
@customer_id = customer_id
|
|
34
|
+
@card_id = card_id
|
|
35
|
+
@status = status
|
|
36
|
+
@since = since
|
|
37
|
+
@until_ = until_
|
|
38
|
+
@tags = tags
|
|
39
|
+
@sort = sort
|
|
40
|
+
@include = include
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def to_hash
|
|
44
|
+
params = {
|
|
45
|
+
"page[limit]": limit,
|
|
46
|
+
"page[offset]": offset,
|
|
47
|
+
"filter[transactionId]": transaction_id,
|
|
48
|
+
"filter[rewardedTransactionId]": rewarded_transaction_id,
|
|
49
|
+
"filter[receivingAccountId]": receiving_account_id,
|
|
50
|
+
"filter[customerId]": customer_id,
|
|
51
|
+
"filter[cardId]": card_id,
|
|
52
|
+
"filter[since]": since,
|
|
53
|
+
"filter[until]": until_,
|
|
54
|
+
"filter[tags]": tags,
|
|
55
|
+
"sort": sort,
|
|
56
|
+
"include": include&.join(",")
|
|
57
|
+
}
|
|
58
|
+
status&.each_with_index&.map do |val, index|
|
|
59
|
+
params.merge!({ "filter[status][#{index}]": val })
|
|
60
|
+
end
|
|
61
|
+
params.compact
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Unit
|
|
4
|
+
module Reward
|
|
5
|
+
REWARD_LIMIT = 100
|
|
6
|
+
REWARD_OFFSET = 0
|
|
7
|
+
autoload :GetRequest, "unit/models/reward/get_request"
|
|
8
|
+
autoload :CreateRewardRequest, "unit/models/reward/create_reward_request"
|
|
9
|
+
autoload :ListRewardParams, "unit/models/reward/list_reward_params"
|
|
10
|
+
class << self
|
|
11
|
+
# Get a reward by id
|
|
12
|
+
# @see https://docs.unit.co/rewards/#get-specific-reward
|
|
13
|
+
# @param reward_id [String]
|
|
14
|
+
# @param include [Array<String>] - optional
|
|
15
|
+
def get_reward(reward_id:, include: nil)
|
|
16
|
+
request = GetRequest.new(reward_id, include)
|
|
17
|
+
Resource::RewardResource.get_reward(request)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# Create a reward request
|
|
21
|
+
# @see https://docs.unit.co/rewards/#create-reward
|
|
22
|
+
# @param receiving_account_id [String]
|
|
23
|
+
# @param amount [Integer]
|
|
24
|
+
# @param description [String]
|
|
25
|
+
# @param tags [Hash]
|
|
26
|
+
# @param idempotency_key [String]
|
|
27
|
+
# @param funding_account_id [String] - optional
|
|
28
|
+
# @param rewarded_transaction_id [String] - optional
|
|
29
|
+
def create_reward(receiving_account_id:, amount:, description:, tags:, idempotency_key:, funding_account_id: nil, rewarded_transaction: nil)
|
|
30
|
+
request = CreateRewardRequest.new(receiving_account_id, amount, description, tags, idempotency_key, funding_account_id, rewarded_transaction)
|
|
31
|
+
Resource::RewardResource.create_reward(request)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# List reward params request
|
|
35
|
+
# @see https://docs.unit.co/rewards/#list-rewards
|
|
36
|
+
# @param limit [Integer] - optional
|
|
37
|
+
# @param offset [Integer] - optional
|
|
38
|
+
# @param transaction_id [String] - optional
|
|
39
|
+
# @param rewarded_transaction_id [String] - optional
|
|
40
|
+
# @param receiving_account_id [String] - optional
|
|
41
|
+
# @param customer_id [String] - optional
|
|
42
|
+
# @param card_id [String] - optional
|
|
43
|
+
# @param status [Array<String>] - optional
|
|
44
|
+
# @param since [String] - optional
|
|
45
|
+
# @param until_ [String] - optional
|
|
46
|
+
# @param tags [Hash] - optional
|
|
47
|
+
# @param sort [String] - optional
|
|
48
|
+
# @param include [Array<String>] - optional
|
|
49
|
+
def list_rewards(limit: REWARD_LIMIT, offset: REWARD_OFFSET, transaction_id: nil, rewarded_transaction_id: nil, receiving_account_id: nil, customer_id: nil, card_id: nil, status: nil, since: nil, until_: nil, tags: nil, sort: nil, include: nil)
|
|
50
|
+
request = ListRewardParams.new(limit, offset, transaction_id, rewarded_transaction_id, receiving_account_id, customer_id, card_id, status, since, until_, tags, sort, include)
|
|
51
|
+
Resource::RewardResource.list_rewards(request)
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Request to create webhook
|
|
4
|
+
# @see https://docs.unit.co/webhooks#create-webhook
|
|
5
|
+
module Unit
|
|
6
|
+
module Webhook
|
|
7
|
+
class CreateWebhookRequest
|
|
8
|
+
attr_accessor :label, :url, :token, :content_type, :delivery_mode,
|
|
9
|
+
:include_resources, :subscription_type
|
|
10
|
+
|
|
11
|
+
# @param label [String]
|
|
12
|
+
# @param url [String]
|
|
13
|
+
# @param token [String]
|
|
14
|
+
# @param content_type [String]
|
|
15
|
+
# @param delivery_mode [String]
|
|
16
|
+
# @param include_resources [Boolean] - optional
|
|
17
|
+
# @param subscription_type [String] - optional
|
|
18
|
+
def initialize(label, url, token, content_type, delivery_mode,
|
|
19
|
+
include_resources = nil, subscription_type = nil)
|
|
20
|
+
@label = label
|
|
21
|
+
@url = url
|
|
22
|
+
@token = token
|
|
23
|
+
@content_type = content_type
|
|
24
|
+
@delivery_mode = delivery_mode
|
|
25
|
+
@include_resources = include_resources
|
|
26
|
+
@subscription_type = subscription_type
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def to_json_api
|
|
30
|
+
payload = {
|
|
31
|
+
data: {
|
|
32
|
+
type: "webhook",
|
|
33
|
+
attributes: {
|
|
34
|
+
label: label,
|
|
35
|
+
url: url,
|
|
36
|
+
token: token,
|
|
37
|
+
contentType: content_type,
|
|
38
|
+
deliveryMode: delivery_mode,
|
|
39
|
+
includeResources: include_resources,
|
|
40
|
+
subscriptionType: subscription_type
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
payload[:data][:attributes].compact!
|
|
45
|
+
payload.to_json
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Request to list webhooks
|
|
4
|
+
# @see https://docs.unit.co/webhooks#list-webhooks
|
|
5
|
+
module Unit
|
|
6
|
+
module Webhook
|
|
7
|
+
class ListWebhookParams
|
|
8
|
+
attr_accessor :limit, :offset, :since, :until_, :from_id, :told
|
|
9
|
+
|
|
10
|
+
# @param limit [Integer]
|
|
11
|
+
# @param offset [Integer]
|
|
12
|
+
# @param since [String] - optional
|
|
13
|
+
# @param until_ [String] - optional
|
|
14
|
+
# @param from_id [Integer] - optional
|
|
15
|
+
# @param told [Integer] - optional
|
|
16
|
+
def initialize(limit = WEBHOOK_LIMIT, offset = WEBHOOK_OFFSET, since = nil,
|
|
17
|
+
until_ = nil, from_id = nil, told = nil)
|
|
18
|
+
@limit = limit
|
|
19
|
+
@offset = offset
|
|
20
|
+
@since = since
|
|
21
|
+
@until_ = until_
|
|
22
|
+
@from_id = from_id
|
|
23
|
+
@told = told
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def to_hash
|
|
27
|
+
payload = {
|
|
28
|
+
"page[limit]": limit,
|
|
29
|
+
"page[offset]": offset,
|
|
30
|
+
"filter[since]": since,
|
|
31
|
+
"filter[until]": until_,
|
|
32
|
+
"filter[fromId]": from_id,
|
|
33
|
+
"filter[told]": told
|
|
34
|
+
}
|
|
35
|
+
payload.compact!
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Request to patch webhook
|
|
4
|
+
# @see https://docs.unit.co/webhooks#update-webhook
|
|
5
|
+
module Unit
|
|
6
|
+
module Webhook
|
|
7
|
+
class PatchWebhookRequest
|
|
8
|
+
attr_reader :webhook_id, :label, :url, :token, :content_type, :token, :include_resources, :subscription_type
|
|
9
|
+
|
|
10
|
+
# @param webhook_id [String]
|
|
11
|
+
# @param label [String]
|
|
12
|
+
# @param url [String]
|
|
13
|
+
# @param content_type [String]
|
|
14
|
+
# @param token [String]
|
|
15
|
+
# @param include_resources [Boolean] - optional
|
|
16
|
+
# @param subscription_type [String] - optional
|
|
17
|
+
def initialize(webhook_id, label, url, content_type, token,
|
|
18
|
+
include_resources = nil, subscription_type = nil)
|
|
19
|
+
@webhook_id = webhook_id
|
|
20
|
+
@label = label
|
|
21
|
+
@url = url
|
|
22
|
+
@token = token
|
|
23
|
+
@content_type = content_type
|
|
24
|
+
@include_resources = include_resources
|
|
25
|
+
@subscription_type = subscription_type
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def to_json_api
|
|
29
|
+
payload = {
|
|
30
|
+
data: {
|
|
31
|
+
type: "webhook",
|
|
32
|
+
attributes: {
|
|
33
|
+
label: label,
|
|
34
|
+
url: url,
|
|
35
|
+
content_type: content_type,
|
|
36
|
+
token: token,
|
|
37
|
+
include_resources: include_resources,
|
|
38
|
+
subscription_type: subscription_type
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
payload[:data][:attributes].compact!
|
|
43
|
+
payload.to_json
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Unit
|
|
4
|
+
module Webhook
|
|
5
|
+
class << self
|
|
6
|
+
WEBHOOK_LIMIT = 100
|
|
7
|
+
WEBHOOK_OFFSET = 0
|
|
8
|
+
autoload :CreateWebhookRequest, "unit/models/webhook/create_webhook_request"
|
|
9
|
+
autoload :ListWebhookParams, "unit/models/webhook/list_webhook_params"
|
|
10
|
+
autoload :PatchWebhookRequest, "unit/models/webhook/patch_webhook_request"
|
|
11
|
+
|
|
12
|
+
# Create a webhook
|
|
13
|
+
# @see https://docs.unit.co/webhooks#create-webhook
|
|
14
|
+
# @param label [String]
|
|
15
|
+
# @param url [String]
|
|
16
|
+
# @param token [String]
|
|
17
|
+
# @param content_type [String]
|
|
18
|
+
# @param delivery_mode [String]
|
|
19
|
+
# @param include_resources [Boolean] - optional
|
|
20
|
+
# @param subscription_type [String] - optional
|
|
21
|
+
def create_webhook(label:, url:, token:, content_type:, delivery_mode:,
|
|
22
|
+
include_resources: nil, subscription_type: nil)
|
|
23
|
+
request = CreateWebhookRequest.new(label, url, token, content_type, delivery_mode,
|
|
24
|
+
include_resources, subscription_type)
|
|
25
|
+
Unit::Resource::WebhookResource.create_webhook(request)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# Request to list webhooks
|
|
29
|
+
# @see https://docs.unit.co/webhooks#list-webhooks
|
|
30
|
+
# @param limit [Integer]
|
|
31
|
+
# @param offset [Integer]
|
|
32
|
+
# @param since [String] - optional
|
|
33
|
+
# @param until_ [String] - optional
|
|
34
|
+
# @param from_id [Integer] - optional
|
|
35
|
+
# @param told [Integer] - optional
|
|
36
|
+
def list_webhooks(limit: WEBHOOK_LIMIT, offset: WEBHOOK_OFFSET, since: nil,
|
|
37
|
+
until_: nil, from_id: nil, told: nil)
|
|
38
|
+
request = ListWebhookParams.new(limit, offset, since, until_, from_id, told)
|
|
39
|
+
Unit::Resource::WebhookResource.list_webhooks(request)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
# Request to patch webhook
|
|
43
|
+
# @see https://docs.unit.co/webhooks#update-webhook
|
|
44
|
+
# @param webhook_id [String]
|
|
45
|
+
# @param label [String]
|
|
46
|
+
# @param url [String]
|
|
47
|
+
# @param content_type [String]
|
|
48
|
+
# @param token [String]
|
|
49
|
+
# @param include_resources [Boolean] - optional
|
|
50
|
+
# @param subscription_type [String] - optional
|
|
51
|
+
def update_webhook(webhook_id:, label:, url:, content_type:, token:,
|
|
52
|
+
include_resources: nil, subscription_type: nil)
|
|
53
|
+
request = PatchWebhookRequest.new(webhook_id, label, url, content_type, token,
|
|
54
|
+
include_resources, subscription_type)
|
|
55
|
+
Unit::Resource::WebhookResource.update_webhook(request)
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
# Request to get a webhook
|
|
59
|
+
# @see https://docs.unit.co/webhooks#get-webhook
|
|
60
|
+
# @param webhook_id [String]
|
|
61
|
+
def get_webhook(webhook_id:)
|
|
62
|
+
Unit::Resource::WebhookResource.get_webhook(webhook_id)
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
# Request to enable a webhook
|
|
66
|
+
# @see https://docs.unit.co/webhooks#enable
|
|
67
|
+
# @param webhook_id [String]
|
|
68
|
+
def enable_webhook(webhook_id:)
|
|
69
|
+
Unit::Resource::WebhookResource.enable_webhook(webhook_id)
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
# Request to disable a webhook
|
|
73
|
+
# @see https://docs.unit.co/webhooks#disable
|
|
74
|
+
# @param webhook_id [String]
|
|
75
|
+
def disable_webhook(webhook_id:)
|
|
76
|
+
Unit::Resource::WebhookResource.disable_webhook(webhook_id)
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
end
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Type representing application form prefill
|
|
4
|
+
# @see https://docs.unit.co/types#applicationformprefill
|
|
5
|
+
module Unit
|
|
6
|
+
module Types
|
|
7
|
+
class ApplicationFormPrefill
|
|
8
|
+
attr_reader :application_type, :full_name, :ssn, :passport, :nationality, :date_of_birth, :email,
|
|
9
|
+
:name, :state_of_incorporation, :entity_type, :contact, :officer, :beneficial_owners,
|
|
10
|
+
:website, :dba, :ein, :industry, :address, :phone, :jwt_subject
|
|
11
|
+
|
|
12
|
+
# @param application_type [Array<String>] - optional
|
|
13
|
+
# @param full_name [FullName] - optional
|
|
14
|
+
# @param ssn [String] - optional
|
|
15
|
+
# @param passport [String] - optional
|
|
16
|
+
# @param nationality [String] - optional
|
|
17
|
+
# @param date_of_birth [Date] - optional
|
|
18
|
+
# @param email [String] - optional
|
|
19
|
+
# @param name [String] - optional
|
|
20
|
+
# @param state_of_incorporation [String] - optional
|
|
21
|
+
# @param entity_type [String] - optional
|
|
22
|
+
# @param contact [BusinessContact] - optional
|
|
23
|
+
# @param officer [Officer] - optional
|
|
24
|
+
# @param beneficial_owners [Array<BeneficialOwner>] - optional
|
|
25
|
+
# @param website [String] - optional
|
|
26
|
+
# @param dba [String] - optional
|
|
27
|
+
# @param ein [String] - optional
|
|
28
|
+
# @param industry [String] - optional
|
|
29
|
+
# @param address [Address] - optional
|
|
30
|
+
# @param phone [Phone] - optional
|
|
31
|
+
def initialize(application_type = nil, full_name = nil, ssn = nil, passport = nil, nationality = nil,
|
|
32
|
+
date_of_birth = nil, email = nil, name = nil, state_of_incorporation = nil, entity_type = nil,
|
|
33
|
+
contact = nil, officer = nil, beneficial_owners = nil, website = nil, dba = nil, ein = nil,
|
|
34
|
+
industry = nil, address = nil, phone = nil, jwt_subject = nil)
|
|
35
|
+
@application_type = application_type
|
|
36
|
+
@full_name = full_name
|
|
37
|
+
@ssn = ssn
|
|
38
|
+
@passport = passport
|
|
39
|
+
@nationality = nationality
|
|
40
|
+
@date_of_birth = date_of_birth
|
|
41
|
+
@email = email
|
|
42
|
+
@name = name
|
|
43
|
+
@state_of_incorporation = state_of_incorporation
|
|
44
|
+
@entity_type = entity_type
|
|
45
|
+
@contact = contact
|
|
46
|
+
@officer = officer
|
|
47
|
+
@beneficial_owners = beneficial_owners
|
|
48
|
+
@website = website
|
|
49
|
+
@dba = dba
|
|
50
|
+
@ein = ein
|
|
51
|
+
@industry = industry
|
|
52
|
+
@address = address
|
|
53
|
+
@phone = phone
|
|
54
|
+
@jwt_subject = jwt_subject
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def represent
|
|
58
|
+
payload = {
|
|
59
|
+
applicationType: application_type,
|
|
60
|
+
fullName: full_name&.represent,
|
|
61
|
+
ssn: ssn,
|
|
62
|
+
passport: passport,
|
|
63
|
+
nationality: nationality,
|
|
64
|
+
dateOfBirth: date_of_birth,
|
|
65
|
+
email: email,
|
|
66
|
+
name: name,
|
|
67
|
+
stateOfIncorporation: state_of_incorporation,
|
|
68
|
+
entityType: entity_type,
|
|
69
|
+
contact: contact&.represent,
|
|
70
|
+
officer: officer&.represent,
|
|
71
|
+
beneficialOwners: beneficial_owners,
|
|
72
|
+
website: website,
|
|
73
|
+
dba: dba,
|
|
74
|
+
ein: ein,
|
|
75
|
+
industry: industry,
|
|
76
|
+
address: address&.represent,
|
|
77
|
+
phone: phone&.represent,
|
|
78
|
+
jwtSubject: jwt_subject
|
|
79
|
+
}
|
|
80
|
+
payload.compact
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
end
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Type representing application form settings override
|
|
4
|
+
# @see https://docs.unit.co/types#applicationformsettingsoverride
|
|
5
|
+
module Unit
|
|
6
|
+
module Types
|
|
7
|
+
class ApplicationFormSettingsOverride
|
|
8
|
+
attr_reader :redirect_url, :privacy_policy_url, :electronic_disclosures_url, :deposit_terms_url,
|
|
9
|
+
:client_terms_url, :cardholder_terms_url, :cash_advanced_terms_url, :debit_card_disclosure_url,
|
|
10
|
+
:additional_disclosures
|
|
11
|
+
|
|
12
|
+
# @param redirect_url [String] - optional
|
|
13
|
+
# @param privacy_policy_url [String] - optional
|
|
14
|
+
# @param electronic_disclosures_url [String] - optional
|
|
15
|
+
# @param deposit_terms_url [String] - optional
|
|
16
|
+
# @param client_terms_url [String] - optional
|
|
17
|
+
# @param cardholder_terms_url [String] - optional
|
|
18
|
+
# @param cash_advanced_terms_url [String] - optional
|
|
19
|
+
# @param debit_card_disclosure_url [String] - optional
|
|
20
|
+
# @param additional_disclosures [Array] - optional
|
|
21
|
+
def initialize(redirect_url = nil, privacy_policy_url = nil, electronic_disclosures_url = nil, deposit_terms_url = nil,
|
|
22
|
+
client_terms_url = nil, cardholder_terms_url = nil, cash_advanced_terms_url = nil, debit_card_disclosure_url = nil,
|
|
23
|
+
additional_disclosures = nil)
|
|
24
|
+
@redirect_url = redirect_url
|
|
25
|
+
@privacy_policy_url = privacy_policy_url
|
|
26
|
+
@electronic_disclosures_url = electronic_disclosures_url
|
|
27
|
+
@deposit_terms_url = deposit_terms_url
|
|
28
|
+
@client_terms_url = client_terms_url
|
|
29
|
+
@cardholder_terms_url = cardholder_terms_url
|
|
30
|
+
@cash_advanced_terms_url = cash_advanced_terms_url
|
|
31
|
+
@debit_card_disclosure_url = debit_card_disclosure_url
|
|
32
|
+
@additional_disclosures = additional_disclosures
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def represent
|
|
36
|
+
payload = {
|
|
37
|
+
redirectUrl: redirect_url,
|
|
38
|
+
privacyPolicyUrl: privacy_policy_url,
|
|
39
|
+
electronicDisclosuresUrl: electronic_disclosures_url,
|
|
40
|
+
depositTermsUrl: deposit_terms_url,
|
|
41
|
+
clientTermsUrl: client_terms_url,
|
|
42
|
+
cardholderTermsUrl: cardholder_terms_url,
|
|
43
|
+
cashAdvancedTermsUrl: cash_advanced_terms_url,
|
|
44
|
+
debitCardDisclosureUrl: debit_card_disclosure_url,
|
|
45
|
+
additionalDisclosures: additional_disclosures&.join(",")
|
|
46
|
+
}
|
|
47
|
+
payload.compact
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
@@ -6,16 +6,21 @@ module Unit
|
|
|
6
6
|
attr_reader :full_name, :date_of_birth, :address, :phone, :email,
|
|
7
7
|
:status, :ssn, :passport, :nationality, :percentage
|
|
8
8
|
|
|
9
|
-
# @param [FullName]
|
|
10
|
-
# @param [Date]
|
|
11
|
-
# @param [Address]
|
|
12
|
-
# @param [Phone]
|
|
13
|
-
# @param [String]
|
|
14
|
-
# @param [String]
|
|
15
|
-
# @param
|
|
16
|
-
# @param
|
|
17
|
-
# @param
|
|
18
|
-
# @param
|
|
9
|
+
# @param full_name [FullName]
|
|
10
|
+
# @param date_of_birth [Date]
|
|
11
|
+
# @param address [Address]
|
|
12
|
+
# @param phone [Phone]
|
|
13
|
+
# @param email [String]
|
|
14
|
+
# @param ssn [String]
|
|
15
|
+
# @param status [String] - optional
|
|
16
|
+
# @param passport [String] - optional
|
|
17
|
+
# @param nationality [String] - optional
|
|
18
|
+
# @param percentage [Integer] - optional
|
|
19
|
+
# @param evaluation_params [EvaluationParams] - optional
|
|
20
|
+
# @param id_theft_score [Integer] - optional
|
|
21
|
+
# @param occupation [String] - optional
|
|
22
|
+
# @param annual_income [String] - optional
|
|
23
|
+
# @param source_of_income [String] - optional
|
|
19
24
|
# @return [BeneficialOwner]
|
|
20
25
|
def initialize(full_name, date_of_birth, address, phone, email, ssn, status = nil, passport = nil,
|
|
21
26
|
nationality = nil, percentage = nil)
|