unit_ruby_sdk 0.1.2 → 0.1.4
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/.rubocop.yml +3 -0
- data/Gemfile +0 -10
- data/README.md +97 -1
- data/lib/unit/api_resources/account_resource.rb +125 -0
- data/lib/unit/api_resources/api_token_resource.rb +59 -0
- data/lib/unit/api_resources/application_resource.rb +9 -9
- data/lib/unit/api_resources/base_resource.rb +3 -11
- data/lib/unit/api_resources/customer_resource.rb +12 -11
- data/lib/unit/api_resources/payment_resource.rb +32 -0
- data/lib/unit/api_resources/transaction_resource.rb +40 -0
- data/lib/unit/errors/unit_error.rb +7 -13
- data/lib/unit/errors/unit_error_payload.rb +15 -2
- data/lib/unit/models/account/account.rb +157 -0
- data/lib/unit/models/account/deposit/account_owners_request.rb +29 -0
- data/lib/unit/models/account/deposit/balance_history_request.rb +39 -0
- data/lib/unit/models/account/deposit/close_deposit_account_request.rb +36 -0
- data/lib/unit/models/account/deposit/create_deposit_account_request.rb +39 -0
- data/lib/unit/models/account/deposit/freeze_account_request.rb +36 -0
- data/lib/unit/models/account/deposit/list_account_params.rb +48 -0
- data/lib/unit/models/account/deposit/patch_deposit_account_request.rb +36 -0
- 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/application.rb +127 -0
- data/lib/unit/models/application/create_business_application_request.rb +7 -7
- data/lib/unit/models/application/create_individual_application_request.rb +14 -14
- data/lib/unit/models/application/list_application_params.rb +4 -4
- data/lib/unit/models/application/patch_application_request.rb +3 -3
- data/lib/unit/models/application/upload_document_request.rb +1 -1
- data/lib/unit/models/customer/add_authorized_users_request.rb +3 -3
- data/lib/unit/models/customer/archive_customer_request.rb +3 -4
- data/lib/unit/models/customer/customer.rb +96 -0
- data/lib/unit/models/customer/list_customer_params.rb +10 -12
- data/lib/unit/models/customer/patch_business_customer_request.rb +8 -8
- data/lib/unit/models/customer/patch_individual_customer_request.rb +9 -10
- data/lib/unit/models/customer/remove_authorized_users_request.rb +3 -3
- 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/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/models/unit_response.rb +7 -1
- data/lib/unit/types/authorized_user.rb +1 -1
- data/lib/unit/types/relationship.rb +4 -5
- data/lib/unit/types/relationship_array.rb +14 -12
- data/lib/unit/types/restricted_resource.rb +23 -0
- data/lib/unit/utils/http_helper.rb +56 -0
- data/lib/unit/version.rb +1 -1
- data/lib/unit_ruby_sdk.rb +22 -21
- metadata +76 -7
- data/Gemfile.lock +0 -133
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Request to get a transaction
|
|
4
|
+
# @see https://docs.unit.co/transactions#get-specific-transaction
|
|
5
|
+
module Unit
|
|
6
|
+
module Transaction
|
|
7
|
+
class GetTransactionParams
|
|
8
|
+
attr_accessor :transaction_id, :account_id, :customer_id, :include
|
|
9
|
+
|
|
10
|
+
# @param transaction_id [String]
|
|
11
|
+
# @param account_id [String]
|
|
12
|
+
# @param customer_id [String] - optional
|
|
13
|
+
# @param include [Array<String>] - optional
|
|
14
|
+
def initialize(transaction_id, account_id, customer_id = nil, include = nil)
|
|
15
|
+
@transaction_id = transaction_id
|
|
16
|
+
@account_id = account_id
|
|
17
|
+
@customer_id = customer_id
|
|
18
|
+
@include = include
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def to_hash
|
|
22
|
+
params = { "filter[customerId]": customer_id,
|
|
23
|
+
"include": include&.join(",") }
|
|
24
|
+
params.compact
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Request to list transactions
|
|
4
|
+
# @see https://docs.unit.co/transactions#list-transactions
|
|
5
|
+
module Unit
|
|
6
|
+
module Transaction
|
|
7
|
+
class ListTransactionParams
|
|
8
|
+
attr_reader :limit, :offset, :account_id, :customer_id, :query, :tags, :since, :_until, :card_id, :type, :from_amount, :to_amount, :direction, :exclude_fees, :sort, :include
|
|
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 query [String] - optional
|
|
15
|
+
# @param tags [String] - optional
|
|
16
|
+
# @param since [String] - optional
|
|
17
|
+
# @param _until [String] - optional
|
|
18
|
+
# @param card_id [String] - optional
|
|
19
|
+
# @param type [Array<String>] - optional
|
|
20
|
+
# @param from_amount [Integer] - optional
|
|
21
|
+
# @param to_amount [Integer] - optional
|
|
22
|
+
# @param direction [String] - optional
|
|
23
|
+
# @param exclude_fees [Boolean] - optional
|
|
24
|
+
# @param sort [String] - optional
|
|
25
|
+
# @param include [Array<String>] - optional
|
|
26
|
+
def initialize(limit = TRANSACTION_LIST_LIMIT, offset = TRANSACTION_LIST_OFFSET, account_id = nil, customer_id = nil,
|
|
27
|
+
query = nil, tags = nil, since = nil, _until = nil, card_id = nil, type = nil, from_amount = nil, to_amount = nil,
|
|
28
|
+
direction = nil, exclude_fees = nil, sort = nil, include = nil)
|
|
29
|
+
@limit = limit
|
|
30
|
+
@offset = offset
|
|
31
|
+
@account_id = account_id
|
|
32
|
+
@customer_id = customer_id
|
|
33
|
+
@query = query
|
|
34
|
+
@tags = tags
|
|
35
|
+
@since = since
|
|
36
|
+
@_until = _until
|
|
37
|
+
@card_id = card_id
|
|
38
|
+
@type = type
|
|
39
|
+
@from_amount = from_amount
|
|
40
|
+
@to_amount = to_amount
|
|
41
|
+
@direction = direction
|
|
42
|
+
@exclude_fees = exclude_fees
|
|
43
|
+
@sort = sort
|
|
44
|
+
@include = include
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def to_hash
|
|
48
|
+
params = { "page[limit]": limit,
|
|
49
|
+
"page[offset]": offset,
|
|
50
|
+
"filter[accountId]": account_id,
|
|
51
|
+
"filter[customerId]": customer_id,
|
|
52
|
+
"filter[query]": query,
|
|
53
|
+
"filter[tags]": tags,
|
|
54
|
+
"filter[since]": since,
|
|
55
|
+
"filter[until]": _until,
|
|
56
|
+
"filter[cardId]": card_id,
|
|
57
|
+
"filter[fromAmount]": from_amount,
|
|
58
|
+
"filter[toAmount]": to_amount,
|
|
59
|
+
"filter[direction]": direction,
|
|
60
|
+
"excludeFees": exclude_fees,
|
|
61
|
+
"sort": sort,
|
|
62
|
+
"include": include&.join(",") }
|
|
63
|
+
type&.each_with_index&.map do |val, index|
|
|
64
|
+
params.merge!({ "filter[type][#{index}]": val })
|
|
65
|
+
end
|
|
66
|
+
params.compact
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Request to update a transaction's tags
|
|
4
|
+
# @see https://docs.unit.co/transactions#update-transaction-tags
|
|
5
|
+
module Unit
|
|
6
|
+
module Transaction
|
|
7
|
+
class PatchTagsRequest
|
|
8
|
+
attr_accessor :account_id, :transaction_id, :tags
|
|
9
|
+
|
|
10
|
+
# @param account_id [String]
|
|
11
|
+
# @param transaction_id [String]
|
|
12
|
+
# @param tags [Hash] - optional
|
|
13
|
+
def initialize(account_id, transaction_id, tags = nil)
|
|
14
|
+
@account_id = account_id
|
|
15
|
+
@transaction_id = transaction_id
|
|
16
|
+
@tags = tags
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def to_json_api
|
|
20
|
+
payload = {
|
|
21
|
+
"data": {
|
|
22
|
+
"type": "transaction",
|
|
23
|
+
"attributes": {
|
|
24
|
+
"tags": tags
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
payload[:data][:attributes].compact!
|
|
29
|
+
payload.to_json
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Unit
|
|
4
|
+
module Transaction
|
|
5
|
+
TRANSACTION_LIST_LIMIT = 100
|
|
6
|
+
TRANSACTION_LIST_OFFSET = 0
|
|
7
|
+
autoload :GetTransactionParams, "unit/models/transaction/get_transaction_params"
|
|
8
|
+
autoload :ListTransactionParams, "unit/models/transaction/list_transaction_params"
|
|
9
|
+
autoload :PatchTagsRequest, "unit/models/transaction/patch_tags_request"
|
|
10
|
+
|
|
11
|
+
class << self
|
|
12
|
+
# Get a transaction by id
|
|
13
|
+
# @see https://docs.unit.co/transactions#get-specific-transaction
|
|
14
|
+
# @param transaction_id [String]
|
|
15
|
+
# @param account_id [String]
|
|
16
|
+
# @param customer_id [String] - optional
|
|
17
|
+
# @param include [Array<String>] - optional
|
|
18
|
+
def get_transaction(transaction_id:, account_id:, customer_id: nil, include: nil)
|
|
19
|
+
params = GetTransactionParams.new(transaction_id, account_id, customer_id, include)
|
|
20
|
+
Unit::Resource::TransactionResource.get_transaction(params)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
# List transactions
|
|
24
|
+
# @see https://docs.unit.co/transactions#list-transactions
|
|
25
|
+
# @param limit [Integer] - optional
|
|
26
|
+
# @param offset [Integer] - optional
|
|
27
|
+
# @param account_id [String] - optional
|
|
28
|
+
# @param query [String] - optional
|
|
29
|
+
# @param tags [String] - optional
|
|
30
|
+
# @param since [String] - optional
|
|
31
|
+
# @param _until [String] - optional
|
|
32
|
+
# @param card_id [String] - optional
|
|
33
|
+
# @param type [Array<String>] - optional
|
|
34
|
+
# @param from_amount [Integer] - optional
|
|
35
|
+
# @param to_amount [Integer] - optional
|
|
36
|
+
# @param direction [String] - optional
|
|
37
|
+
# @param exclude_fees [Boolean] - optional
|
|
38
|
+
# @param sort [String] - optional
|
|
39
|
+
# @param include [Array<String>] - optional
|
|
40
|
+
def list_transactions(limit: nil, offset: nil, account_id: nil, customer_id: nil,
|
|
41
|
+
query: nil, tags: nil, since: nil, _until: nil, card_id: nil, type: nil, from_amount: nil, to_amount: nil,
|
|
42
|
+
direction: nil, exclude_fees: nil, sort: nil, include: nil)
|
|
43
|
+
params = ListTransactionParams.new(limit, offset, account_id, customer_id, query, tags, since,
|
|
44
|
+
_until, card_id, type, from_amount, to_amount,
|
|
45
|
+
direction, exclude_fees, sort, include)
|
|
46
|
+
Unit::Resource::TransactionResource.list_transactions(params)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
# Update transaction tags
|
|
50
|
+
# @see https://docs.unit.co/transactions#update-transaction-tags
|
|
51
|
+
# @param account_id [String]
|
|
52
|
+
# @param transaction_id [String]
|
|
53
|
+
# @param tags [Hash]
|
|
54
|
+
def update_transaction(account_id:, transaction_id:, tags: nil)
|
|
55
|
+
request = PatchTagsRequest.new(account_id, transaction_id, tags)
|
|
56
|
+
Unit::Resource::TransactionResource.update_tags(request)
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
@@ -7,11 +7,17 @@ module Unit
|
|
|
7
7
|
|
|
8
8
|
# @param data [Hash] The JSON API payload
|
|
9
9
|
# @param included [Array] The JSON API payload
|
|
10
|
-
|
|
11
10
|
def initialize(data, included, meta)
|
|
12
11
|
@data = data
|
|
13
12
|
@included = included
|
|
14
13
|
@meta = meta
|
|
15
14
|
end
|
|
15
|
+
|
|
16
|
+
# Creates a new UnitResponse from given response.
|
|
17
|
+
# @param [HTTP::Response] response The response returned from Unit's API
|
|
18
|
+
# @return [UnitResponse] a new UnitResponse populated with values taken from the response
|
|
19
|
+
def self.from_json_api(response)
|
|
20
|
+
new(response.body["data"], response.body["included"], response.body["meta"])
|
|
21
|
+
end
|
|
16
22
|
end
|
|
17
23
|
end
|
|
@@ -8,14 +8,13 @@ module Unit
|
|
|
8
8
|
|
|
9
9
|
# @param id [String] The id of the relationship
|
|
10
10
|
# @param type [String] The type
|
|
11
|
-
def initialize(
|
|
12
|
-
@id = id
|
|
11
|
+
def initialize(type, id)
|
|
13
12
|
@type = type
|
|
13
|
+
@id = id
|
|
14
14
|
end
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
nested ? { "data": { "id": id, "type": type } } : { "id": id, "type": type }
|
|
16
|
+
def to_hash
|
|
17
|
+
{ "data": { "type": type, "id": id } }
|
|
19
18
|
end
|
|
20
19
|
end
|
|
21
20
|
end
|
|
@@ -6,23 +6,25 @@ module Unit
|
|
|
6
6
|
class RelationshipArray
|
|
7
7
|
attr_reader :data
|
|
8
8
|
|
|
9
|
-
# @param array [Array]
|
|
9
|
+
# @param array [Array]
|
|
10
10
|
def initialize(array)
|
|
11
|
-
|
|
12
|
-
array.map do |item|
|
|
13
|
-
relationships << if item.is_a?(Relationship)
|
|
14
|
-
item
|
|
15
|
-
else
|
|
16
|
-
Relationship.new(item[:data][:id], item[:data][:type]).represent
|
|
17
|
-
end
|
|
18
|
-
p item
|
|
19
|
-
end
|
|
20
|
-
@data = relationships
|
|
11
|
+
@data = array
|
|
21
12
|
end
|
|
22
13
|
|
|
23
|
-
def
|
|
14
|
+
def to_hash
|
|
24
15
|
{ "data": data }
|
|
25
16
|
end
|
|
17
|
+
|
|
18
|
+
def self.from_params_array(array)
|
|
19
|
+
@relationships = []
|
|
20
|
+
array.map do |item|
|
|
21
|
+
@relationships << if item.is_a?(Relationship)
|
|
22
|
+
item.to_hash[:data]
|
|
23
|
+
else
|
|
24
|
+
Relationship.new(item[:type], item[:id]).to_hash[:data] end
|
|
25
|
+
end
|
|
26
|
+
RelationshipArray.new(@relationships).to_hash
|
|
27
|
+
end
|
|
26
28
|
end
|
|
27
29
|
end
|
|
28
30
|
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "json"
|
|
4
|
+
module Unit
|
|
5
|
+
module Types
|
|
6
|
+
class RestrictedResource
|
|
7
|
+
attr_reader :ids, :type
|
|
8
|
+
|
|
9
|
+
def initialize(ids, type)
|
|
10
|
+
@ids = ids
|
|
11
|
+
@type = type
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def to_json_api
|
|
15
|
+
result = []
|
|
16
|
+
@ids.each do |id|
|
|
17
|
+
result << { type: type, id: id }
|
|
18
|
+
end
|
|
19
|
+
result
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "uri"
|
|
4
|
+
require "net/http"
|
|
5
|
+
require "json"
|
|
6
|
+
|
|
7
|
+
module HttpHelper
|
|
8
|
+
def self.get(url, headers:, params: nil)
|
|
9
|
+
make_request(Net::HTTP::Get, url, headers, params: params)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def self.post(url, headers:, body: nil)
|
|
13
|
+
make_request(Net::HTTP::Post, url, headers, body: body)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def self.put(url, body:, headers:)
|
|
17
|
+
make_request(Net::HTTP::Put, url, headers, body: body)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def self.patch(url, body:, headers:)
|
|
21
|
+
make_request(Net::HTTP::Patch, url, headers, body: body)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def self.delete(url, headers:, body: nil)
|
|
25
|
+
make_request(Net::HTTP::Delete, url, headers, body: body)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def self.make_request(net_http, url, headers, body: nil, params: nil)
|
|
29
|
+
uri = params.nil? ? URI(url) : URI("#{url}?#{encode(params)}")
|
|
30
|
+
host = uri.host.to_s
|
|
31
|
+
port = uri.port
|
|
32
|
+
options = { use_ssl: uri.scheme == "https" }
|
|
33
|
+
|
|
34
|
+
Net::HTTP.start(host, port, options) do |http|
|
|
35
|
+
request = net_http.new uri, headers
|
|
36
|
+
request.body = body unless body.nil?
|
|
37
|
+
response = http.request request
|
|
38
|
+
response.body = JSON.parse(response.body)
|
|
39
|
+
response
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def self.encode(value, key = nil)
|
|
44
|
+
case value
|
|
45
|
+
when Hash then value.map { |k, v| encode(v, append_key(key, k)) }.join("&")
|
|
46
|
+
when Array then value.map { |v| encode(v, "#{key}[]") }.join("&")
|
|
47
|
+
when nil then ""
|
|
48
|
+
else
|
|
49
|
+
"#{key}=#{CGI.escape(value.to_s)}"
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def self.append_key(root_key, key)
|
|
54
|
+
root_key.nil? ? key : "#{root_key}[#{key}]"
|
|
55
|
+
end
|
|
56
|
+
end
|
data/lib/unit/version.rb
CHANGED
data/lib/unit_ruby_sdk.rb
CHANGED
|
@@ -3,26 +3,20 @@
|
|
|
3
3
|
require_relative "unit/version"
|
|
4
4
|
|
|
5
5
|
module Unit
|
|
6
|
+
autoload :Application, "unit/models/application/application"
|
|
7
|
+
autoload :Customer, "unit/models/customer/customer"
|
|
8
|
+
autoload :Account, "unit/models/account/account"
|
|
9
|
+
autoload :ApiToken, "unit/models/api_token/api_token"
|
|
10
|
+
autoload :Payment, "unit/models/payment/payment"
|
|
11
|
+
autoload :Transaction, "unit/models/transaction/transaction"
|
|
12
|
+
|
|
6
13
|
module Resource
|
|
7
14
|
autoload :ApplicationResource, "unit/api_resources/application_resource"
|
|
8
15
|
autoload :CustomerResource, "unit/api_resources/customer_resource"
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
autoload :
|
|
13
|
-
autoload :CreateIndividualApplicationRequest, "unit/models/application/create_individual_application_request"
|
|
14
|
-
autoload :ListApplicationParams, "unit/models/application/list_application_params"
|
|
15
|
-
autoload :PatchApplicationRequest, "unit/models/application/patch_application_request"
|
|
16
|
-
autoload :UploadDocumentRequest, "unit/models/application/upload_document_request"
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
module Customer
|
|
20
|
-
autoload :AddAuthorizedUsersRequest, "unit/models/customer/add_authorized_users_request"
|
|
21
|
-
autoload :ArchiveCustomerRequest, "unit/models/customer/archive_customer_request"
|
|
22
|
-
autoload :ListCustomerParams, "unit/models/customer/list_customer_params"
|
|
23
|
-
autoload :PatchBusinessCustomerRequest, "unit/models/customer/patch_business_customer_request"
|
|
24
|
-
autoload :PatchIndividualCustomerRequest, "unit/models/customer/patch_individual_customer_request"
|
|
25
|
-
autoload :RemoveAuthorizedUsersRequest, "unit/models/customer/remove_authorized_users_request"
|
|
16
|
+
autoload :AccountResource, "unit/api_resources/account_resource"
|
|
17
|
+
autoload :ApiTokenResource, "unit/api_resources/api_token_resource"
|
|
18
|
+
autoload :PaymentResource, "unit/api_resources/payment_resource"
|
|
19
|
+
autoload :TransactionResource, "unit/api_resources/transaction_resource"
|
|
26
20
|
end
|
|
27
21
|
|
|
28
22
|
module Types
|
|
@@ -38,6 +32,7 @@ module Unit
|
|
|
38
32
|
autoload :PowerOfAttorneyAgent, "unit/types/power_of_attorney_agent"
|
|
39
33
|
autoload :Relationship, "unit/types/relationship"
|
|
40
34
|
autoload :RelationshipArray, "unit/types/relationship_array"
|
|
35
|
+
autoload :RestrictedResource, "unit/types/restricted_resource"
|
|
41
36
|
end
|
|
42
37
|
|
|
43
38
|
autoload :UnitErrorPayload, "unit/errors/unit_error_payload"
|
|
@@ -46,9 +41,15 @@ module Unit
|
|
|
46
41
|
autoload :UnitResource, "unit/models/unit_resource"
|
|
47
42
|
|
|
48
43
|
# Configure Unit SDK - acts both as a setter and a getter
|
|
49
|
-
#
|
|
50
|
-
# @
|
|
51
|
-
|
|
52
|
-
|
|
44
|
+
# If params are passed, updates config
|
|
45
|
+
# @param [String] api_url
|
|
46
|
+
# @param [String] token
|
|
47
|
+
# @return [Hash] current (updated) config
|
|
48
|
+
def self.config(api_url: nil, token: nil)
|
|
49
|
+
@@config ||= {}
|
|
50
|
+
@@config[:api_url] = api_url if api_url
|
|
51
|
+
@@config[:token] = token if token
|
|
52
|
+
|
|
53
|
+
@@config
|
|
53
54
|
end
|
|
54
55
|
end
|
metadata
CHANGED
|
@@ -1,15 +1,43 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: unit_ruby_sdk
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Unit
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2022-12-
|
|
11
|
+
date: 2022-12-22 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: factory_bot_rails
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: 6.2.0
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: 6.2.0
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: rake
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '13.0'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '13.0'
|
|
13
41
|
- !ruby/object:Gem::Dependency
|
|
14
42
|
name: rspec
|
|
15
43
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -25,19 +53,33 @@ dependencies:
|
|
|
25
53
|
- !ruby/object:Gem::Version
|
|
26
54
|
version: '0'
|
|
27
55
|
- !ruby/object:Gem::Dependency
|
|
28
|
-
name:
|
|
56
|
+
name: rubocop
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - "~>"
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '1.21'
|
|
62
|
+
type: :development
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - "~>"
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '1.21'
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: ruby-debug-ide
|
|
29
71
|
requirement: !ruby/object:Gem::Requirement
|
|
30
72
|
requirements:
|
|
31
73
|
- - ">="
|
|
32
74
|
- !ruby/object:Gem::Version
|
|
33
|
-
version: 0
|
|
34
|
-
type: :
|
|
75
|
+
version: '0'
|
|
76
|
+
type: :development
|
|
35
77
|
prerelease: false
|
|
36
78
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
79
|
requirements:
|
|
38
80
|
- - ">="
|
|
39
81
|
- !ruby/object:Gem::Version
|
|
40
|
-
version: 0
|
|
82
|
+
version: '0'
|
|
41
83
|
description: This library provides a Ruby wrapper to http://unit.co API. See https://docs.unit.co/
|
|
42
84
|
email:
|
|
43
85
|
- engineering@unit.co
|
|
@@ -49,15 +91,32 @@ files:
|
|
|
49
91
|
- ".rubocop.yml"
|
|
50
92
|
- CHANGELOG.md
|
|
51
93
|
- Gemfile
|
|
52
|
-
- Gemfile.lock
|
|
53
94
|
- LICENSE.txt
|
|
54
95
|
- README.md
|
|
55
96
|
- Rakefile
|
|
97
|
+
- lib/unit/api_resources/account_resource.rb
|
|
98
|
+
- lib/unit/api_resources/api_token_resource.rb
|
|
56
99
|
- lib/unit/api_resources/application_resource.rb
|
|
57
100
|
- lib/unit/api_resources/base_resource.rb
|
|
58
101
|
- lib/unit/api_resources/customer_resource.rb
|
|
102
|
+
- lib/unit/api_resources/payment_resource.rb
|
|
103
|
+
- lib/unit/api_resources/transaction_resource.rb
|
|
59
104
|
- lib/unit/errors/unit_error.rb
|
|
60
105
|
- lib/unit/errors/unit_error_payload.rb
|
|
106
|
+
- lib/unit/models/account/account.rb
|
|
107
|
+
- lib/unit/models/account/deposit/account_owners_request.rb
|
|
108
|
+
- lib/unit/models/account/deposit/balance_history_request.rb
|
|
109
|
+
- lib/unit/models/account/deposit/close_deposit_account_request.rb
|
|
110
|
+
- lib/unit/models/account/deposit/create_deposit_account_request.rb
|
|
111
|
+
- lib/unit/models/account/deposit/freeze_account_request.rb
|
|
112
|
+
- lib/unit/models/account/deposit/list_account_params.rb
|
|
113
|
+
- lib/unit/models/account/deposit/patch_deposit_account_request.rb
|
|
114
|
+
- lib/unit/models/api_token/api_token.rb
|
|
115
|
+
- lib/unit/models/api_token/customer/create_customer_token_request.rb
|
|
116
|
+
- lib/unit/models/api_token/customer/create_customer_token_verification.rb
|
|
117
|
+
- lib/unit/models/api_token/customer/create_token_using_jwt_request.rb
|
|
118
|
+
- lib/unit/models/api_token/org/create_api_token_request.rb
|
|
119
|
+
- lib/unit/models/application/application.rb
|
|
61
120
|
- lib/unit/models/application/create_business_application_request.rb
|
|
62
121
|
- lib/unit/models/application/create_individual_application_request.rb
|
|
63
122
|
- lib/unit/models/application/list_application_params.rb
|
|
@@ -65,10 +124,18 @@ files:
|
|
|
65
124
|
- lib/unit/models/application/upload_document_request.rb
|
|
66
125
|
- lib/unit/models/customer/add_authorized_users_request.rb
|
|
67
126
|
- lib/unit/models/customer/archive_customer_request.rb
|
|
127
|
+
- lib/unit/models/customer/customer.rb
|
|
68
128
|
- lib/unit/models/customer/list_customer_params.rb
|
|
69
129
|
- lib/unit/models/customer/patch_business_customer_request.rb
|
|
70
130
|
- lib/unit/models/customer/patch_individual_customer_request.rb
|
|
71
131
|
- lib/unit/models/customer/remove_authorized_users_request.rb
|
|
132
|
+
- lib/unit/models/payment/create_book_payment_request.rb
|
|
133
|
+
- lib/unit/models/payment/patch_book_payment_request.rb
|
|
134
|
+
- lib/unit/models/payment/payment.rb
|
|
135
|
+
- lib/unit/models/transaction/get_transaction_params.rb
|
|
136
|
+
- lib/unit/models/transaction/list_transaction_params.rb
|
|
137
|
+
- lib/unit/models/transaction/patch_tags_request.rb
|
|
138
|
+
- lib/unit/models/transaction/transaction.rb
|
|
72
139
|
- lib/unit/models/unit_resource.rb
|
|
73
140
|
- lib/unit/models/unit_response.rb
|
|
74
141
|
- lib/unit/types/address.rb
|
|
@@ -83,6 +150,8 @@ files:
|
|
|
83
150
|
- lib/unit/types/power_of_attorney_agent.rb
|
|
84
151
|
- lib/unit/types/relationship.rb
|
|
85
152
|
- lib/unit/types/relationship_array.rb
|
|
153
|
+
- lib/unit/types/restricted_resource.rb
|
|
154
|
+
- lib/unit/utils/http_helper.rb
|
|
86
155
|
- lib/unit/version.rb
|
|
87
156
|
- lib/unit_ruby_sdk.rb
|
|
88
157
|
homepage: https://github.com/unit-finance/unit-ruby-sdk
|