masspay_ruby_sdk 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.
Files changed (119) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +8 -0
  3. data/CONTRIBUTING.md +13 -0
  4. data/Gemfile +9 -0
  5. data/README.md +197 -0
  6. data/Rakefile +10 -0
  7. data/docs/AccountApi.md +150 -0
  8. data/docs/ApiResponse.md +22 -0
  9. data/docs/AttrTxn.md +20 -0
  10. data/docs/AttrValue.md +20 -0
  11. data/docs/AttrVelocityRequestInner.md +20 -0
  12. data/docs/AttributeApi.md +168 -0
  13. data/docs/AttrsRequirement.md +36 -0
  14. data/docs/AutopayResp.md +22 -0
  15. data/docs/AutopayRule.md +20 -0
  16. data/docs/AvailableBalanceTxnResp.md +22 -0
  17. data/docs/CardApi.md +160 -0
  18. data/docs/CatalogApi.md +469 -0
  19. data/docs/CompaniesResp.md +18 -0
  20. data/docs/Company.md +26 -0
  21. data/docs/Country.md +22 -0
  22. data/docs/Exception.md +20 -0
  23. data/docs/FoundUser.md +24 -0
  24. data/docs/GetAccountStatement200Response.md +18 -0
  25. data/docs/GetTransactionConfirmationDetails200Response.md +18 -0
  26. data/docs/GetUserAgreement200Response.md +26 -0
  27. data/docs/GetUserAgreementsNames200ResponseInner.md +24 -0
  28. data/docs/GetUserUserTokenKycAu10tix200Response.md +18 -0
  29. data/docs/GetUserUserTokenKycVeriff200Response.md +18 -0
  30. data/docs/GetWalletCardInfo200Response.md +30 -0
  31. data/docs/IDUpload.md +20 -0
  32. data/docs/KYCApi.md +305 -0
  33. data/docs/LoadApi.md +621 -0
  34. data/docs/LoadTxn.md +32 -0
  35. data/docs/LoadTxnResp.md +20 -0
  36. data/docs/Loads.md +36 -0
  37. data/docs/PayoutApi.md +403 -0
  38. data/docs/PayoutTxn.md +36 -0
  39. data/docs/PayoutTxnCommitResp.md +24 -0
  40. data/docs/PayoutTxnResp.md +60 -0
  41. data/docs/ResendBalanceNotification200Response.md +18 -0
  42. data/docs/Service.md +22 -0
  43. data/docs/ServicePayersInner.md +38 -0
  44. data/docs/ServicePayersInnerExchangeRateInner.md +20 -0
  45. data/docs/SpendBackApi.md +161 -0
  46. data/docs/SpendBackTxn.md +28 -0
  47. data/docs/SpendBackTxnResp.md +22 -0
  48. data/docs/SpendBacks.md +34 -0
  49. data/docs/StoredUser.md +56 -0
  50. data/docs/TaxApi.md +81 -0
  51. data/docs/TaxYearUserResp.md +48 -0
  52. data/docs/TxnHistoryResp.md +52 -0
  53. data/docs/UpdateUser.md +52 -0
  54. data/docs/User.md +50 -0
  55. data/docs/UserApi.md +403 -0
  56. data/docs/WalletApi.md +463 -0
  57. data/docs/WalletTxnResp.md +34 -0
  58. data/docs/logo.webp +0 -0
  59. data/lib/masspay_ruby_sdk/api/account_api.rb +149 -0
  60. data/lib/masspay_ruby_sdk/api/attribute_api.rb +214 -0
  61. data/lib/masspay_ruby_sdk/api/card_api.rb +174 -0
  62. data/lib/masspay_ruby_sdk/api/catalog_api.rb +443 -0
  63. data/lib/masspay_ruby_sdk/api/kyc_api.rb +290 -0
  64. data/lib/masspay_ruby_sdk/api/load_api.rb +598 -0
  65. data/lib/masspay_ruby_sdk/api/payout_api.rb +397 -0
  66. data/lib/masspay_ruby_sdk/api/spend_back_api.rb +160 -0
  67. data/lib/masspay_ruby_sdk/api/tax_api.rb +82 -0
  68. data/lib/masspay_ruby_sdk/api/user_api.rb +418 -0
  69. data/lib/masspay_ruby_sdk/api/wallet_api.rb +461 -0
  70. data/lib/masspay_ruby_sdk/api_client.rb +391 -0
  71. data/lib/masspay_ruby_sdk/api_error.rb +57 -0
  72. data/lib/masspay_ruby_sdk/configuration.rb +315 -0
  73. data/lib/masspay_ruby_sdk/models/api_response.rb +236 -0
  74. data/lib/masspay_ruby_sdk/models/attr_txn.rb +235 -0
  75. data/lib/masspay_ruby_sdk/models/attr_value.rb +239 -0
  76. data/lib/masspay_ruby_sdk/models/attr_velocity_request_inner.rb +273 -0
  77. data/lib/masspay_ruby_sdk/models/attrs_requirement.rb +372 -0
  78. data/lib/masspay_ruby_sdk/models/autopay_resp.rb +256 -0
  79. data/lib/masspay_ruby_sdk/models/autopay_rule.rb +241 -0
  80. data/lib/masspay_ruby_sdk/models/available_balance_txn_resp.rb +254 -0
  81. data/lib/masspay_ruby_sdk/models/companies_resp.rb +225 -0
  82. data/lib/masspay_ruby_sdk/models/company.rb +285 -0
  83. data/lib/masspay_ruby_sdk/models/country.rb +296 -0
  84. data/lib/masspay_ruby_sdk/models/exception.rb +241 -0
  85. data/lib/masspay_ruby_sdk/models/found_user.rb +270 -0
  86. data/lib/masspay_ruby_sdk/models/get_account_statement200_response.rb +225 -0
  87. data/lib/masspay_ruby_sdk/models/get_transaction_confirmation_details200_response.rb +218 -0
  88. data/lib/masspay_ruby_sdk/models/get_user_agreement200_response.rb +280 -0
  89. data/lib/masspay_ruby_sdk/models/get_user_agreements_names200_response_inner.rb +270 -0
  90. data/lib/masspay_ruby_sdk/models/get_user_user_token_kyc_au10tix200_response.rb +224 -0
  91. data/lib/masspay_ruby_sdk/models/get_user_user_token_kyc_veriff200_response.rb +224 -0
  92. data/lib/masspay_ruby_sdk/models/get_wallet_card_info200_response.rb +460 -0
  93. data/lib/masspay_ruby_sdk/models/id_upload.rb +273 -0
  94. data/lib/masspay_ruby_sdk/models/load_txn.rb +321 -0
  95. data/lib/masspay_ruby_sdk/models/load_txn_resp.rb +273 -0
  96. data/lib/masspay_ruby_sdk/models/loads.rb +388 -0
  97. data/lib/masspay_ruby_sdk/models/payout_txn.rb +328 -0
  98. data/lib/masspay_ruby_sdk/models/payout_txn_commit_resp.rb +293 -0
  99. data/lib/masspay_ruby_sdk/models/payout_txn_resp.rb +613 -0
  100. data/lib/masspay_ruby_sdk/models/resend_balance_notification200_response.rb +225 -0
  101. data/lib/masspay_ruby_sdk/models/service.rb +318 -0
  102. data/lib/masspay_ruby_sdk/models/service_payers_inner.rb +373 -0
  103. data/lib/masspay_ruby_sdk/models/service_payers_inner_exchange_rate_inner.rb +239 -0
  104. data/lib/masspay_ruby_sdk/models/spend_back_txn.rb +325 -0
  105. data/lib/masspay_ruby_sdk/models/spend_back_txn_resp.rb +307 -0
  106. data/lib/masspay_ruby_sdk/models/spend_backs.rb +340 -0
  107. data/lib/masspay_ruby_sdk/models/stored_user.rb +500 -0
  108. data/lib/masspay_ruby_sdk/models/tax_year_user_resp.rb +388 -0
  109. data/lib/masspay_ruby_sdk/models/txn_history_resp.rb +571 -0
  110. data/lib/masspay_ruby_sdk/models/update_user.rb +490 -0
  111. data/lib/masspay_ruby_sdk/models/user.rb +423 -0
  112. data/lib/masspay_ruby_sdk/models/wallet_txn_resp.rb +375 -0
  113. data/lib/masspay_ruby_sdk/version.rb +14 -0
  114. data/lib/masspay_ruby_sdk.rb +89 -0
  115. data/masspay_ruby_sdk.gemspec +37 -0
  116. data/spec/api_client_spec.rb +227 -0
  117. data/spec/configuration_spec.rb +41 -0
  118. data/spec/spec_helper.rb +110 -0
  119. metadata +203 -0
@@ -0,0 +1,315 @@
1
+ =begin
2
+ #MassPay API
3
+
4
+ #MassPay API
5
+
6
+ The version of the OpenAPI document: 0.1.4
7
+ Contact: support@masspay.io
8
+ Generated by: MassPay Inc.
9
+ OpenAPI Generator version: 6.5.0
10
+ =end
11
+
12
+ module MassPayRubySdk
13
+ class Configuration
14
+ # Defines url scheme
15
+ attr_accessor :scheme
16
+
17
+ # Defines url host
18
+ attr_accessor :host
19
+
20
+ # Defines url base path
21
+ attr_accessor :base_path
22
+
23
+ # Define server configuration index
24
+ attr_accessor :server_index
25
+
26
+ # Define server operation configuration index
27
+ attr_accessor :server_operation_index
28
+
29
+ # Default server variables
30
+ attr_accessor :server_variables
31
+
32
+ # Default server operation variables
33
+ attr_accessor :server_operation_variables
34
+
35
+ # Defines API keys used with API Key authentications.
36
+ #
37
+ # @return [Hash] key: parameter name, value: parameter value (API key)
38
+ #
39
+ # @example parameter name is "api_key", API key is "xxx" (e.g. "api_key=xxx" in query string)
40
+ # config.api_key['api_key'] = 'xxx'
41
+ attr_accessor :api_key
42
+
43
+ # Defines API key prefixes used with API Key authentications.
44
+ #
45
+ # @return [Hash] key: parameter name, value: API key prefix
46
+ #
47
+ # @example parameter name is "Authorization", API key prefix is "Token" (e.g. "Authorization: Token xxx" in headers)
48
+ # config.api_key_prefix['api_key'] = 'Token'
49
+ attr_accessor :api_key_prefix
50
+
51
+ # Defines the username used with HTTP basic authentication.
52
+ #
53
+ # @return [String]
54
+ attr_accessor :username
55
+
56
+ # Defines the password used with HTTP basic authentication.
57
+ #
58
+ # @return [String]
59
+ attr_accessor :password
60
+
61
+ # Defines the access token (Bearer) used with OAuth2.
62
+ attr_accessor :access_token
63
+
64
+ # Defines a Proc used to fetch or refresh access tokens (Bearer) used with OAuth2.
65
+ # Overrides the access_token if set
66
+ # @return [Proc]
67
+ attr_accessor :access_token_getter
68
+
69
+ # Set this to return data as binary instead of downloading a temp file. When enabled (set to true)
70
+ # HTTP responses with return type `File` will be returned as a stream of binary data.
71
+ # Default to false.
72
+ attr_accessor :return_binary_data
73
+
74
+ # Set this to enable/disable debugging. When enabled (set to true), HTTP request/response
75
+ # details will be logged with `logger.debug` (see the `logger` attribute).
76
+ # Default to false.
77
+ #
78
+ # @return [true, false]
79
+ attr_accessor :debugging
80
+
81
+ # Defines the logger used for debugging.
82
+ # Default to `Rails.logger` (when in Rails) or logging to STDOUT.
83
+ #
84
+ # @return [#debug]
85
+ attr_accessor :logger
86
+
87
+ # Defines the temporary folder to store downloaded files
88
+ # (for API endpoints that have file response).
89
+ # Default to use `Tempfile`.
90
+ #
91
+ # @return [String]
92
+ attr_accessor :temp_folder_path
93
+
94
+ # The time limit for HTTP request in seconds.
95
+ # Default to 0 (never times out).
96
+ attr_accessor :timeout
97
+
98
+ # Set this to false to skip client side validation in the operation.
99
+ # Default to true.
100
+ # @return [true, false]
101
+ attr_accessor :client_side_validation
102
+
103
+ ### TLS/SSL setting
104
+ # Set this to false to skip verifying SSL certificate when calling API from https server.
105
+ # Default to true.
106
+ #
107
+ # @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
108
+ #
109
+ # @return [true, false]
110
+ attr_accessor :verify_ssl
111
+
112
+ ### TLS/SSL setting
113
+ # Set this to false to skip verifying SSL host name
114
+ # Default to true.
115
+ #
116
+ # @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
117
+ #
118
+ # @return [true, false]
119
+ attr_accessor :verify_ssl_host
120
+
121
+ ### TLS/SSL setting
122
+ # Set this to customize the certificate file to verify the peer.
123
+ #
124
+ # @return [String] the path to the certificate file
125
+ #
126
+ # @see The `cainfo` option of Typhoeus, `--cert` option of libcurl. Related source code:
127
+ # https://github.com/typhoeus/typhoeus/blob/master/lib/typhoeus/easy_factory.rb#L145
128
+ attr_accessor :ssl_ca_cert
129
+
130
+ ### TLS/SSL setting
131
+ # Client certificate file (for client certificate)
132
+ attr_accessor :cert_file
133
+
134
+ ### TLS/SSL setting
135
+ # Client private key file (for client certificate)
136
+ attr_accessor :key_file
137
+
138
+ # Set this to customize parameters encoding of array parameter with multi collectionFormat.
139
+ # Default to nil.
140
+ #
141
+ # @see The params_encoding option of Ethon. Related source code:
142
+ # https://github.com/typhoeus/ethon/blob/master/lib/ethon/easy/queryable.rb#L96
143
+ attr_accessor :params_encoding
144
+
145
+
146
+ attr_accessor :inject_format
147
+
148
+ attr_accessor :force_ending_format
149
+
150
+ def initialize
151
+ @scheme = 'https'
152
+ @host = 'api.masspay.io'
153
+ @base_path = '/v0.1.4'
154
+ @server_index = 0
155
+ @server_operation_index = {}
156
+ @server_variables = {}
157
+ @server_operation_variables = {}
158
+ @api_key = {}
159
+ @api_key_prefix = {}
160
+ @client_side_validation = true
161
+ @verify_ssl = true
162
+ @verify_ssl_host = true
163
+ @cert_file = nil
164
+ @key_file = nil
165
+ @timeout = 0
166
+ @params_encoding = nil
167
+ @debugging = false
168
+ @inject_format = false
169
+ @force_ending_format = false
170
+ @logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
171
+
172
+ yield(self) if block_given?
173
+ end
174
+
175
+ # The default Configuration object.
176
+ def self.default
177
+ @@default ||= Configuration.new
178
+ end
179
+
180
+ def configure
181
+ yield(self) if block_given?
182
+ end
183
+
184
+ def scheme=(scheme)
185
+ # remove :// from scheme
186
+ @scheme = scheme.sub(/:\/\//, '')
187
+ end
188
+
189
+ def host=(host)
190
+ # remove http(s):// and anything after a slash
191
+ @host = host.sub(/https?:\/\//, '').split('/').first
192
+ end
193
+
194
+ def base_path=(base_path)
195
+ # Add leading and trailing slashes to base_path
196
+ @base_path = "/#{base_path}".gsub(/\/+/, '/')
197
+ @base_path = '' if @base_path == '/'
198
+ end
199
+
200
+ # Returns base URL for specified operation based on server settings
201
+ def base_url(operation = nil)
202
+ index = server_operation_index.fetch(operation, server_index)
203
+ return "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '') if index == nil
204
+
205
+ server_url(index, server_operation_variables.fetch(operation, server_variables), operation_server_settings[operation])
206
+ end
207
+
208
+ # Gets API key (with prefix if set).
209
+ # @param [String] param_name the parameter name of API key auth
210
+ def api_key_with_prefix(param_name, param_alias = nil)
211
+ key = @api_key[param_name]
212
+ key = @api_key.fetch(param_alias, key) unless param_alias.nil?
213
+ if @api_key_prefix[param_name]
214
+ "#{@api_key_prefix[param_name]} #{key}"
215
+ else
216
+ key
217
+ end
218
+ end
219
+
220
+ # Gets access_token using access_token_getter or uses the static access_token
221
+ def access_token_with_refresh
222
+ return access_token if access_token_getter.nil?
223
+ access_token_getter.call
224
+ end
225
+
226
+ # Gets Basic Auth token string
227
+ def basic_auth_token
228
+ 'Basic ' + ["#{username}:#{password}"].pack('m').delete("\r\n")
229
+ end
230
+
231
+ # Returns Auth Settings hash for api client.
232
+ def auth_settings
233
+ {
234
+ 'AUTHORIZER_NAME' =>
235
+ {
236
+ type: 'api_key',
237
+ in: 'header',
238
+ key: 'Authorization',
239
+ value: api_key_with_prefix('AUTHORIZER_NAME')
240
+ },
241
+ }
242
+ end
243
+
244
+ # Returns an array of Server setting
245
+ def server_settings
246
+ [
247
+ {
248
+ url: "https://{environment}.masspay.io/{VERSION}",
249
+ description: "MassPay's API server",
250
+ variables: {
251
+ VERSION: {
252
+ description: "No description provided",
253
+ default_value: "v0.1.4",
254
+ enum_values: [
255
+ "v0.1.0",
256
+ "v0.1.1",
257
+ "v0.1.2",
258
+ "v0.1.3",
259
+ "v0.1.4"
260
+ ]
261
+ },
262
+ environment: {
263
+ description: "No description provided",
264
+ default_value: "api",
265
+ enum_values: [
266
+ "api",
267
+ "staging-api"
268
+ ]
269
+ }
270
+ }
271
+ }
272
+ ]
273
+ end
274
+
275
+ def operation_server_settings
276
+ {
277
+ }
278
+ end
279
+
280
+ # Returns URL based on server settings
281
+ #
282
+ # @param index array index of the server settings
283
+ # @param variables hash of variable and the corresponding value
284
+ def server_url(index, variables = {}, servers = nil)
285
+ servers = server_settings if servers == nil
286
+
287
+ # check array index out of bound
288
+ if (index < 0 || index >= servers.size)
289
+ fail ArgumentError, "Invalid index #{index} when selecting the server. Must be less than #{servers.size}"
290
+ end
291
+
292
+ server = servers[index]
293
+ url = server[:url]
294
+
295
+ return url unless server.key? :variables
296
+
297
+ # go through variable and assign a value
298
+ server[:variables].each do |name, variable|
299
+ if variables.key?(name)
300
+ if (!server[:variables][name].key?(:enum_values) || server[:variables][name][:enum_values].include?(variables[name]))
301
+ url.gsub! "{" + name.to_s + "}", variables[name]
302
+ else
303
+ fail ArgumentError, "The variable `#{name}` in the server URL has invalid value #{variables[name]}. Must be #{server[:variables][name][:enum_values]}."
304
+ end
305
+ else
306
+ # use default value
307
+ url.gsub! "{" + name.to_s + "}", server[:variables][name][:default_value]
308
+ end
309
+ end
310
+
311
+ url
312
+ end
313
+
314
+ end
315
+ end
@@ -0,0 +1,236 @@
1
+ =begin
2
+ #MassPay API
3
+
4
+ #MassPay API
5
+
6
+ The version of the OpenAPI document: 0.1.4
7
+ Contact: support@masspay.io
8
+ Generated by: MassPay Inc.
9
+ OpenAPI Generator version: 6.5.0
10
+ =end
11
+
12
+ require 'date'
13
+ require 'time'
14
+
15
+ module MassPayRubySdk
16
+ class ApiResponse
17
+ attr_accessor :code
18
+
19
+ attr_accessor :type
20
+
21
+ attr_accessor :message
22
+
23
+ # Attribute mapping from ruby-style variable name to JSON key.
24
+ def self.attribute_map
25
+ {
26
+ :'code' => :'code',
27
+ :'type' => :'type',
28
+ :'message' => :'message'
29
+ }
30
+ end
31
+
32
+ # Returns all the JSON keys this model knows about
33
+ def self.acceptable_attributes
34
+ attribute_map.values
35
+ end
36
+
37
+ # Attribute type mapping.
38
+ def self.openapi_types
39
+ {
40
+ :'code' => :'Integer',
41
+ :'type' => :'String',
42
+ :'message' => :'String'
43
+ }
44
+ end
45
+
46
+ # List of attributes with nullable: true
47
+ def self.openapi_nullable
48
+ Set.new([
49
+ ])
50
+ end
51
+
52
+ # Initializes the object
53
+ # @param [Hash] attributes Model attributes in the form of hash
54
+ def initialize(attributes = {})
55
+ if (!attributes.is_a?(Hash))
56
+ fail ArgumentError, "The input argument (attributes) must be a hash in `MassPayRubySdk::ApiResponse` initialize method"
57
+ end
58
+
59
+ # check to see if the attribute exists and convert string to symbol for hash key
60
+ attributes = attributes.each_with_object({}) { |(k, v), h|
61
+ if (!self.class.attribute_map.key?(k.to_sym))
62
+ fail ArgumentError, "`#{k}` is not a valid attribute in `MassPayRubySdk::ApiResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
63
+ end
64
+ h[k.to_sym] = v
65
+ }
66
+
67
+ if attributes.key?(:'code')
68
+ self.code = attributes[:'code']
69
+ end
70
+
71
+ if attributes.key?(:'type')
72
+ self.type = attributes[:'type']
73
+ end
74
+
75
+ if attributes.key?(:'message')
76
+ self.message = attributes[:'message']
77
+ end
78
+ end
79
+
80
+ # Show invalid properties with the reasons. Usually used together with valid?
81
+ # @return Array for valid properties with the reasons
82
+ def list_invalid_properties
83
+ invalid_properties = Array.new
84
+ invalid_properties
85
+ end
86
+
87
+ # Check to see if the all the properties in the model are valid
88
+ # @return true if the model is valid
89
+ def valid?
90
+ true
91
+ end
92
+
93
+ # Checks equality by comparing each attribute.
94
+ # @param [Object] Object to be compared
95
+ def ==(o)
96
+ return true if self.equal?(o)
97
+ self.class == o.class &&
98
+ code == o.code &&
99
+ type == o.type &&
100
+ message == o.message
101
+ end
102
+
103
+ # @see the `==` method
104
+ # @param [Object] Object to be compared
105
+ def eql?(o)
106
+ self == o
107
+ end
108
+
109
+ # Calculates hash code according to all attributes.
110
+ # @return [Integer] Hash code
111
+ def hash
112
+ [code, type, message].hash
113
+ end
114
+
115
+ # Builds the object from hash
116
+ # @param [Hash] attributes Model attributes in the form of hash
117
+ # @return [Object] Returns the model itself
118
+ def self.build_from_hash(attributes)
119
+ new.build_from_hash(attributes)
120
+ end
121
+
122
+ # Builds the object from hash
123
+ # @param [Hash] attributes Model attributes in the form of hash
124
+ # @return [Object] Returns the model itself
125
+ def build_from_hash(attributes)
126
+ return nil unless attributes.is_a?(Hash)
127
+ attributes = attributes.transform_keys(&:to_sym)
128
+ self.class.openapi_types.each_pair do |key, type|
129
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
130
+ self.send("#{key}=", nil)
131
+ elsif type =~ /\AArray<(.*)>/i
132
+ # check to ensure the input is an array given that the attribute
133
+ # is documented as an array but the input is not
134
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
135
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
136
+ end
137
+ elsif !attributes[self.class.attribute_map[key]].nil?
138
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
139
+ end
140
+ end
141
+
142
+ self
143
+ end
144
+
145
+ # Deserializes the data based on type
146
+ # @param string type Data type
147
+ # @param string value Value to be deserialized
148
+ # @return [Object] Deserialized data
149
+ def _deserialize(type, value)
150
+ case type.to_sym
151
+ when :Time
152
+ Time.parse(value)
153
+ when :Date
154
+ Date.parse(value)
155
+ when :String
156
+ value.to_s
157
+ when :Integer
158
+ value.to_i
159
+ when :Float
160
+ value.to_f
161
+ when :Boolean
162
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
163
+ true
164
+ else
165
+ false
166
+ end
167
+ when :Object
168
+ # generic object (usually a Hash), return directly
169
+ value
170
+ when /\AArray<(?<inner_type>.+)>\z/
171
+ inner_type = Regexp.last_match[:inner_type]
172
+ value.map { |v| _deserialize(inner_type, v) }
173
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
174
+ k_type = Regexp.last_match[:k_type]
175
+ v_type = Regexp.last_match[:v_type]
176
+ {}.tap do |hash|
177
+ value.each do |k, v|
178
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
179
+ end
180
+ end
181
+ else # model
182
+ # models (e.g. Pet) or oneOf
183
+ klass = MassPayRubySdk.const_get(type)
184
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
185
+ end
186
+ end
187
+
188
+ # Returns the string representation of the object
189
+ # @return [String] String presentation of the object
190
+ def to_s
191
+ to_hash.to_s
192
+ end
193
+
194
+ # to_body is an alias to to_hash (backward compatibility)
195
+ # @return [Hash] Returns the object in the form of hash
196
+ def to_body
197
+ to_hash
198
+ end
199
+
200
+ # Returns the object in the form of hash
201
+ # @return [Hash] Returns the object in the form of hash
202
+ def to_hash
203
+ hash = {}
204
+ self.class.attribute_map.each_pair do |attr, param|
205
+ value = self.send(attr)
206
+ if value.nil?
207
+ is_nullable = self.class.openapi_nullable.include?(attr)
208
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
209
+ end
210
+
211
+ hash[param] = _to_hash(value)
212
+ end
213
+ hash
214
+ end
215
+
216
+ # Outputs non-array value in the form of hash
217
+ # For object, use to_hash. Otherwise, just return the value
218
+ # @param [Object] value Any valid value
219
+ # @return [Hash] Returns the value in the form of hash
220
+ def _to_hash(value)
221
+ if value.is_a?(Array)
222
+ value.compact.map { |v| _to_hash(v) }
223
+ elsif value.is_a?(Hash)
224
+ {}.tap do |hash|
225
+ value.each { |k, v| hash[k] = _to_hash(v) }
226
+ end
227
+ elsif value.respond_to? :to_hash
228
+ value.to_hash
229
+ else
230
+ value
231
+ end
232
+ end
233
+
234
+ end
235
+
236
+ end