unit_ruby_sdk 0.1.5 → 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 +17 -4
- data/lib/unit/api_resources/atm_location_resource.rb +21 -0
- 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/types/coordinates.rb +24 -0
- data/lib/unit/types/document_file_type.rb +11 -0
- data/lib/unit/utils/http_helper.rb +6 -1
- data/lib/unit/version.rb +1 -1
- data/lib/unit_ruby_sdk.rb +4 -1
- metadata +9 -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
@@ -47,6 +47,19 @@ response = Unit::Application.create_business_application(
|
|
47
47
|
application = response.data
|
48
48
|
|
49
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
|
50
63
|
```
|
51
64
|
|
52
65
|
### Fetching a Customer
|
@@ -67,10 +80,10 @@ puts customer.id
|
|
67
80
|
require 'unit_ruby_sdk'
|
68
81
|
|
69
82
|
response = Unit::Payment.create_book_payment(
|
70
|
-
amount:
|
71
|
-
description:
|
72
|
-
|
73
|
-
|
83
|
+
amount: 1000,
|
84
|
+
description: "test payment",
|
85
|
+
account_id: "27573",
|
86
|
+
counterparty_account_id: "36981"
|
74
87
|
)
|
75
88
|
payment = response.data
|
76
89
|
puts payment.id
|
@@ -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
|
@@ -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,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
|
@@ -48,7 +49,7 @@ module HttpHelper
|
|
48
49
|
end
|
49
50
|
end
|
50
51
|
|
51
|
-
def self.
|
52
|
+
def self.value_check(value, key = nil)
|
52
53
|
case value
|
53
54
|
when Hash then value.map { |k, v| encode(v, append_key(key, k)) }.join("&")
|
54
55
|
when Array then value.map { |v| encode(v, "#{key}[]") }.join("&")
|
@@ -58,6 +59,10 @@ module HttpHelper
|
|
58
59
|
end
|
59
60
|
end
|
60
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
|
+
|
61
66
|
def self.append_key(root_key, key)
|
62
67
|
root_key.nil? ? key : "#{root_key}[#{key}]"
|
63
68
|
end
|
data/lib/unit/version.rb
CHANGED
data/lib/unit_ruby_sdk.rb
CHANGED
@@ -11,7 +11,7 @@ module Unit
|
|
11
11
|
autoload :Transaction, "unit/models/transaction/transaction"
|
12
12
|
autoload :Card, "unit/models/card/card"
|
13
13
|
autoload :Statement, "unit/models/statement/statement"
|
14
|
-
|
14
|
+
autoload :AtmLocation, "unit/models/atm_location/atm_location"
|
15
15
|
module Resource
|
16
16
|
autoload :ApplicationResource, "unit/api_resources/application_resource"
|
17
17
|
autoload :CustomerResource, "unit/api_resources/customer_resource"
|
@@ -21,6 +21,7 @@ module Unit
|
|
21
21
|
autoload :TransactionResource, "unit/api_resources/transaction_resource"
|
22
22
|
autoload :CardResource, "unit/api_resources/card_resource"
|
23
23
|
autoload :StatementResource, "unit/api_resources/statement_resource"
|
24
|
+
autoload :AtmLocationResource, "unit/api_resources/atm_location_resource"
|
24
25
|
end
|
25
26
|
|
26
27
|
module Types
|
@@ -37,6 +38,8 @@ module Unit
|
|
37
38
|
autoload :Relationship, "unit/types/relationship"
|
38
39
|
autoload :RelationshipArray, "unit/types/relationship_array"
|
39
40
|
autoload :RestrictedResource, "unit/types/restricted_resource"
|
41
|
+
autoload :DocumentFileType, "unit/types/document_file_type"
|
42
|
+
autoload :Coordinates, "unit/types/coordinates"
|
40
43
|
end
|
41
44
|
|
42
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: 2023-01-
|
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,6 +97,7 @@ 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
|
101
102
|
- lib/unit/api_resources/card_resource.rb
|
102
103
|
- lib/unit/api_resources/customer_resource.rb
|
@@ -124,6 +125,10 @@ files:
|
|
124
125
|
- lib/unit/models/application/list_application_params.rb
|
125
126
|
- lib/unit/models/application/patch_application_request.rb
|
126
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
|
127
132
|
- lib/unit/models/card/card.rb
|
128
133
|
- lib/unit/models/card/create_business_debit_card_request.rb
|
129
134
|
- lib/unit/models/card/create_business_virtual_debit_card_request.rb
|
@@ -156,7 +161,9 @@ files:
|
|
156
161
|
- lib/unit/types/authorized_user.rb
|
157
162
|
- lib/unit/types/beneficial_owner.rb
|
158
163
|
- lib/unit/types/business_contact.rb
|
164
|
+
- lib/unit/types/coordinates.rb
|
159
165
|
- lib/unit/types/device_fingerprint.rb
|
166
|
+
- lib/unit/types/document_file_type.rb
|
160
167
|
- lib/unit/types/evaluation_params.rb
|
161
168
|
- lib/unit/types/full_name.rb
|
162
169
|
- lib/unit/types/officer.rb
|