transferzero-sdk 1.5.0 → 1.6.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 +7 -5
- data/docs/Document.md +1 -3
- data/docs/DocumentsApi.md +2 -74
- data/docs/PayinMethodDetails.md +3 -1
- data/docs/PayinMethodDetailsBTC.md +17 -0
- data/docs/PayoutMethodDetails.md +5 -1
- data/docs/PayoutMethodDetailsBTC.md +23 -0
- data/docs/PoliticallyExposedPerson.md +31 -0
- data/docs/Sender.md +62 -32
- data/docs/Transaction.md +3 -3
- data/lib/transferzero-sdk.rb +3 -0
- data/lib/transferzero-sdk/api/documents_api.rb +0 -63
- data/lib/transferzero-sdk/api_client.rb +1 -1
- data/lib/transferzero-sdk/models/document.rb +1 -10
- data/lib/transferzero-sdk/models/payin_method_details.rb +15 -4
- data/lib/transferzero-sdk/models/payin_method_details_btc.rb +203 -0
- data/lib/transferzero-sdk/models/payout_method_details.rb +33 -4
- data/lib/transferzero-sdk/models/payout_method_details_btc.rb +249 -0
- data/lib/transferzero-sdk/models/politically_exposed_person.rb +271 -0
- data/lib/transferzero-sdk/models/sender.rb +288 -124
- data/lib/transferzero-sdk/models/sender_state.rb +1 -1
- data/lib/transferzero-sdk/version.rb +1 -1
- data/spec/models/payin_method_details_btc_spec.rb +41 -0
- data/spec/models/payout_method_details_btc_spec.rb +59 -0
- data/spec/models/politically_exposed_person_spec.rb +83 -0
- metadata +15 -4
- data/transferzero-sdk-1.4.0.gem +0 -0
data/docs/Transaction.md
CHANGED
@@ -33,10 +33,10 @@ instance = TransferZero::Transaction.new(input_currency: NGN,
|
|
33
33
|
recipients: null,
|
34
34
|
traits: null,
|
35
35
|
state: null,
|
36
|
-
input_amount:
|
36
|
+
input_amount: 1000,
|
37
37
|
payin_reference: null,
|
38
|
-
paid_amount:
|
39
|
-
due_amount:
|
38
|
+
paid_amount: 1000,
|
39
|
+
due_amount: 1000,
|
40
40
|
created_at: null,
|
41
41
|
expires_at: null,
|
42
42
|
external_id: 806ec63a-a5a7-43cc-9d75-1ee74fbcc026,
|
data/lib/transferzero-sdk.rb
CHANGED
@@ -52,6 +52,7 @@ require 'transferzero-sdk/models/pagination'
|
|
52
52
|
require 'transferzero-sdk/models/pagination_meta'
|
53
53
|
require 'transferzero-sdk/models/payin_method'
|
54
54
|
require 'transferzero-sdk/models/payin_method_details'
|
55
|
+
require 'transferzero-sdk/models/payin_method_details_btc'
|
55
56
|
require 'transferzero-sdk/models/payin_method_details_mobile'
|
56
57
|
require 'transferzero-sdk/models/payin_method_details_ngn_bank'
|
57
58
|
require 'transferzero-sdk/models/payin_method_request'
|
@@ -61,6 +62,7 @@ require 'transferzero-sdk/models/payment_method_opposite'
|
|
61
62
|
require 'transferzero-sdk/models/payout_method'
|
62
63
|
require 'transferzero-sdk/models/payout_method_bank_account_type_enum'
|
63
64
|
require 'transferzero-sdk/models/payout_method_details'
|
65
|
+
require 'transferzero-sdk/models/payout_method_details_btc'
|
64
66
|
require 'transferzero-sdk/models/payout_method_details_balance'
|
65
67
|
require 'transferzero-sdk/models/payout_method_details_ghs_bank'
|
66
68
|
require 'transferzero-sdk/models/payout_method_details_iban'
|
@@ -76,6 +78,7 @@ require 'transferzero-sdk/models/payout_method_mobile_provider_enum'
|
|
76
78
|
require 'transferzero-sdk/models/payout_method_request'
|
77
79
|
require 'transferzero-sdk/models/payout_method_response'
|
78
80
|
require 'transferzero-sdk/models/payout_method_webhook'
|
81
|
+
require 'transferzero-sdk/models/politically_exposed_person'
|
79
82
|
require 'transferzero-sdk/models/recipient'
|
80
83
|
require 'transferzero-sdk/models/recipient_list_response'
|
81
84
|
require 'transferzero-sdk/models/recipient_request'
|
@@ -21,68 +21,10 @@ module TransferZero
|
|
21
21
|
end
|
22
22
|
|
23
23
|
|
24
|
-
# Deleting a document
|
25
|
-
# Deletes a single document by the Document ID
|
26
|
-
# @param document_id ID of the document to delete. Example: `/v1/document/bf9ff782-e182-45ac-abea-5bce83ad6670`
|
27
|
-
# @param [Hash] opts the optional parameters
|
28
|
-
# @option opts [String] :sender_id Allows filtering results by `sender_id`. Example: `/v1/transactions?sender_id=b41d3cb7-6c54-4245-85fc-8e30690eb0f7`
|
29
|
-
# @return [DocumentResponse]
|
30
|
-
def delete_document(document_id, opts = {})
|
31
|
-
data, _status_code, _headers = delete_document_with_http_info(document_id, opts)
|
32
|
-
data
|
33
|
-
end
|
34
|
-
|
35
|
-
# Deleting a document
|
36
|
-
# Deletes a single document by the Document ID
|
37
|
-
# @param document_id ID of the document to delete. Example: `/v1/document/bf9ff782-e182-45ac-abea-5bce83ad6670`
|
38
|
-
# @param [Hash] opts the optional parameters
|
39
|
-
# @option opts [String] :sender_id Allows filtering results by `sender_id`. Example: `/v1/transactions?sender_id=b41d3cb7-6c54-4245-85fc-8e30690eb0f7`
|
40
|
-
# @return [Array<(DocumentResponse, Fixnum, Hash)>] DocumentResponse data, response status code and response headers
|
41
|
-
def delete_document_with_http_info(document_id, opts = {})
|
42
|
-
if @api_client.config.debugging
|
43
|
-
@api_client.config.logger.debug 'Calling API: DocumentsApi.delete_document ...'
|
44
|
-
end
|
45
|
-
# verify the required parameter 'document_id' is set
|
46
|
-
if @api_client.config.client_side_validation && document_id.nil?
|
47
|
-
fail ArgumentError, "Missing the required parameter 'document_id' when calling DocumentsApi.delete_document"
|
48
|
-
end
|
49
|
-
# resource path
|
50
|
-
local_var_path = '/documents/{Document ID}'.sub('{' + 'Document ID' + '}', document_id.to_s)
|
51
|
-
|
52
|
-
# query parameters
|
53
|
-
query_params = {}
|
54
|
-
query_params[:'sender_id'] = opts[:'sender_id'] if !opts[:'sender_id'].nil?
|
55
|
-
|
56
|
-
# header parameters
|
57
|
-
header_params = {}
|
58
|
-
# HTTP header 'Accept' (if needed)
|
59
|
-
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
|
60
|
-
|
61
|
-
# form parameters
|
62
|
-
form_params = {}
|
63
|
-
|
64
|
-
# http body (model)
|
65
|
-
post_body = nil
|
66
|
-
auth_names = ['AuthorizationKey', 'AuthorizationNonce', 'AuthorizationSecret', 'AuthorizationSignature']
|
67
|
-
data, status_code, headers = @api_client.call_api(:DELETE, local_var_path,
|
68
|
-
:header_params => header_params,
|
69
|
-
:query_params => query_params,
|
70
|
-
:form_params => form_params,
|
71
|
-
:body => post_body,
|
72
|
-
:auth_names => auth_names,
|
73
|
-
:return_type => 'DocumentResponse')
|
74
|
-
if @api_client.config.debugging
|
75
|
-
@api_client.config.logger.debug "API called: DocumentsApi#delete_document\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
76
|
-
end
|
77
|
-
return data, status_code, headers
|
78
|
-
end
|
79
|
-
|
80
|
-
|
81
24
|
# Fetching a document
|
82
25
|
# Returns a single document by the Documents ID
|
83
26
|
# @param document_id ID of the document to get. Example: `/v1/documents/bf9ff782-e182-45ac-abea-5bce83ad6670`
|
84
27
|
# @param [Hash] opts the optional parameters
|
85
|
-
# @option opts [String] :sender_id Allows filtering results by `sender_id`. Example: `/v1/transactions?sender_id=b41d3cb7-6c54-4245-85fc-8e30690eb0f7`
|
86
28
|
# @return [DocumentResponse]
|
87
29
|
def get_document(document_id, opts = {})
|
88
30
|
data, _status_code, _headers = get_document_with_http_info(document_id, opts)
|
@@ -93,7 +35,6 @@ module TransferZero
|
|
93
35
|
# Returns a single document by the Documents ID
|
94
36
|
# @param document_id ID of the document to get. Example: `/v1/documents/bf9ff782-e182-45ac-abea-5bce83ad6670`
|
95
37
|
# @param [Hash] opts the optional parameters
|
96
|
-
# @option opts [String] :sender_id Allows filtering results by `sender_id`. Example: `/v1/transactions?sender_id=b41d3cb7-6c54-4245-85fc-8e30690eb0f7`
|
97
38
|
# @return [Array<(DocumentResponse, Fixnum, Hash)>] DocumentResponse data, response status code and response headers
|
98
39
|
def get_document_with_http_info(document_id, opts = {})
|
99
40
|
if @api_client.config.debugging
|
@@ -108,7 +49,6 @@ module TransferZero
|
|
108
49
|
|
109
50
|
# query parameters
|
110
51
|
query_params = {}
|
111
|
-
query_params[:'sender_id'] = opts[:'sender_id'] if !opts[:'sender_id'].nil?
|
112
52
|
|
113
53
|
# header parameters
|
114
54
|
header_params = {}
|
@@ -150,7 +90,6 @@ module TransferZero
|
|
150
90
|
# @param [Hash] opts the optional parameters
|
151
91
|
# @option opts [Integer] :page The page number to request (defaults to 1)
|
152
92
|
# @option opts [Integer] :per The number of results to load per page (defaults to 10)
|
153
|
-
# @option opts [String] :sender_id Allows filtering results by `sender_id`. Example: `/v1/transactions?sender_id=b41d3cb7-6c54-4245-85fc-8e30690eb0f7`
|
154
93
|
# @return [DocumentListResponse]
|
155
94
|
def get_documents(opts = {})
|
156
95
|
data, _status_code, _headers = get_documents_with_http_info(opts)
|
@@ -162,7 +101,6 @@ module TransferZero
|
|
162
101
|
# @param [Hash] opts the optional parameters
|
163
102
|
# @option opts [Integer] :page The page number to request (defaults to 1)
|
164
103
|
# @option opts [Integer] :per The number of results to load per page (defaults to 10)
|
165
|
-
# @option opts [String] :sender_id Allows filtering results by `sender_id`. Example: `/v1/transactions?sender_id=b41d3cb7-6c54-4245-85fc-8e30690eb0f7`
|
166
104
|
# @return [Array<(DocumentListResponse, Fixnum, Hash)>] DocumentListResponse data, response status code and response headers
|
167
105
|
def get_documents_with_http_info(opts = {})
|
168
106
|
if @api_client.config.debugging
|
@@ -175,7 +113,6 @@ module TransferZero
|
|
175
113
|
query_params = {}
|
176
114
|
query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?
|
177
115
|
query_params[:'per'] = opts[:'per'] if !opts[:'per'].nil?
|
178
|
-
query_params[:'sender_id'] = opts[:'sender_id'] if !opts[:'sender_id'].nil?
|
179
116
|
|
180
117
|
# header parameters
|
181
118
|
header_params = {}
|
@@ -35,7 +35,7 @@ module TransferZero
|
|
35
35
|
# @option config [Configuration] Configuration for initializing the object, default to Configuration.default
|
36
36
|
def initialize(config = Configuration.default)
|
37
37
|
@config = config
|
38
|
-
@user_agent = "TransferZero-SDK/Ruby/1.
|
38
|
+
@user_agent = "TransferZero-SDK/Ruby/1.6.0"
|
39
39
|
@default_headers = {
|
40
40
|
'Content-Type' => 'application/json',
|
41
41
|
'User-Agent' => @user_agent
|
@@ -14,8 +14,6 @@ require 'date'
|
|
14
14
|
|
15
15
|
module TransferZero
|
16
16
|
class Document
|
17
|
-
attr_accessor :sender_id
|
18
|
-
|
19
17
|
# Base64 encoded data uri of an image/pdf file or a fully qualified url
|
20
18
|
attr_accessor :upload
|
21
19
|
|
@@ -71,7 +69,6 @@ module TransferZero
|
|
71
69
|
# Attribute mapping from ruby-style variable name to JSON key.
|
72
70
|
def self.attribute_map
|
73
71
|
{
|
74
|
-
:'sender_id' => :'sender_id',
|
75
72
|
:'upload' => :'upload',
|
76
73
|
:'upload_file_name' => :'upload_file_name',
|
77
74
|
:'metadata' => :'metadata',
|
@@ -89,7 +86,6 @@ module TransferZero
|
|
89
86
|
# Attribute type mapping.
|
90
87
|
def self.openapi_types
|
91
88
|
{
|
92
|
-
:'sender_id' => :'String',
|
93
89
|
:'upload' => :'String',
|
94
90
|
:'upload_file_name' => :'String',
|
95
91
|
:'metadata' => :'Object',
|
@@ -119,10 +115,6 @@ module TransferZero
|
|
119
115
|
h[k.to_sym] = v
|
120
116
|
}
|
121
117
|
|
122
|
-
if attributes.key?(:'sender_id')
|
123
|
-
self.sender_id = attributes[:'sender_id']
|
124
|
-
end
|
125
|
-
|
126
118
|
if attributes.key?(:'upload')
|
127
119
|
self.upload = attributes[:'upload']
|
128
120
|
end
|
@@ -210,7 +202,6 @@ module TransferZero
|
|
210
202
|
def ==(o)
|
211
203
|
return true if self.equal?(o)
|
212
204
|
self.class == o.class &&
|
213
|
-
sender_id == o.sender_id &&
|
214
205
|
upload == o.upload &&
|
215
206
|
upload_file_name == o.upload_file_name &&
|
216
207
|
metadata == o.metadata &&
|
@@ -233,7 +224,7 @@ module TransferZero
|
|
233
224
|
# Calculates hash code according to all attributes.
|
234
225
|
# @return [Integer] Hash code
|
235
226
|
def hash
|
236
|
-
[
|
227
|
+
[upload, upload_file_name, metadata, upload_content_type, upload_file_size, category, side, document_type, issuing_country, id, errors].hash
|
237
228
|
end
|
238
229
|
|
239
230
|
require 'active_support/core_ext/hash'
|
@@ -27,13 +27,17 @@ module TransferZero
|
|
27
27
|
# States whether to send out the instructions to the phone number on how to pay the funds or not. This shuold always be set to true, otherwise the sender might not receive a prompt for payment.
|
28
28
|
attr_accessor :send_instructions
|
29
29
|
|
30
|
+
# Please make sure the refund_address is a valid BTC address belonging to the sender, as that is going to be used in case the transaction has to be refunded.
|
31
|
+
attr_accessor :refund_address
|
32
|
+
|
30
33
|
# Attribute mapping from ruby-style variable name to JSON key.
|
31
34
|
def self.attribute_map
|
32
35
|
{
|
33
36
|
:'payment_method' => :'payment_method',
|
34
37
|
:'redirect_url' => :'redirect_url',
|
35
38
|
:'phone_number' => :'phone_number',
|
36
|
-
:'send_instructions' => :'send_instructions'
|
39
|
+
:'send_instructions' => :'send_instructions',
|
40
|
+
:'refund_address' => :'refund_address'
|
37
41
|
}
|
38
42
|
end
|
39
43
|
|
@@ -43,13 +47,15 @@ module TransferZero
|
|
43
47
|
:'payment_method' => :'String',
|
44
48
|
:'redirect_url' => :'String',
|
45
49
|
:'phone_number' => :'String',
|
46
|
-
:'send_instructions' => :'Boolean'
|
50
|
+
:'send_instructions' => :'Boolean',
|
51
|
+
:'refund_address' => :'String'
|
47
52
|
}
|
48
53
|
end
|
49
54
|
|
50
55
|
# List of class defined in oneOf (OpenAPI v3)
|
51
56
|
def self.openapi_one_of
|
52
57
|
[
|
58
|
+
:'PayinMethodDetailsBTC',
|
53
59
|
:'PayinMethodDetailsMobile',
|
54
60
|
:'PayinMethodDetailsNGNBank'
|
55
61
|
]
|
@@ -85,6 +91,10 @@ module TransferZero
|
|
85
91
|
if attributes.key?(:'send_instructions')
|
86
92
|
self.send_instructions = attributes[:'send_instructions']
|
87
93
|
end
|
94
|
+
|
95
|
+
if attributes.key?(:'refund_address')
|
96
|
+
self.refund_address = attributes[:'refund_address']
|
97
|
+
end
|
88
98
|
end
|
89
99
|
|
90
100
|
# Show invalid properties with the reasons. Usually used together with valid?
|
@@ -129,7 +139,8 @@ module TransferZero
|
|
129
139
|
payment_method == o.payment_method &&
|
130
140
|
redirect_url == o.redirect_url &&
|
131
141
|
phone_number == o.phone_number &&
|
132
|
-
send_instructions == o.send_instructions
|
142
|
+
send_instructions == o.send_instructions &&
|
143
|
+
refund_address == o.refund_address
|
133
144
|
end
|
134
145
|
|
135
146
|
# @see the `==` method
|
@@ -141,7 +152,7 @@ module TransferZero
|
|
141
152
|
# Calculates hash code according to all attributes.
|
142
153
|
# @return [Integer] Hash code
|
143
154
|
def hash
|
144
|
-
[payment_method, redirect_url, phone_number, send_instructions].hash
|
155
|
+
[payment_method, redirect_url, phone_number, send_instructions, refund_address].hash
|
145
156
|
end
|
146
157
|
|
147
158
|
require 'active_support/core_ext/hash'
|
@@ -0,0 +1,203 @@
|
|
1
|
+
=begin
|
2
|
+
#TransferZero API
|
3
|
+
|
4
|
+
#Reference documentation for the TransferZero API V1
|
5
|
+
|
6
|
+
OpenAPI spec version: 1.0
|
7
|
+
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
OpenAPI Generator version: 4.0.0-beta3
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
|
15
|
+
module TransferZero
|
16
|
+
# ```JSON \"details\": { \"refund_address\": \"n4VQ5YdHf7hLQ2gWQYYrcxoE5B7nWuDFNF\" } ```
|
17
|
+
class PayinMethodDetailsBTC
|
18
|
+
# Please make sure the refund_address is a valid BTC address belonging to the sender, as that is going to be used in case the transaction has to be refunded.
|
19
|
+
attr_accessor :refund_address
|
20
|
+
|
21
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
22
|
+
def self.attribute_map
|
23
|
+
{
|
24
|
+
:'refund_address' => :'refund_address'
|
25
|
+
}
|
26
|
+
end
|
27
|
+
|
28
|
+
# Attribute type mapping.
|
29
|
+
def self.openapi_types
|
30
|
+
{
|
31
|
+
:'refund_address' => :'String'
|
32
|
+
}
|
33
|
+
end
|
34
|
+
|
35
|
+
# Initializes the object
|
36
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
37
|
+
def initialize(attributes = {})
|
38
|
+
if (!attributes.is_a?(Hash))
|
39
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `TransferZero::PayinMethodDetailsBTC` initialize method"
|
40
|
+
end
|
41
|
+
|
42
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
43
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
44
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
45
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `TransferZero::PayinMethodDetailsBTC`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
46
|
+
end
|
47
|
+
h[k.to_sym] = v
|
48
|
+
}
|
49
|
+
|
50
|
+
if attributes.key?(:'refund_address')
|
51
|
+
self.refund_address = attributes[:'refund_address']
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
56
|
+
# @return Array for valid properties with the reasons
|
57
|
+
def list_invalid_properties
|
58
|
+
invalid_properties = Array.new
|
59
|
+
invalid_properties
|
60
|
+
end
|
61
|
+
|
62
|
+
# Check to see if the all the properties in the model are valid
|
63
|
+
# @return true if the model is valid
|
64
|
+
def valid?
|
65
|
+
true
|
66
|
+
end
|
67
|
+
|
68
|
+
# Checks equality by comparing each attribute.
|
69
|
+
# @param [Object] Object to be compared
|
70
|
+
def ==(o)
|
71
|
+
return true if self.equal?(o)
|
72
|
+
self.class == o.class &&
|
73
|
+
refund_address == o.refund_address
|
74
|
+
end
|
75
|
+
|
76
|
+
# @see the `==` method
|
77
|
+
# @param [Object] Object to be compared
|
78
|
+
def eql?(o)
|
79
|
+
self == o
|
80
|
+
end
|
81
|
+
|
82
|
+
# Calculates hash code according to all attributes.
|
83
|
+
# @return [Integer] Hash code
|
84
|
+
def hash
|
85
|
+
[refund_address].hash
|
86
|
+
end
|
87
|
+
|
88
|
+
require 'active_support/core_ext/hash'
|
89
|
+
require 'active_support/hash_with_indifferent_access.rb'
|
90
|
+
# Builds the object from hash
|
91
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
92
|
+
# @return [Object] Returns the model itself
|
93
|
+
def build_from_hash(attributes)
|
94
|
+
return nil unless attributes.is_a?(Hash)
|
95
|
+
self.class.openapi_types.each_pair do |key, type|
|
96
|
+
if type =~ /\AArray<(.*)>/i
|
97
|
+
# check to ensure the input is an array given that the the attribute
|
98
|
+
# is documented as an array but the input is not
|
99
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
100
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
101
|
+
end
|
102
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
103
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
104
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
105
|
+
end
|
106
|
+
|
107
|
+
self
|
108
|
+
end
|
109
|
+
|
110
|
+
# Deserializes the data based on type
|
111
|
+
# @param string type Data type
|
112
|
+
# @param string value Value to be deserialized
|
113
|
+
# @return [Object] Deserialized data
|
114
|
+
def _deserialize(type, value)
|
115
|
+
case type.to_sym
|
116
|
+
when :DateTime
|
117
|
+
DateTime.parse(value)
|
118
|
+
when :Date
|
119
|
+
Date.parse(value)
|
120
|
+
when :String
|
121
|
+
value.to_s
|
122
|
+
when :Integer
|
123
|
+
value.to_i
|
124
|
+
when :Float
|
125
|
+
value.to_f
|
126
|
+
when :Boolean
|
127
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
128
|
+
true
|
129
|
+
else
|
130
|
+
false
|
131
|
+
end
|
132
|
+
when :Object
|
133
|
+
# generic object (usually a Hash), return directly
|
134
|
+
value
|
135
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
136
|
+
inner_type = Regexp.last_match[:inner_type]
|
137
|
+
value.map { |v| _deserialize(inner_type, v) }
|
138
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
139
|
+
k_type = Regexp.last_match[:k_type]
|
140
|
+
v_type = Regexp.last_match[:v_type]
|
141
|
+
{}.tap do |hash|
|
142
|
+
value.each do |k, v|
|
143
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
144
|
+
end
|
145
|
+
end
|
146
|
+
else # model
|
147
|
+
temp_model = TransferZero.const_get(type).new
|
148
|
+
temp_model.build_from_hash(value)
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
# Returns the string representation of the object
|
153
|
+
# @return [String] String presentation of the object
|
154
|
+
def to_s
|
155
|
+
to_hash.to_s
|
156
|
+
end
|
157
|
+
|
158
|
+
# to_body is an alias to to_hash (backward compatibility)
|
159
|
+
# @return [Hash] Returns the object in the form of hash
|
160
|
+
def to_body
|
161
|
+
to_hash
|
162
|
+
end
|
163
|
+
|
164
|
+
# Returns the object in the form of hash
|
165
|
+
# @return [Hash] Returns the object in the form of hash
|
166
|
+
def to_hash
|
167
|
+
hash = {}
|
168
|
+
self.class.attribute_map.each_pair do |attr, param|
|
169
|
+
value = self.send(attr)
|
170
|
+
next if value.nil?
|
171
|
+
hash[param] = _to_hash(value)
|
172
|
+
end
|
173
|
+
::ActiveSupport::HashWithIndifferentAccess.new(hash)
|
174
|
+
end
|
175
|
+
|
176
|
+
def [](key)
|
177
|
+
to_hash[key]
|
178
|
+
end
|
179
|
+
|
180
|
+
def dig(*args)
|
181
|
+
to_hash.dig(*args)
|
182
|
+
end
|
183
|
+
|
184
|
+
# Outputs non-array value in the form of hash
|
185
|
+
# For object, use to_hash. Otherwise, just return the value
|
186
|
+
# @param [Object] value Any valid value
|
187
|
+
# @return [Hash] Returns the value in the form of hash
|
188
|
+
def _to_hash(value)
|
189
|
+
if value.is_a?(Array)
|
190
|
+
value.compact.map { |v| _to_hash(v) }
|
191
|
+
elsif value.is_a?(Hash)
|
192
|
+
{}.tap do |hash|
|
193
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
194
|
+
end
|
195
|
+
elsif value.respond_to? :to_hash
|
196
|
+
value.to_hash
|
197
|
+
else
|
198
|
+
value
|
199
|
+
end
|
200
|
+
end
|
201
|
+
|
202
|
+
end
|
203
|
+
end
|