unit_ruby_sdk 0.1.3 → 0.1.5
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 +39 -0
- data/lib/unit/api_resources/api_token_resource.rb +59 -0
- data/lib/unit/api_resources/base_resource.rb +5 -1
- data/lib/unit/api_resources/card_resource.rb +104 -0
- data/lib/unit/api_resources/payment_resource.rb +32 -0
- data/lib/unit/api_resources/statement_resource.rb +46 -0
- data/lib/unit/api_resources/transaction_resource.rb +40 -0
- data/lib/unit/models/account/deposit/balance_history_request.rb +1 -1
- data/lib/unit/models/api_token/api_token.rb +89 -0
- data/lib/unit/models/api_token/customer/create_customer_token_request.rb +41 -0
- data/lib/unit/models/api_token/customer/create_customer_token_verification.rb +37 -0
- data/lib/unit/models/api_token/customer/create_token_using_jwt_request.rb +30 -0
- data/lib/unit/models/api_token/org/create_api_token_request.rb +40 -0
- data/lib/unit/models/application/list_application_params.rb +1 -1
- data/lib/unit/models/card/card.rb +149 -0
- data/lib/unit/models/card/create_business_debit_card_request.rb +68 -0
- data/lib/unit/models/card/create_business_virtual_debit_card_request.rb +56 -0
- data/lib/unit/models/card/create_individual_debit_card_request.rb +57 -0
- data/lib/unit/models/card/create_individual_virtual_card_request.rb +44 -0
- data/lib/unit/models/card/list_card_params.rb +45 -0
- data/lib/unit/models/card/replace_card_request.rb +31 -0
- data/lib/unit/models/customer/list_customer_params.rb +1 -1
- data/lib/unit/models/payment/create_book_payment_request.rb +49 -0
- data/lib/unit/models/payment/patch_book_payment_request.rb +31 -0
- data/lib/unit/models/payment/payment.rb +37 -0
- data/lib/unit/models/statement/get_bank_verification_pdf.rb +23 -0
- data/lib/unit/models/statement/get_html_by_id_request.rb +26 -0
- data/lib/unit/models/statement/get_pdf_by_id_request.rb +26 -0
- data/lib/unit/models/statement/list_statement_params.rb +37 -0
- data/lib/unit/models/statement/statement.rb +55 -0
- data/lib/unit/models/transaction/get_transaction_params.rb +28 -0
- data/lib/unit/models/transaction/list_transaction_params.rb +70 -0
- data/lib/unit/models/transaction/patch_tags_request.rb +33 -0
- data/lib/unit/models/transaction/transaction.rb +60 -0
- data/lib/unit/types/restricted_resource.rb +23 -0
- data/lib/unit/utils/http_helper.rb +10 -2
- data/lib/unit/version.rb +1 -1
- data/lib/unit_ruby_sdk.rb +11 -0
- metadata +32 -2
@@ -0,0 +1,149 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Unit
|
4
|
+
module Card
|
5
|
+
CARD_LIST_LIMIT = 100
|
6
|
+
CARD_LIST_OFFSET = 0
|
7
|
+
autoload :CreateIndividualDebitCardRequest, "unit/models/card/create_individual_debit_card_request"
|
8
|
+
autoload :CreateBusinessDebitCardRequest, "unit/models/card/create_business_debit_card_request"
|
9
|
+
autoload :CreateBusinessVirtualDebitCardRequest, "unit/models/card/create_business_virtual_debit_card_request"
|
10
|
+
autoload :CreateIndividualVirtualCardRequest, "unit/models/card/create_individual_virtual_card_request"
|
11
|
+
autoload :ReplaceCardRequest, "unit/models/card/replace_card_request"
|
12
|
+
autoload :ListCardParams, "unit/models/card/list_card_params"
|
13
|
+
|
14
|
+
class << self
|
15
|
+
# Create a new individual debit card by calling Unit's API
|
16
|
+
# @see https://docs.unit.co/cards#create-individual-debit-card
|
17
|
+
# @param account_id [String]
|
18
|
+
# @param shipping_address [Address] - optional
|
19
|
+
# @param design [String] - optional
|
20
|
+
# @param additional_embossed_text [String] - optional
|
21
|
+
# @param idempotency_key [String] - optional
|
22
|
+
# @param tags [Hash] - optional
|
23
|
+
# @param limits [Hash] - optional
|
24
|
+
# @param print_only_business_name [String] - optional
|
25
|
+
def create_individual_debit_card(account_id:, customer_id: nil, shipping_address: nil, design: nil, additional_embossed_text: nil,
|
26
|
+
idempotency_key: nil, tags: nil, limits: nil, print_only_business_name: nil)
|
27
|
+
request = CreateIndividualDebitCardRequest.new(account_id, customer_id, shipping_address, design, additional_embossed_text,
|
28
|
+
idempotency_key, tags, limits, print_only_business_name)
|
29
|
+
Unit::Resource::CardResource.create_card(request)
|
30
|
+
end
|
31
|
+
|
32
|
+
# Create a new business debit card by calling Unit's API
|
33
|
+
# @see https://docs.unit.co/cards#create-business-debit-card
|
34
|
+
# @param full_name [FullName]
|
35
|
+
# @param date_of_birth [Date]
|
36
|
+
# @param address [Address]
|
37
|
+
# @param shipping_address [Address] - optional
|
38
|
+
# @param phone [Phone] - optional
|
39
|
+
# @param email [String] - optional
|
40
|
+
# @param design [String] - optional
|
41
|
+
# @param additional_embossed_text [String] - optional
|
42
|
+
# @param idempotency_key [String] - optional
|
43
|
+
# @param tags [Hash] - optional
|
44
|
+
# @param limits [Hash] - optional
|
45
|
+
# @param print_only_business_name [Boolean] - optional
|
46
|
+
def create_business_debit_card(account_id:, full_name:, date_of_birth:, address:, phone:, email:, shipping_address: nil,
|
47
|
+
design: nil, additional_embossed_text: nil, idempotency_key: nil, tags: nil, limits: nil, print_only_business_name: nil)
|
48
|
+
request = CreateBusinessDebitCardRequest.new(account_id, full_name, date_of_birth, address, shipping_address, phone, email, design, additional_embossed_text,
|
49
|
+
idempotency_key, tags, limits, print_only_business_name)
|
50
|
+
Unit::Resource::CardResource.create_card(request)
|
51
|
+
end
|
52
|
+
|
53
|
+
# Create a new individual virtual card by calling Unit's API
|
54
|
+
# @see https://docs.unit.co/cards#create-individual-virtual-debit-card
|
55
|
+
# @param account_id [String]
|
56
|
+
# @param idempotency_key [String] - optional
|
57
|
+
# @param tags [Hash] - optional
|
58
|
+
# @param limits [Hash] - optional
|
59
|
+
def create_individual_virtual_card(account_id:, customer_id: nil, idempotency_key: nil, tags: nil, limits: nil)
|
60
|
+
request = CreateIndividualVirtualCardRequest.new(account_id, customer_id, idempotency_key, tags, limits)
|
61
|
+
Unit::Resource::CardResource.create_card(request)
|
62
|
+
end
|
63
|
+
|
64
|
+
# Create a new business virtual card by calling Unit's API
|
65
|
+
# @see https://docs.unit.co/cards#create-business-virtual-debit-card
|
66
|
+
# @param account_id [String]
|
67
|
+
# @param type [String]
|
68
|
+
# @param idempotency_key [String] - optional
|
69
|
+
# @param tags [Hash] - optional
|
70
|
+
# @param limits [Hash] - optional
|
71
|
+
def create_business_virtual_card(account_id:, full_name:, date_of_birth:, address:, phone: nil, email: nil, idempotency_key: nil, tags: nil, limits: nil)
|
72
|
+
request = CreateBusinessVirtualDebitCardRequest.new(account_id, full_name, date_of_birth, address, phone, email, idempotency_key, tags, limits)
|
73
|
+
Unit::Resource::CardResource.create_card(request)
|
74
|
+
end
|
75
|
+
|
76
|
+
# Get pin status by calling Unit's API
|
77
|
+
# @see https://docs.unit.co/cards#get-pin-status
|
78
|
+
# @param card_id [String]
|
79
|
+
def get_pin_status(card_id:)
|
80
|
+
Unit::Resource::CardResource.get_pin_status(card_id)
|
81
|
+
end
|
82
|
+
|
83
|
+
# Report a card as a stolen by calling Unit's API
|
84
|
+
# @param card_id [String]
|
85
|
+
def report_stolen(card_id:)
|
86
|
+
Unit::Resource::CardResource.report_stolen(card_id)
|
87
|
+
end
|
88
|
+
|
89
|
+
# Report a card as a lost by calling Unit's API
|
90
|
+
# @param card_id [String]
|
91
|
+
def report_lost(card_id:)
|
92
|
+
Unit::Resource::CardResource.report_lost(card_id)
|
93
|
+
end
|
94
|
+
|
95
|
+
# Close a card by calling Unit's API
|
96
|
+
# @param card_id [String]
|
97
|
+
def close_card(card_id:)
|
98
|
+
Unit::Resource::CardResource.close_card(card_id)
|
99
|
+
end
|
100
|
+
|
101
|
+
# Freeze a card by calling Unit's API
|
102
|
+
# @param card_id [String]
|
103
|
+
def freeze_card(card_id:)
|
104
|
+
Unit::Resource::CardResource.freeze_card(card_id)
|
105
|
+
end
|
106
|
+
|
107
|
+
# Unfreeze a card by calling Unit's API
|
108
|
+
# @param card_id [String]
|
109
|
+
def unfreeze_card(card_id:)
|
110
|
+
Unit::Resource::CardResource.unfreeze_card(card_id)
|
111
|
+
end
|
112
|
+
|
113
|
+
# Replace a card by calling Unit's API
|
114
|
+
# @param card_id [String]
|
115
|
+
# @param shipping_address [Address] - optional
|
116
|
+
def replace_card(card_id:, shipping_address: nil)
|
117
|
+
request = ReplaceCardRequest.new(card_id, shipping_address)
|
118
|
+
Unit::Resource::CardResource.replace_card(request)
|
119
|
+
end
|
120
|
+
|
121
|
+
# Get a card by id by calling Unit's API
|
122
|
+
# @param card_id [String]
|
123
|
+
def get_card(card_id:)
|
124
|
+
Unit::Resource::CardResource.get_card(card_id)
|
125
|
+
end
|
126
|
+
|
127
|
+
# List cards by calling Unit's API
|
128
|
+
# @param limit [Integer] - optional
|
129
|
+
# @param offset [Integer] - optional
|
130
|
+
# @param account_id [String] - optional
|
131
|
+
# @param customer_id [String] - optional
|
132
|
+
# @param tags [Hash] - optional
|
133
|
+
# @param status [Array<String>] - optional
|
134
|
+
# @param include [Array] - optional
|
135
|
+
# @param sort [String] - optional
|
136
|
+
def list_cards(limit: CARD_LIST_LIMIT, offset: CARD_LIST_OFFSET, account_id: nil,
|
137
|
+
customer_id: nil, tags: nil, status: nil, include: nil, sort: nil)
|
138
|
+
request = ListCardParams.new(limit, offset, account_id, customer_id, tags, status, include, sort)
|
139
|
+
Unit::Resource::CardResource.list_cards(request)
|
140
|
+
end
|
141
|
+
|
142
|
+
# Get a card limits by calling Unit's API
|
143
|
+
# @param card_id [String]
|
144
|
+
def limits(card_id:)
|
145
|
+
Unit::Resource::CardResource.limits(card_id)
|
146
|
+
end
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Request to create business debit card request
|
4
|
+
# @see https://docs.unit.co/cards#create-business-debit-card
|
5
|
+
module Unit
|
6
|
+
module Card
|
7
|
+
class CreateBusinessDebitCardRequest
|
8
|
+
attr_reader :account_id, :full_name, :date_of_birth, :address, :shipping_address, :phone, :email, :design, :additional_embossed_text, :idempotency_key, :tags, :limits, :print_only_business_name
|
9
|
+
|
10
|
+
# @param account_id [String]
|
11
|
+
# @param full_name [FullName]
|
12
|
+
# @param date_of_birth [Date]
|
13
|
+
# @param address [Address]
|
14
|
+
# @param shipping_address [Address] - optional
|
15
|
+
# @param phone [Phone] - optional
|
16
|
+
# @param email [String] - optional
|
17
|
+
# @param design [String] - optional
|
18
|
+
# @param additional_embossed_text [String] - optional
|
19
|
+
# @param idempotency_key [String] - optional
|
20
|
+
# @param tags [Hash] - optional
|
21
|
+
# @param limits [Hash] - optional
|
22
|
+
# @param print_only_business_name [Boolean] - optional
|
23
|
+
def initialize(account_id, full_name, date_of_birth, address, shipping_address = nil, phone = nil, email = nil, design = nil,
|
24
|
+
additional_embossed_text = nil, idempotency_key = nil, tags = nil, limits = nil, print_only_business_name = nil)
|
25
|
+
@account_id = account_id
|
26
|
+
@full_name = full_name
|
27
|
+
@date_of_birth = date_of_birth
|
28
|
+
@address = address
|
29
|
+
@shipping_address = shipping_address
|
30
|
+
@phone = phone
|
31
|
+
@email = email
|
32
|
+
@design = design
|
33
|
+
@additional_embossed_text = additional_embossed_text
|
34
|
+
@idempotency_key = idempotency_key
|
35
|
+
@tags = tags
|
36
|
+
@limits = limits
|
37
|
+
@print_only_business_name = print_only_business_name
|
38
|
+
end
|
39
|
+
|
40
|
+
def to_json_api
|
41
|
+
payload = {
|
42
|
+
"data": {
|
43
|
+
"type": "businessDebitCard",
|
44
|
+
"attributes": {
|
45
|
+
"fullName": full_name&.represent,
|
46
|
+
"dateOfBirth": date_of_birth,
|
47
|
+
"address": address&.represent,
|
48
|
+
"shippingAddress": shipping_address,
|
49
|
+
"phone": phone&.represent,
|
50
|
+
"email": email,
|
51
|
+
"design": design,
|
52
|
+
"additionalEmbossedText": additional_embossed_text,
|
53
|
+
"idempotencyKey": idempotency_key,
|
54
|
+
"tags": tags,
|
55
|
+
"limits": limits,
|
56
|
+
"printOnlyBusinessName": print_only_business_name
|
57
|
+
},
|
58
|
+
"relationships": {
|
59
|
+
"account": Unit::Types::Relationship.new("account", account_id).to_hash
|
60
|
+
}
|
61
|
+
}
|
62
|
+
}
|
63
|
+
payload[:data][:attributes].compact!
|
64
|
+
payload.to_json
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Request to create a business virtual debit card
|
4
|
+
# @see https://docs.unit.co/cards#create-business-virtual-debit-card
|
5
|
+
module Unit
|
6
|
+
module Card
|
7
|
+
class CreateBusinessVirtualDebitCardRequest
|
8
|
+
attr_reader :account_id, :full_name, :date_of_birth, :address, :phone, :email, :idempotency_key, :tags, :limits
|
9
|
+
|
10
|
+
# @param account_id [String]
|
11
|
+
# @param full_name [FullName]
|
12
|
+
# @param date_of_birth [Date]
|
13
|
+
# @param address [Address]
|
14
|
+
# @param phone [Phone] - optional
|
15
|
+
# @param email [String] - optional
|
16
|
+
# @param idempotency_key [String] - optional
|
17
|
+
# @param tags [Hash] - optional
|
18
|
+
# @param limits [Hash] - optional
|
19
|
+
def initialize(account_id, full_name, date_of_birth, address, phone, email,
|
20
|
+
idempotency_key, tags, limits)
|
21
|
+
@account_id = account_id
|
22
|
+
@full_name = full_name
|
23
|
+
@date_of_birth = date_of_birth
|
24
|
+
@address = address
|
25
|
+
@phone = phone
|
26
|
+
@email = email
|
27
|
+
@idempotency_key = idempotency_key
|
28
|
+
@tags = tags
|
29
|
+
@limits = limits
|
30
|
+
end
|
31
|
+
|
32
|
+
def to_json_api
|
33
|
+
payload = {
|
34
|
+
"data": {
|
35
|
+
"type": "businessVirtualDebitCard",
|
36
|
+
"attributes": {
|
37
|
+
"fullName": full_name&.represent,
|
38
|
+
"dateOfBirth": date_of_birth,
|
39
|
+
"address": address&.represent,
|
40
|
+
"phone": phone&.represent,
|
41
|
+
"email": email,
|
42
|
+
"idempotencyKey": idempotency_key,
|
43
|
+
"tags": tags,
|
44
|
+
"limits": limits
|
45
|
+
},
|
46
|
+
"relationships": {
|
47
|
+
"account": Unit::Types::Relationship.new("depositAccount", account_id).to_hash
|
48
|
+
}
|
49
|
+
}
|
50
|
+
}
|
51
|
+
payload[:data][:attributes].compact!
|
52
|
+
payload.to_json
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Request to create individual debit card request
|
4
|
+
# @see https://docs.unit.co/cards#create-individual-debit-card
|
5
|
+
module Unit
|
6
|
+
module Card
|
7
|
+
class CreateIndividualDebitCardRequest
|
8
|
+
attr_reader :account_id, :customer_id, :shipping_address, :design, :additional_embossed_text, :idempotency_key, :tags, :limits, :print_only_business_name
|
9
|
+
|
10
|
+
# @param account_id [String]
|
11
|
+
# @param customer_id [String] - optional
|
12
|
+
# @param shipping_address [Address] - optional
|
13
|
+
# @param design [String] - optional
|
14
|
+
# @param additional_embossed_text [String] - optional
|
15
|
+
# @param idempotency_key [String] - optional
|
16
|
+
# @param tags [Hash] - optional
|
17
|
+
# @param limits [Hash] - optional
|
18
|
+
# @param print_only_business_name [Boolean] - optional
|
19
|
+
def initialize(account_id, customer_id = nil, shipping_address = nil, design = nil, additional_embossed_text = nil,
|
20
|
+
idempotency_key = nil, tags = nil, limits = nil, print_only_business_name = nil)
|
21
|
+
@account_id = account_id
|
22
|
+
@customer_id = customer_id
|
23
|
+
@shipping_address = shipping_address
|
24
|
+
@design = design
|
25
|
+
@additional_embossed_text = additional_embossed_text
|
26
|
+
@idempotency_key = idempotency_key
|
27
|
+
@tags = tags
|
28
|
+
@limits = limits
|
29
|
+
@print_only_business_name = print_only_business_name
|
30
|
+
end
|
31
|
+
|
32
|
+
def to_json_api
|
33
|
+
payload = {
|
34
|
+
"data": {
|
35
|
+
"type": "individualDebitCard",
|
36
|
+
"attributes": {
|
37
|
+
"shippingAddress": shipping_address&.represent,
|
38
|
+
"design": design,
|
39
|
+
"additionalEmbossedText": additional_embossed_text,
|
40
|
+
"idempotencyKey": idempotency_key,
|
41
|
+
"tags": tags,
|
42
|
+
"limits": limits,
|
43
|
+
"printOnlyBusinessName": print_only_business_name
|
44
|
+
},
|
45
|
+
"relationships": {
|
46
|
+
"account": Unit::Types::Relationship.new("depositAccount", account_id).to_hash
|
47
|
+
}
|
48
|
+
}
|
49
|
+
}
|
50
|
+
customer = { "customer": Unit::Types::Relationship.new("customer", customer_id).to_hash } unless customer_id.nil?
|
51
|
+
payload[:data][:relationships].merge!(customer) unless customer.nil?
|
52
|
+
payload[:data][:attributes].compact!
|
53
|
+
payload.to_json
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Request to create individual virtual card
|
4
|
+
# @see https://docs.unit.co/cards#create-individual-virtual-debit-card
|
5
|
+
module Unit
|
6
|
+
module Card
|
7
|
+
class CreateIndividualVirtualCardRequest
|
8
|
+
attr_reader :account_id, :customer_id, :idempotency_key, :tags, :limits
|
9
|
+
|
10
|
+
# @param account_id [String]
|
11
|
+
# @param customer_id [String] - optional
|
12
|
+
# @param idempotency_key [String] - optional
|
13
|
+
# @param tags [Hash] - optional
|
14
|
+
# @param limits [Hash] - optional
|
15
|
+
def initialize(account_id, customer_id = nil, idempotency_key = nil, tags = nil, limits = nil)
|
16
|
+
@account_id = account_id
|
17
|
+
@customer_id = customer_id
|
18
|
+
@idempotency_key = idempotency_key
|
19
|
+
@tags = tags
|
20
|
+
@limits = limits
|
21
|
+
end
|
22
|
+
|
23
|
+
def to_json_api
|
24
|
+
payload = {
|
25
|
+
"data": {
|
26
|
+
"type": "individualVirtualDebitCard",
|
27
|
+
"attributes": {
|
28
|
+
"idempotencyKey": idempotency_key,
|
29
|
+
"tags": tags,
|
30
|
+
"limits": limits
|
31
|
+
},
|
32
|
+
"relationships": {
|
33
|
+
"account": Unit::Types::Relationship.new("depositAccount", account_id).to_hash
|
34
|
+
}
|
35
|
+
}
|
36
|
+
}
|
37
|
+
customer = { "customer": Unit::Types::Relationship.new("customer", customer_id).to_hash } unless customer_id.nil?
|
38
|
+
payload[:data][:relationships].merge!(customer) unless customer.nil?
|
39
|
+
payload[:data][:attributes].compact!
|
40
|
+
payload.to_json
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Request to list cards
|
4
|
+
# @see https://docs.unit.co/cards#list-cards
|
5
|
+
module Unit
|
6
|
+
module Card
|
7
|
+
class ListCardParams
|
8
|
+
attr_reader :limit, :offset, :account_id, :customer_id, :tags, :status, :include, :sort
|
9
|
+
|
10
|
+
# @param limit [Integer] - optional
|
11
|
+
# @param offset [Integer] - optional
|
12
|
+
# @param account_id [String] - optional
|
13
|
+
# @param customer_id [String] - optional
|
14
|
+
# @param tags [String] - optional
|
15
|
+
# @param status [Array<String>] - optional
|
16
|
+
# @param include [Array] - optional
|
17
|
+
# @param sort [String] - optional
|
18
|
+
def initialize(limit = CARD_LIST_LIMIT, offset = CARD_LIST_OFFSET, account_id = nil,
|
19
|
+
customer_id = nil, tags = nil, status = nil, include = nil, sort = nil)
|
20
|
+
@limit = limit
|
21
|
+
@offset = offset
|
22
|
+
@account_id = account_id
|
23
|
+
@customer_id = customer_id
|
24
|
+
@tags = tags
|
25
|
+
@status = status
|
26
|
+
@include = include
|
27
|
+
@sort = sort
|
28
|
+
end
|
29
|
+
|
30
|
+
def to_hash
|
31
|
+
params = { "page[limit]": limit,
|
32
|
+
"page[offset]": offset,
|
33
|
+
"filter[accountId]": account_id,
|
34
|
+
"filter[customerId]": customer_id,
|
35
|
+
"filter[tags]": tags,
|
36
|
+
"include": include&.join(","),
|
37
|
+
"sort": sort }
|
38
|
+
status&.each_with_index&.map do |val, index|
|
39
|
+
params.merge!({ "filter[status][#{index}]": val })
|
40
|
+
end
|
41
|
+
params.compact
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Request to replace a card
|
4
|
+
# @see https://docs.unit.co/cards#replace-card
|
5
|
+
module Unit
|
6
|
+
module Card
|
7
|
+
class ReplaceCardRequest
|
8
|
+
attr_reader :card_id, :shipping_address
|
9
|
+
|
10
|
+
# @param card_id [String]
|
11
|
+
# @param shipping_address [Address] - optional
|
12
|
+
def initialize(card_id, shipping_address = nil)
|
13
|
+
@card_id = card_id
|
14
|
+
@shipping_address = shipping_address
|
15
|
+
end
|
16
|
+
|
17
|
+
def to_json_api
|
18
|
+
payload = {
|
19
|
+
"data": {
|
20
|
+
"type": "replaceCard",
|
21
|
+
"attributes": {
|
22
|
+
"shippingAddress": shipping_address&.represent
|
23
|
+
}
|
24
|
+
}
|
25
|
+
}
|
26
|
+
payload[:data][:attributes].compact!
|
27
|
+
payload.to_json
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Request to create a book payment
|
4
|
+
# @see https://docs.unit.co/book-payments#book-payments
|
5
|
+
module Unit
|
6
|
+
module Payment
|
7
|
+
class CreateBookPaymentRequest
|
8
|
+
attr_reader :amount, :description, :account_id, :counterparty_account_id, :transaction_summary_override, :idempotency_key, :tags, :relationships
|
9
|
+
|
10
|
+
# @param amount [Integer]
|
11
|
+
# @param description [String]
|
12
|
+
# @param account_id [String]
|
13
|
+
# @param counterparty_account_id [String]
|
14
|
+
# @param transaction_summary_override [String] - optional
|
15
|
+
# @param idempotency_key [String] - optional
|
16
|
+
# @param tags [Hash] - optional
|
17
|
+
def initialize(amount, description, account_id, counterparty_account_id, relationships, transaction_summary_override = nil,
|
18
|
+
idempotency_key = nil, tags = nil)
|
19
|
+
@amount = amount
|
20
|
+
@description = description
|
21
|
+
@account_id = account_id
|
22
|
+
@counterparty_account_id = counterparty_account_id
|
23
|
+
@relationships = relationships
|
24
|
+
@transaction_summary_override = transaction_summary_override
|
25
|
+
@idempotency_key = idempotency_key
|
26
|
+
@tags = tags
|
27
|
+
end
|
28
|
+
|
29
|
+
def to_json_api
|
30
|
+
payload = {
|
31
|
+
data: {
|
32
|
+
type: "bookPayment",
|
33
|
+
attributes: {
|
34
|
+
amount: amount,
|
35
|
+
description: description,
|
36
|
+
transactionSummaryOverride: transaction_summary_override,
|
37
|
+
idempotencyKey: idempotency_key,
|
38
|
+
tags: tags
|
39
|
+
},
|
40
|
+
relationships: { account: Unit::Types::Relationship.new("depositAccount", account_id).to_hash,
|
41
|
+
counterpartyAccount: Unit::Types::Relationship.new("depositAccount", counterparty_account_id).to_hash }
|
42
|
+
}
|
43
|
+
}
|
44
|
+
payload[:data][:attributes].compact!
|
45
|
+
payload.to_json
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Request to update a book payment
|
4
|
+
# @see https://docs.unit.co/book-payments#update-book-payment
|
5
|
+
module Unit
|
6
|
+
module Payment
|
7
|
+
class PatchBookPaymentRequest
|
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: "bookPayment",
|
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
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Unit
|
4
|
+
module Payment
|
5
|
+
autoload :CreateBookPaymentRequest, "unit/models/payment/create_book_payment_request"
|
6
|
+
autoload :PatchBookPaymentRequest, "unit/models/payment/patch_book_payment_request"
|
7
|
+
|
8
|
+
class << self
|
9
|
+
# Create a new book payment by calling Unit's API
|
10
|
+
# @see https://docs.unit.co/book-payments#book-payments
|
11
|
+
# @param amount [Integer]
|
12
|
+
# @param description [String]
|
13
|
+
# @param account_id [String]
|
14
|
+
# @param counterparty_account_id [String]
|
15
|
+
# @param transaction_summary_override [String] - optional
|
16
|
+
# @param idempotency_key [String] - optional
|
17
|
+
# @param tags [Hash] - optional
|
18
|
+
# @return [UnitResponse, UnitError]
|
19
|
+
def create_book_payment(amount:, description:, account_id:, counterparty_account_id:, transaction_summary_override: nil,
|
20
|
+
idempotency_key: nil, tags: nil)
|
21
|
+
request = Unit::Payment::CreateBookPaymentRequest.new(amount, description, account_id, counterparty_account_id, transaction_summary_override,
|
22
|
+
idempotency_key, tags)
|
23
|
+
Unit::Resource::PaymentResource.create_payment(request)
|
24
|
+
end
|
25
|
+
|
26
|
+
# Update a book payment by calling Unit's API
|
27
|
+
# @see https://docs.unit.co/book-payments#update-book-payment
|
28
|
+
# @param payment_id [String]
|
29
|
+
# @param tags [Hash] - optional
|
30
|
+
# @return [UnitResponse, UnitError]
|
31
|
+
def update_book_payment(payment_id:, tags: nil)
|
32
|
+
request = Unit::Payment::PatchBookPaymentRequest.new(payment_id, tags)
|
33
|
+
Unit::Resource::PaymentResource.update_payment(request)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Request to get bank verification pdf
|
4
|
+
# @see https://docs.unit.co/statements#get-bank-verification-pdf
|
5
|
+
module Unit
|
6
|
+
module Statement
|
7
|
+
class GetBankVerificationPdf
|
8
|
+
attr_accessor :account_id, :include_proof_of_funds
|
9
|
+
|
10
|
+
# @param account_id [String]
|
11
|
+
# @param include_proof_of_funds [Boolean]
|
12
|
+
def initialize(account_id, include_proof_of_funds: false)
|
13
|
+
@account_id = account_id
|
14
|
+
@include_proof_of_funds = include_proof_of_funds
|
15
|
+
end
|
16
|
+
|
17
|
+
def to_hash
|
18
|
+
params = { "includeProofOfFunds": include_proof_of_funds }
|
19
|
+
params.compact
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Request to get html by id
|
4
|
+
# @see https://docs.unit.co/statements#get-statement-html
|
5
|
+
module Unit
|
6
|
+
module Statement
|
7
|
+
class GetHtmlByIdRequest
|
8
|
+
attr_accessor :statement_id, :customer_id, :language
|
9
|
+
|
10
|
+
# @param statement_id [String]
|
11
|
+
# @param customer_id [String]
|
12
|
+
# @param language [String]
|
13
|
+
def initialize(statement_id, customer_id, language = nil)
|
14
|
+
@statement_id = statement_id
|
15
|
+
@customer_id = customer_id
|
16
|
+
@language = language
|
17
|
+
end
|
18
|
+
|
19
|
+
def to_hash
|
20
|
+
params = { "filter[customerId]": customer_id,
|
21
|
+
"language": language }
|
22
|
+
params.compact
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Request to get pdf by id
|
4
|
+
# @see https://docs.unit.co/statements#get-statement-pdf
|
5
|
+
module Unit
|
6
|
+
module Statement
|
7
|
+
class GetPdfByIdRequest
|
8
|
+
attr_accessor :statement_id, :customer_id, :language
|
9
|
+
|
10
|
+
# @param statement_id [String]
|
11
|
+
# @param customer_id [String]
|
12
|
+
# @param language [String]
|
13
|
+
def initialize(statement_id, customer_id, language = nil)
|
14
|
+
@statement_id = statement_id
|
15
|
+
@customer_id = customer_id
|
16
|
+
@language = language
|
17
|
+
end
|
18
|
+
|
19
|
+
def to_hash
|
20
|
+
params = { "filter[customerId]": customer_id,
|
21
|
+
"language": language }
|
22
|
+
params.compact
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|