unit_ruby_sdk 0.1.4 → 1.0.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 +32 -4
- data/lib/unit/api_resources/atm_location_resource.rb +21 -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/statement_resource.rb +46 -0
- data/lib/unit/models/api_token/org/create_api_token_request.rb +2 -2
- data/lib/unit/models/application/application.rb +2 -5
- data/lib/unit/models/application/upload_document_request.rb +2 -5
- data/lib/unit/models/atm_location/atm_location.rb +38 -0
- data/lib/unit/models/atm_location/list_by_address_params.rb +26 -0
- data/lib/unit/models/atm_location/list_by_coordinates_params.rb +26 -0
- data/lib/unit/models/atm_location/list_by_postal_code_params.rb +26 -0
- 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/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/types/coordinates.rb +24 -0
- data/lib/unit/types/document_file_type.rb +11 -0
- data/lib/unit/utils/http_helper.rb +15 -2
- data/lib/unit/version.rb +1 -1
- data/lib/unit_ruby_sdk.rb +8 -1
- metadata +23 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e391082a9b8407e9e7ff1848ef06235d65aa3254b6c52ce5548bd4ad02534485
|
4
|
+
data.tar.gz: 85d795785020ef391810521d23404e989201943ab4a41ca9ab762b1bad068612
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 54185c5b5bca29ededcf81ed28d193fcf72c2012206f7a4bf095f3f58d958ec52e0f1c31ea34738ec675f3dcb4e1045f339ca6bb842298a736ae4af784e7bb0e
|
7
|
+
data.tar.gz: c9b2abeae465e2d34cdcb2c83f48565416fe2874ea983ced5eca080c6ee8b746675d3813e33dd5bb5fdc95d5ef01091360b4c51eedadcaf5760bb9e47d0a355a
|
data/README.md
CHANGED
@@ -14,6 +14,8 @@ gem install unit_ruby_sdk
|
|
14
14
|
|
15
15
|
## Usage
|
16
16
|
|
17
|
+
Bellow are a few exapmles of the Ruby SDK application. For full documentation of the Unit API please refer to the full documentation at https://docs.unit.co/
|
18
|
+
|
17
19
|
### Creating a Business Application
|
18
20
|
|
19
21
|
```ruby
|
@@ -45,6 +47,19 @@ response = Unit::Application.create_business_application(
|
|
45
47
|
application = response.data
|
46
48
|
|
47
49
|
puts application.id
|
50
|
+
|
51
|
+
file = File.open("./spec/test.pdf", "rb")
|
52
|
+
contents = file.read
|
53
|
+
file.close
|
54
|
+
|
55
|
+
upload_document_request = Unit::Application.upload_document(
|
56
|
+
application_id: "836683",
|
57
|
+
document_id: "125214",
|
58
|
+
file: contents,
|
59
|
+
file_type: Unit::Types::DocumentFileType::PDF,
|
60
|
+
is_back_side: true)
|
61
|
+
|
62
|
+
puts upload_document_request.data.id
|
48
63
|
```
|
49
64
|
|
50
65
|
### Fetching a Customer
|
@@ -65,10 +80,10 @@ puts customer.id
|
|
65
80
|
require 'unit_ruby_sdk'
|
66
81
|
|
67
82
|
response = Unit::Payment.create_book_payment(
|
68
|
-
amount:
|
69
|
-
description:
|
70
|
-
|
71
|
-
|
83
|
+
amount: 1000,
|
84
|
+
description: "test payment",
|
85
|
+
account_id: "27573",
|
86
|
+
counterparty_account_id: "36981"
|
72
87
|
)
|
73
88
|
payment = response.data
|
74
89
|
puts payment.id
|
@@ -82,6 +97,19 @@ transaction = response.data
|
|
82
97
|
puts transaction.id
|
83
98
|
```
|
84
99
|
|
100
|
+
### Creating an individual debit card
|
101
|
+
```ruby
|
102
|
+
response = Unit::Card.create_individual_debit_card(
|
103
|
+
account_id: '1234',
|
104
|
+
type: "depositAccount",
|
105
|
+
shipping_address: address,
|
106
|
+
design: "default",
|
107
|
+
additional_embossed_text: "Second Cardholder"
|
108
|
+
)
|
109
|
+
card = response.data
|
110
|
+
puts card.id
|
111
|
+
```
|
112
|
+
|
85
113
|
### Logging Errors
|
86
114
|
|
87
115
|
```ruby
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "./base_resource"
|
4
|
+
require_relative "../utils/http_helper"
|
5
|
+
require "json"
|
6
|
+
|
7
|
+
module Unit
|
8
|
+
module Resource
|
9
|
+
class AtmLocationResource < Unit::Resource::BaseResource
|
10
|
+
class << self
|
11
|
+
# Get a list of ATM locations by calling Unit's API
|
12
|
+
# @param params [ListByCoordinatesParams, ListByAddressParams, ListByPostalCodeParams] The parameters to use to get a list of ATM locations
|
13
|
+
# @return [Unit::Response] The response from Unit's API
|
14
|
+
def list(params = nil)
|
15
|
+
response = HttpHelper.get("#{api_url}/atm-locations", params: params.to_hash, headers: headers)
|
16
|
+
response_handler(response)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -11,6 +11,10 @@ module Unit
|
|
11
11
|
handler.from_json_api(response)
|
12
12
|
end
|
13
13
|
|
14
|
+
def file_response_handler(response)
|
15
|
+
response.code.to_i.between?(200, 299) ? response.body : Unit::UnitError
|
16
|
+
end
|
17
|
+
|
14
18
|
protected
|
15
19
|
|
16
20
|
def api_url
|
@@ -25,7 +29,7 @@ module Unit
|
|
25
29
|
{
|
26
30
|
"Content-Type" => "application/vnd.api+json",
|
27
31
|
"Authorization" => "Bearer #{Unit.config[:token]}",
|
28
|
-
"
|
32
|
+
"X-UNIT-SDK" => "unit-ruby-sdk@v#{Unit::VERSION}"
|
29
33
|
}
|
30
34
|
end
|
31
35
|
end
|
@@ -0,0 +1,104 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "./base_resource"
|
4
|
+
require_relative "../utils/http_helper"
|
5
|
+
require "json"
|
6
|
+
# class for creating requests for cards to Unit API and parsing responses
|
7
|
+
# @see https://docs.unit.co/cards
|
8
|
+
module Unit
|
9
|
+
module Resource
|
10
|
+
class CardResource < Unit::Resource::BaseResource
|
11
|
+
class << self
|
12
|
+
# Create a new card by calling Unit's API
|
13
|
+
# @param [CreateIndividualDebitCardRequest, CreateIndividualVirtualCardRequest] request
|
14
|
+
# @return [UnitResponse, UnitError]
|
15
|
+
def create_card(request)
|
16
|
+
payload = request.to_json_api
|
17
|
+
response = HttpHelper.post("#{api_url}/cards", body: payload, headers: headers)
|
18
|
+
response_handler(response)
|
19
|
+
end
|
20
|
+
|
21
|
+
# Get pin status by calling Unit's API
|
22
|
+
# @param card_id [String]
|
23
|
+
# @return [UnitResponse, UnitError]
|
24
|
+
def get_pin_status(card_id)
|
25
|
+
response = HttpHelper.get("#{api_url}/cards/#{card_id}/secure-data/pin/status", headers: headers)
|
26
|
+
response_handler(response)
|
27
|
+
end
|
28
|
+
|
29
|
+
# Report a card as a stolen by calling Unit's API
|
30
|
+
# @param card_id [String]
|
31
|
+
# @return [UnitResponse, UnitError]
|
32
|
+
def report_stolen(card_id)
|
33
|
+
response = HttpHelper.post("#{api_url}/cards/#{card_id}/report-stolen", headers: headers)
|
34
|
+
response_handler(response)
|
35
|
+
end
|
36
|
+
|
37
|
+
# Report a card as a lost by calling Unit's API
|
38
|
+
# @param card_id [String]
|
39
|
+
# @return [UnitResponse, UnitError]
|
40
|
+
def report_lost(card_id)
|
41
|
+
response = HttpHelper.post("#{api_url}/cards/#{card_id}/report-lost", headers: headers)
|
42
|
+
response_handler(response)
|
43
|
+
end
|
44
|
+
|
45
|
+
# Close a card by calling Unit's API
|
46
|
+
# @param card_id [String]
|
47
|
+
# @return [UnitResponse, UnitError]
|
48
|
+
def close_card(card_id)
|
49
|
+
response = HttpHelper.post("#{api_url}/cards/#{card_id}/close", headers: headers)
|
50
|
+
response_handler(response)
|
51
|
+
end
|
52
|
+
|
53
|
+
# Freeze a card by calling Unit's API
|
54
|
+
# @param card_id [String]
|
55
|
+
# @return [UnitResponse, UnitError]
|
56
|
+
def freeze_card(card_id)
|
57
|
+
response = HttpHelper.post("#{api_url}/cards/#{card_id}/freeze", headers: headers)
|
58
|
+
response_handler(response)
|
59
|
+
end
|
60
|
+
|
61
|
+
# Unfreeze a card by calling Unit's API
|
62
|
+
# @param card_id [String]
|
63
|
+
# @return [UnitResponse, UnitError]
|
64
|
+
def unfreeze_card(card_id)
|
65
|
+
response = HttpHelper.post("#{api_url}/cards/#{card_id}/unfreeze", headers: headers)
|
66
|
+
response_handler(response)
|
67
|
+
end
|
68
|
+
|
69
|
+
# Replace a card by calling Unit's API
|
70
|
+
# @param request [ReplaceCardRequest]
|
71
|
+
# @return [UnitResponse, UnitError]
|
72
|
+
def replace_card(request)
|
73
|
+
payload = request.to_json_api
|
74
|
+
response = HttpHelper.post("#{api_url}/cards/#{request.card_id}/replace", body: payload, headers: headers)
|
75
|
+
response_handler(response)
|
76
|
+
end
|
77
|
+
|
78
|
+
# Get a card by id by calling Unit's API
|
79
|
+
# @param card_id [String]
|
80
|
+
# @return [UnitResponse, UnitError]
|
81
|
+
def get_card(card_id)
|
82
|
+
response = HttpHelper.get("#{api_url}/cards/#{card_id}", headers: headers)
|
83
|
+
response_handler(response)
|
84
|
+
end
|
85
|
+
|
86
|
+
# List cards by calling Unit's API
|
87
|
+
# @param params [ListCardParams]
|
88
|
+
# @return [UnitResponse, UnitError]
|
89
|
+
def list_cards(params = nil)
|
90
|
+
response = HttpHelper.get("#{api_url}/cards", params: params&.to_hash, headers: headers)
|
91
|
+
response_handler(response)
|
92
|
+
end
|
93
|
+
|
94
|
+
# Get card limits by calling Unit's API
|
95
|
+
# @param card_id [String]
|
96
|
+
# @return [UnitResponse, UnitError]
|
97
|
+
def limits(card_id)
|
98
|
+
response = HttpHelper.get("#{api_url}/cards/#{card_id}/limits", headers: headers)
|
99
|
+
response_handler(response)
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "./base_resource"
|
4
|
+
require_relative "../utils/http_helper"
|
5
|
+
require "json"
|
6
|
+
# class for creating requests for statements to Unit API and parsing responses
|
7
|
+
# @see https://docs.unit.co/cards
|
8
|
+
module Unit
|
9
|
+
module Resource
|
10
|
+
class StatementResource < Unit::Resource::BaseResource
|
11
|
+
class << self
|
12
|
+
# Get statements by calling Unit's API
|
13
|
+
# @param params [ListStatementParams]
|
14
|
+
# @return [UnitResponse, UnitError]
|
15
|
+
def list(params = nil)
|
16
|
+
response = HttpHelper.get("#{api_url}/statements", params: params&.to_hash, headers: headers)
|
17
|
+
response_handler(response)
|
18
|
+
end
|
19
|
+
|
20
|
+
# Get a html statement by id by calling Unit's API
|
21
|
+
# @param params [GetHtmlByIdRequest]
|
22
|
+
# @return [UnitResponse, UnitError]
|
23
|
+
def get_html_by_id(request)
|
24
|
+
response = HttpHelper.get("#{api_url}/statements/#{request.statement_id}/html", params: request.to_hash, headers: headers)
|
25
|
+
file_response_handler(response)
|
26
|
+
end
|
27
|
+
|
28
|
+
# Get a pdf statement by id by calling Unit's API
|
29
|
+
# @param request [GetPdfByIdRequest]
|
30
|
+
# @return [UnitResponse, UnitError]
|
31
|
+
def get_pdf_by_id(request)
|
32
|
+
response = HttpHelper.get("#{api_url}/statements/#{request.statement_id}/pdf", params: request.to_hash, headers: headers)
|
33
|
+
file_response_handler(response)
|
34
|
+
end
|
35
|
+
|
36
|
+
# Get bank verification by calling Unit's API
|
37
|
+
# @param request [GetBankVerificationRequest]
|
38
|
+
# @return [UnitResponse, UnitError]
|
39
|
+
def get_bank_verification(request)
|
40
|
+
response = HttpHelper.get("#{api_url}/statements/#{request.account_id}/bank/pdf", params: request&.to_hash, headers: headers)
|
41
|
+
file_response_handler(response)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -10,7 +10,7 @@ module Unit
|
|
10
10
|
|
11
11
|
# @param user_id [String]
|
12
12
|
# @param description [String]
|
13
|
-
# @param scope [String]
|
13
|
+
# @param scope [Array<String>]
|
14
14
|
# @param expiration [String]
|
15
15
|
# @param source_ip [String] - optional
|
16
16
|
# @param resources [Array<RestrictedResource>] - optional
|
@@ -27,7 +27,7 @@ module Unit
|
|
27
27
|
result = { data: { type: "apiToken",
|
28
28
|
attributes:
|
29
29
|
{ description: description,
|
30
|
-
scope: scope,
|
30
|
+
scope: scope.join(" "),
|
31
31
|
expiration: expiration,
|
32
32
|
sourceIp: source_ip,
|
33
33
|
resources: resources } } }
|
@@ -111,11 +111,8 @@ module Unit
|
|
111
111
|
# Upload an application document by calling Unit's API
|
112
112
|
# @param application_id [String] The application ID
|
113
113
|
# @param document_id [String] The document ID
|
114
|
-
# @param file [String] The file
|
115
|
-
# @param file_type [String] The file type
|
116
|
-
# @option file_type [String] :pdf
|
117
|
-
# @option file_type [String] :jpg
|
118
|
-
# @option file_type [String] :png
|
114
|
+
# @param file [String] The file content
|
115
|
+
# @param file_type [String] The file type. One of the Unit::Types::DocumentFileType constants.
|
119
116
|
# @param is_back_side [Boolean] The file is back side
|
120
117
|
# @return [UnitResponse, UnitError]
|
121
118
|
def upload_document(application_id:, document_id:, file:, file_type:, is_back_side: false)
|
@@ -9,11 +9,8 @@ module Unit
|
|
9
9
|
|
10
10
|
# @param application_id [String] The application ID
|
11
11
|
# @param document_id [String] The document ID
|
12
|
-
# @param file [String] The file
|
13
|
-
# @param file_type [String] The file type
|
14
|
-
# @option file_type [String] :pdf
|
15
|
-
# @option file_type [String] :jpg
|
16
|
-
# @option file_type [String] :png
|
12
|
+
# @param file [String] The file content
|
13
|
+
# @param file_type [String] The file type. One of the Unit::Types::DocumentFileType constants.
|
17
14
|
# @param is_back_side [Boolean] The file is back side
|
18
15
|
def initialize(application_id, document_id, file, file_type, is_back_side: false)
|
19
16
|
@application_id = application_id
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Unit
|
4
|
+
module AtmLocation
|
5
|
+
autoload :ListByCoordinatesParams, "unit/models/atm_location/list_by_coordinates_params"
|
6
|
+
autoload :ListByAddressParams, "unit/models/atm_location/list_by_address_params"
|
7
|
+
autoload :ListByPostalCodeParams, "unit/models/atm_location/list_by_postal_code_params"
|
8
|
+
|
9
|
+
class << self
|
10
|
+
# Get a list of ATM locations by coordinates by calling Unit's API
|
11
|
+
# @see https://docs.unit.co/cards-atm-locations#list-atm-locations-by-coordinates
|
12
|
+
# @param coordinates [Coordinates]
|
13
|
+
# @param search_radius [Integer] - optional
|
14
|
+
def list_by_coordinates(coordinates:, search_radius: nil)
|
15
|
+
params = ListByCoordinatesParams.new(coordinates, search_radius)
|
16
|
+
Unit::Resource::AtmLocationResource.list(params)
|
17
|
+
end
|
18
|
+
|
19
|
+
# Get a list of ATM locations by postal code by calling Unit's API
|
20
|
+
# @see https://docs.unit.co/cards-atm-locations#list-atm-locations-by-postal-code
|
21
|
+
# @param postal_code [String]
|
22
|
+
# @param search_radius [Integer] - optional
|
23
|
+
def list_by_postal_code(postal_code:, search_radius: nil)
|
24
|
+
params = ListByPostalCodeParams.new(postal_code, search_radius)
|
25
|
+
Unit::Resource::AtmLocationResource.list(params)
|
26
|
+
end
|
27
|
+
|
28
|
+
# Get a list of ATM locations by address by calling Unit's API
|
29
|
+
# @see https://docs.unit.co/cards-atm-locations#list-atm-locations-by-address
|
30
|
+
# @param address [Address]
|
31
|
+
# @param search_radius [Integer] - optional
|
32
|
+
def list_by_address(address:, search_radius: nil)
|
33
|
+
params = ListByAddressParams.new(address, search_radius)
|
34
|
+
Unit::Resource::AtmLocationResource.list(params)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# params fot list atm locations by address
|
4
|
+
# @see
|
5
|
+
module Unit
|
6
|
+
module AtmLocation
|
7
|
+
class ListByAddressParams
|
8
|
+
attr_reader :address, :search_radius
|
9
|
+
|
10
|
+
# @param address [Address]
|
11
|
+
# @param search_radius [Integer]
|
12
|
+
def initialize(address, search_radius = nil)
|
13
|
+
@address = address
|
14
|
+
@search_radius = search_radius
|
15
|
+
end
|
16
|
+
|
17
|
+
def to_hash
|
18
|
+
params = {
|
19
|
+
"filter[address]": address.represent.to_json,
|
20
|
+
"filter[searchRadius]": search_radius
|
21
|
+
}
|
22
|
+
params.compact
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# params to list atm locations by coordinates
|
4
|
+
# @see https://docs.unit.co/cards-atm-locations/#list-atm-locations-by-coordinates
|
5
|
+
module Unit
|
6
|
+
module AtmLocation
|
7
|
+
class ListByCoordinatesParams
|
8
|
+
attr_reader :coordinates, :search_radius
|
9
|
+
|
10
|
+
# @param coordinates [Coordinates]
|
11
|
+
# @param search_radius [Integer]
|
12
|
+
def initialize(coordinates, search_radius = nil)
|
13
|
+
@coordinates = coordinates
|
14
|
+
@search_radius = search_radius
|
15
|
+
end
|
16
|
+
|
17
|
+
def to_hash
|
18
|
+
params = {
|
19
|
+
"filter[coordinates]": coordinates.represent,
|
20
|
+
"filter[searchRadius]": search_radius
|
21
|
+
}
|
22
|
+
params.compact
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# params to list atm locations by postal code
|
4
|
+
# @see https://docs.unit.co/cards-atm-locations/#list-atm-locations-by-postal-code
|
5
|
+
module Unit
|
6
|
+
module AtmLocation
|
7
|
+
class ListByPostalCodeParams
|
8
|
+
attr_reader :postal_code, :search_radius
|
9
|
+
|
10
|
+
# @param postal_code [String]
|
11
|
+
# @param search_radius [Integer]
|
12
|
+
def initialize(postal_code, search_radius = nil)
|
13
|
+
@postal_code = postal_code
|
14
|
+
@search_radius = search_radius
|
15
|
+
end
|
16
|
+
|
17
|
+
def to_hash
|
18
|
+
params = {
|
19
|
+
"filter[postalCode]": postal_code,
|
20
|
+
"filter[searchRadius]": search_radius
|
21
|
+
}
|
22
|
+
params.compact
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -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,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
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Request to list statements
|
4
|
+
# @see https://docs.unit.co/statements#list-statements
|
5
|
+
module Unit
|
6
|
+
module Statement
|
7
|
+
class ListStatementParams
|
8
|
+
attr_reader :limit, :offset, :account_id, :customer_id, :period, :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 period [String] - optional
|
15
|
+
# @param sort [String] - optional
|
16
|
+
def initialize(limit = STATEMENT_LIST_LIMIT, offset = STATEMENT_LIST_OFFSET,
|
17
|
+
account_id = nil, customer_id = nil, period = nil, sort = nil)
|
18
|
+
@limit = limit
|
19
|
+
@offset = offset
|
20
|
+
@account_id = account_id
|
21
|
+
@customer_id = customer_id
|
22
|
+
@period = period
|
23
|
+
@sort = sort
|
24
|
+
end
|
25
|
+
|
26
|
+
def to_hash
|
27
|
+
params = { "page[limit]": limit,
|
28
|
+
"page[offset]": offset,
|
29
|
+
"filter[accountId]": account_id,
|
30
|
+
"filter[customerId]": customer_id,
|
31
|
+
"filter[period]": period,
|
32
|
+
"sort": sort }
|
33
|
+
params.compact
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Unit
|
4
|
+
module Statement
|
5
|
+
STATEMENT_LIST_LIMIT = 100
|
6
|
+
STATEMENT_LIST_OFFSET = 0
|
7
|
+
autoload :ListStatementParams, "unit/models/statement/list_statement_params"
|
8
|
+
autoload :GetPdfByIdRequest, "unit/models/statement/get_pdf_by_id_request"
|
9
|
+
autoload :GetHtmlByIdRequest, "unit/models/statement/get_html_by_id_request"
|
10
|
+
autoload :GetBankVerificationPdf, "unit/models/statement/get_bank_verification_pdf"
|
11
|
+
|
12
|
+
class << self
|
13
|
+
# List statements
|
14
|
+
# @see https://docs.unit.co/statements#list-statements
|
15
|
+
# @param limit [Integer]
|
16
|
+
# @param offset [Integer]
|
17
|
+
# @param account_id [String]
|
18
|
+
# @param customer_id [String]
|
19
|
+
# @param period [String]
|
20
|
+
# @param sort [String]
|
21
|
+
def list_statements(limit: STATEMENT_LIST_LIMIT, offset: STATEMENT_LIST_OFFSET,
|
22
|
+
account_id: nil, customer_id: nil, period: nil, sort: nil)
|
23
|
+
params = ListStatementParams.new(limit, offset, account_id, customer_id, period, sort)
|
24
|
+
Unit::Resource::StatementResource.list(params)
|
25
|
+
end
|
26
|
+
|
27
|
+
# Get statement pdf by id
|
28
|
+
# @see https://docs.unit.co/statements#get-statement-pdf
|
29
|
+
# @param customer_id [String]
|
30
|
+
# @param language [String]
|
31
|
+
def get_pdf_by_id(statement_id:, customer_id:, language: nil)
|
32
|
+
request = GetPdfByIdRequest.new(statement_id, customer_id, language)
|
33
|
+
Unit::Resource::StatementResource.get_pdf_by_id(request)
|
34
|
+
end
|
35
|
+
|
36
|
+
# Get statement html by id
|
37
|
+
# @see https://docs.unit.co/statements#get-statement-html
|
38
|
+
# @param customer_id [String]
|
39
|
+
# @param language [String]
|
40
|
+
def get_html_by_id(statement_id:, customer_id:, language: nil)
|
41
|
+
request = GetHtmlByIdRequest.new(statement_id, customer_id, language)
|
42
|
+
Unit::Resource::StatementResource.get_html_by_id(request)
|
43
|
+
end
|
44
|
+
|
45
|
+
# Get a bank verification pdf
|
46
|
+
# @see https://docs.unit.co/statements#get-bank-verification-pdf
|
47
|
+
# @param account_id [String]
|
48
|
+
# @param include_proof_of_funds [Boolean]
|
49
|
+
def get_bank_verification_pdf(account_id:, include_proof_of_funds: false)
|
50
|
+
request = GetBankVerificationPdf.new(account_id, include_proof_of_funds: include_proof_of_funds)
|
51
|
+
Unit::Resource::StatementResource.get_bank_verification(request)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Unit
|
4
|
+
module Types
|
5
|
+
class Coordinates
|
6
|
+
attr_reader :latitude, :longitude
|
7
|
+
|
8
|
+
# @param latitude [Float] The latitude
|
9
|
+
# @param longitude [Float] The longitude
|
10
|
+
def initialize(latitude, longitude)
|
11
|
+
@latitude = latitude
|
12
|
+
@longitude = longitude
|
13
|
+
end
|
14
|
+
|
15
|
+
def represent
|
16
|
+
params = {
|
17
|
+
longitude: longitude,
|
18
|
+
latitude: latitude
|
19
|
+
}
|
20
|
+
params.compact.to_json
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -5,6 +5,7 @@ require "net/http"
|
|
5
5
|
require "json"
|
6
6
|
|
7
7
|
module HttpHelper
|
8
|
+
VALUES = [:"filter[searchRadius]"].freeze
|
8
9
|
def self.get(url, headers:, params: nil)
|
9
10
|
make_request(Net::HTTP::Get, url, headers, params: params)
|
10
11
|
end
|
@@ -35,12 +36,20 @@ module HttpHelper
|
|
35
36
|
request = net_http.new uri, headers
|
36
37
|
request.body = body unless body.nil?
|
37
38
|
response = http.request request
|
38
|
-
response.body =
|
39
|
+
response.body = response_check(response)
|
39
40
|
response
|
40
41
|
end
|
41
42
|
end
|
42
43
|
|
43
|
-
def self.
|
44
|
+
def self.response_check(response)
|
45
|
+
if response.body.include?("html") || response.body.include?("PDF")
|
46
|
+
response.body
|
47
|
+
else
|
48
|
+
JSON.parse(response.body)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def self.value_check(value, key = nil)
|
44
53
|
case value
|
45
54
|
when Hash then value.map { |k, v| encode(v, append_key(key, k)) }.join("&")
|
46
55
|
when Array then value.map { |v| encode(v, "#{key}[]") }.join("&")
|
@@ -50,6 +59,10 @@ module HttpHelper
|
|
50
59
|
end
|
51
60
|
end
|
52
61
|
|
62
|
+
def self.encode(value, key = nil)
|
63
|
+
value.instance_of?(Hash) && value.key?(VALUES.map { |val| val }) ? value.map { |k, v| "#{k}=#{v}" }.join("&") : value_check(value, key)
|
64
|
+
end
|
65
|
+
|
53
66
|
def self.append_key(root_key, key)
|
54
67
|
root_key.nil? ? key : "#{root_key}[#{key}]"
|
55
68
|
end
|
data/lib/unit/version.rb
CHANGED
data/lib/unit_ruby_sdk.rb
CHANGED
@@ -9,7 +9,9 @@ module Unit
|
|
9
9
|
autoload :ApiToken, "unit/models/api_token/api_token"
|
10
10
|
autoload :Payment, "unit/models/payment/payment"
|
11
11
|
autoload :Transaction, "unit/models/transaction/transaction"
|
12
|
-
|
12
|
+
autoload :Card, "unit/models/card/card"
|
13
|
+
autoload :Statement, "unit/models/statement/statement"
|
14
|
+
autoload :AtmLocation, "unit/models/atm_location/atm_location"
|
13
15
|
module Resource
|
14
16
|
autoload :ApplicationResource, "unit/api_resources/application_resource"
|
15
17
|
autoload :CustomerResource, "unit/api_resources/customer_resource"
|
@@ -17,6 +19,9 @@ module Unit
|
|
17
19
|
autoload :ApiTokenResource, "unit/api_resources/api_token_resource"
|
18
20
|
autoload :PaymentResource, "unit/api_resources/payment_resource"
|
19
21
|
autoload :TransactionResource, "unit/api_resources/transaction_resource"
|
22
|
+
autoload :CardResource, "unit/api_resources/card_resource"
|
23
|
+
autoload :StatementResource, "unit/api_resources/statement_resource"
|
24
|
+
autoload :AtmLocationResource, "unit/api_resources/atm_location_resource"
|
20
25
|
end
|
21
26
|
|
22
27
|
module Types
|
@@ -33,6 +38,8 @@ module Unit
|
|
33
38
|
autoload :Relationship, "unit/types/relationship"
|
34
39
|
autoload :RelationshipArray, "unit/types/relationship_array"
|
35
40
|
autoload :RestrictedResource, "unit/types/restricted_resource"
|
41
|
+
autoload :DocumentFileType, "unit/types/document_file_type"
|
42
|
+
autoload :Coordinates, "unit/types/coordinates"
|
36
43
|
end
|
37
44
|
|
38
45
|
autoload :UnitErrorPayload, "unit/errors/unit_error_payload"
|
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: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Unit
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-01-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: factory_bot_rails
|
@@ -97,9 +97,12 @@ files:
|
|
97
97
|
- lib/unit/api_resources/account_resource.rb
|
98
98
|
- lib/unit/api_resources/api_token_resource.rb
|
99
99
|
- lib/unit/api_resources/application_resource.rb
|
100
|
+
- lib/unit/api_resources/atm_location_resource.rb
|
100
101
|
- lib/unit/api_resources/base_resource.rb
|
102
|
+
- lib/unit/api_resources/card_resource.rb
|
101
103
|
- lib/unit/api_resources/customer_resource.rb
|
102
104
|
- lib/unit/api_resources/payment_resource.rb
|
105
|
+
- lib/unit/api_resources/statement_resource.rb
|
103
106
|
- lib/unit/api_resources/transaction_resource.rb
|
104
107
|
- lib/unit/errors/unit_error.rb
|
105
108
|
- lib/unit/errors/unit_error_payload.rb
|
@@ -122,6 +125,17 @@ files:
|
|
122
125
|
- lib/unit/models/application/list_application_params.rb
|
123
126
|
- lib/unit/models/application/patch_application_request.rb
|
124
127
|
- lib/unit/models/application/upload_document_request.rb
|
128
|
+
- lib/unit/models/atm_location/atm_location.rb
|
129
|
+
- lib/unit/models/atm_location/list_by_address_params.rb
|
130
|
+
- lib/unit/models/atm_location/list_by_coordinates_params.rb
|
131
|
+
- lib/unit/models/atm_location/list_by_postal_code_params.rb
|
132
|
+
- lib/unit/models/card/card.rb
|
133
|
+
- lib/unit/models/card/create_business_debit_card_request.rb
|
134
|
+
- lib/unit/models/card/create_business_virtual_debit_card_request.rb
|
135
|
+
- lib/unit/models/card/create_individual_debit_card_request.rb
|
136
|
+
- lib/unit/models/card/create_individual_virtual_card_request.rb
|
137
|
+
- lib/unit/models/card/list_card_params.rb
|
138
|
+
- lib/unit/models/card/replace_card_request.rb
|
125
139
|
- lib/unit/models/customer/add_authorized_users_request.rb
|
126
140
|
- lib/unit/models/customer/archive_customer_request.rb
|
127
141
|
- lib/unit/models/customer/customer.rb
|
@@ -132,6 +146,11 @@ files:
|
|
132
146
|
- lib/unit/models/payment/create_book_payment_request.rb
|
133
147
|
- lib/unit/models/payment/patch_book_payment_request.rb
|
134
148
|
- lib/unit/models/payment/payment.rb
|
149
|
+
- lib/unit/models/statement/get_bank_verification_pdf.rb
|
150
|
+
- lib/unit/models/statement/get_html_by_id_request.rb
|
151
|
+
- lib/unit/models/statement/get_pdf_by_id_request.rb
|
152
|
+
- lib/unit/models/statement/list_statement_params.rb
|
153
|
+
- lib/unit/models/statement/statement.rb
|
135
154
|
- lib/unit/models/transaction/get_transaction_params.rb
|
136
155
|
- lib/unit/models/transaction/list_transaction_params.rb
|
137
156
|
- lib/unit/models/transaction/patch_tags_request.rb
|
@@ -142,7 +161,9 @@ files:
|
|
142
161
|
- lib/unit/types/authorized_user.rb
|
143
162
|
- lib/unit/types/beneficial_owner.rb
|
144
163
|
- lib/unit/types/business_contact.rb
|
164
|
+
- lib/unit/types/coordinates.rb
|
145
165
|
- lib/unit/types/device_fingerprint.rb
|
166
|
+
- lib/unit/types/document_file_type.rb
|
146
167
|
- lib/unit/types/evaluation_params.rb
|
147
168
|
- lib/unit/types/full_name.rb
|
148
169
|
- lib/unit/types/officer.rb
|