mx-platform-ruby 0.10.0 → 0.11.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +4 -4
  3. data/docs/CredentialResponse.md +3 -1
  4. data/docs/MxPlatformApi.md +215 -2
  5. data/docs/PaymentAccountResponse.md +30 -0
  6. data/docs/PaymentAccountResponseBody.md +18 -0
  7. data/docs/PaymentProcessorAuthorizationCodeRequest.md +22 -0
  8. data/docs/PaymentProcessorAuthorizationCodeRequestBody.md +18 -0
  9. data/docs/PaymentProcessorAuthorizationCodeResponse.md +18 -0
  10. data/docs/PaymentProcessorAuthorizationCodeResponseBody.md +18 -0
  11. data/docs/PaymentProcessorTokenResponseBody.md +22 -0
  12. data/lib/mx-platform-ruby/api/mx_platform_api.rb +192 -4
  13. data/lib/mx-platform-ruby/configuration.rb +7 -0
  14. data/lib/mx-platform-ruby/models/credential_response.rb +15 -5
  15. data/lib/mx-platform-ruby/models/payment_account_response.rb +279 -0
  16. data/lib/mx-platform-ruby/models/payment_account_response_body.rb +218 -0
  17. data/lib/mx-platform-ruby/models/payment_processor_authorization_code_request.rb +236 -0
  18. data/lib/mx-platform-ruby/models/payment_processor_authorization_code_request_body.rb +218 -0
  19. data/lib/mx-platform-ruby/models/payment_processor_authorization_code_response.rb +219 -0
  20. data/lib/mx-platform-ruby/models/payment_processor_authorization_code_response_body.rb +218 -0
  21. data/lib/mx-platform-ruby/models/payment_processor_token_response_body.rb +239 -0
  22. data/lib/mx-platform-ruby/version.rb +1 -1
  23. data/lib/mx-platform-ruby.rb +7 -0
  24. data/openapi/config.yml +1 -1
  25. data/spec/api/mx_platform_api_spec.rb +38 -2
  26. data/spec/models/credential_response_spec.rb +6 -0
  27. data/spec/models/payment_account_response_body_spec.rb +34 -0
  28. data/spec/models/payment_account_response_spec.rb +70 -0
  29. data/spec/models/payment_processor_authorization_code_request_body_spec.rb +34 -0
  30. data/spec/models/payment_processor_authorization_code_request_spec.rb +46 -0
  31. data/spec/models/payment_processor_authorization_code_response_body_spec.rb +34 -0
  32. data/spec/models/payment_processor_authorization_code_response_spec.rb +34 -0
  33. data/spec/models/payment_processor_token_response_body_spec.rb +46 -0
  34. metadata +119 -91
@@ -768,7 +768,7 @@ module MxPlatformRuby
768
768
  end
769
769
 
770
770
  # Create user
771
- # Call this endpoint to create a new user. The MX Platform API will respond with the newly-created user object if successful. This endpoint accepts several parameters - id, metadata, and is_disabled. Disabling a user means that accounts and transactions associated with it will not be updated in the background by MX. It will also restrict access to that users data until they are no longer disabled. Users who are disabled for the entirety of an MX Platform API billing period will not be factored into that months bill.
771
+ # Use this endpoint to create a new user. The API will respond with the newly-created user object if successful. Disabling a user means that accounts and transactions associated with it will not be updated in the background by MX. It will also restrict access to that user’s data until they are no longer disabled.
772
772
  # @param user_create_request_body [UserCreateRequestBody] User object to be created. (None of these parameters are required, but the user object cannot be empty)
773
773
  # @param [Hash] opts the optional parameters
774
774
  # @return [UserResponseBody]
@@ -778,7 +778,7 @@ module MxPlatformRuby
778
778
  end
779
779
 
780
780
  # Create user
781
- # Call this endpoint to create a new user. The MX Platform API will respond with the newly-created user object if successful. This endpoint accepts several parameters - id, metadata, and is_disabled. Disabling a user means that accounts and transactions associated with it will not be updated in the background by MX. It will also restrict access to that users data until they are no longer disabled. Users who are disabled for the entirety of an MX Platform API billing period will not be factored into that months bill.
781
+ # Use this endpoint to create a new user. The API will respond with the newly-created user object if successful. Disabling a user means that accounts and transactions associated with it will not be updated in the background by MX. It will also restrict access to that user’s data until they are no longer disabled.
782
782
  # @param user_create_request_body [UserCreateRequestBody] User object to be created. (None of these parameters are required, but the user object cannot be empty)
783
783
  # @param [Hash] opts the optional parameters
784
784
  # @return [Array<(UserResponseBody, Integer, Hash)>] UserResponseBody data, response status code and response headers
@@ -5363,6 +5363,194 @@ module MxPlatformRuby
5363
5363
  return data, status_code, headers
5364
5364
  end
5365
5365
 
5366
+ # Request payment account
5367
+ # Use this endpoint to request a payment account.
5368
+ # @param [Hash] opts the optional parameters
5369
+ # @return [PaymentAccountResponseBody]
5370
+ def request_payment_account(opts = {})
5371
+ data, _status_code, _headers = request_payment_account_with_http_info(opts)
5372
+ data
5373
+ end
5374
+
5375
+ # Request payment account
5376
+ # Use this endpoint to request a payment account.
5377
+ # @param [Hash] opts the optional parameters
5378
+ # @return [Array<(PaymentAccountResponseBody, Integer, Hash)>] PaymentAccountResponseBody data, response status code and response headers
5379
+ def request_payment_account_with_http_info(opts = {})
5380
+ if @api_client.config.debugging
5381
+ @api_client.config.logger.debug 'Calling API: MxPlatformApi.request_payment_account ...'
5382
+ end
5383
+ # resource path
5384
+ local_var_path = '/payment_account'
5385
+
5386
+ # query parameters
5387
+ query_params = opts[:query_params] || {}
5388
+
5389
+ # header parameters
5390
+ header_params = opts[:header_params] || {}
5391
+ # HTTP header 'Accept' (if needed)
5392
+ header_params['Accept'] = @api_client.select_header_accept(['application/vnd.mx.api.v1+json'])
5393
+
5394
+ # form parameters
5395
+ form_params = opts[:form_params] || {}
5396
+
5397
+ # http body (model)
5398
+ post_body = opts[:debug_body]
5399
+
5400
+ # return_type
5401
+ return_type = opts[:debug_return_type] || 'PaymentAccountResponseBody'
5402
+
5403
+ # auth_names
5404
+ auth_names = opts[:debug_auth_names] || ['bearerAuth']
5405
+
5406
+ new_options = opts.merge(
5407
+ :operation => :"MxPlatformApi.request_payment_account",
5408
+ :header_params => header_params,
5409
+ :query_params => query_params,
5410
+ :form_params => form_params,
5411
+ :body => post_body,
5412
+ :auth_names => auth_names,
5413
+ :return_type => return_type
5414
+ )
5415
+
5416
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
5417
+ if @api_client.config.debugging
5418
+ @api_client.config.logger.debug "API called: MxPlatformApi#request_payment_account\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
5419
+ end
5420
+ return data, status_code, headers
5421
+ end
5422
+
5423
+ # Request payment processor authorization code
5424
+ # Use this endpoint to request a payment processor authorization code.
5425
+ # @param payment_processor_authorization_code_request_body [PaymentProcessorAuthorizationCodeRequestBody] Payment processor authorization code object containing account_guid, member_guid, and user_guid.
5426
+ # @param [Hash] opts the optional parameters
5427
+ # @return [PaymentProcessorAuthorizationCodeResponseBody]
5428
+ def request_payment_processor_authorization_code(payment_processor_authorization_code_request_body, opts = {})
5429
+ data, _status_code, _headers = request_payment_processor_authorization_code_with_http_info(payment_processor_authorization_code_request_body, opts)
5430
+ data
5431
+ end
5432
+
5433
+ # Request payment processor authorization code
5434
+ # Use this endpoint to request a payment processor authorization code.
5435
+ # @param payment_processor_authorization_code_request_body [PaymentProcessorAuthorizationCodeRequestBody] Payment processor authorization code object containing account_guid, member_guid, and user_guid.
5436
+ # @param [Hash] opts the optional parameters
5437
+ # @return [Array<(PaymentProcessorAuthorizationCodeResponseBody, Integer, Hash)>] PaymentProcessorAuthorizationCodeResponseBody data, response status code and response headers
5438
+ def request_payment_processor_authorization_code_with_http_info(payment_processor_authorization_code_request_body, opts = {})
5439
+ if @api_client.config.debugging
5440
+ @api_client.config.logger.debug 'Calling API: MxPlatformApi.request_payment_processor_authorization_code ...'
5441
+ end
5442
+ # verify the required parameter 'payment_processor_authorization_code_request_body' is set
5443
+ if @api_client.config.client_side_validation && payment_processor_authorization_code_request_body.nil?
5444
+ fail ArgumentError, "Missing the required parameter 'payment_processor_authorization_code_request_body' when calling MxPlatformApi.request_payment_processor_authorization_code"
5445
+ end
5446
+ # resource path
5447
+ local_var_path = '/payment_processor_authorization_code'
5448
+
5449
+ # query parameters
5450
+ query_params = opts[:query_params] || {}
5451
+
5452
+ # header parameters
5453
+ header_params = opts[:header_params] || {}
5454
+ # HTTP header 'Accept' (if needed)
5455
+ header_params['Accept'] = @api_client.select_header_accept(['application/vnd.mx.api.v1+json'])
5456
+ # HTTP header 'Content-Type'
5457
+ content_type = @api_client.select_header_content_type(['application/json'])
5458
+ if !content_type.nil?
5459
+ header_params['Content-Type'] = content_type
5460
+ end
5461
+
5462
+ # form parameters
5463
+ form_params = opts[:form_params] || {}
5464
+
5465
+ # http body (model)
5466
+ post_body = opts[:debug_body] || @api_client.object_to_http_body(payment_processor_authorization_code_request_body)
5467
+
5468
+ # return_type
5469
+ return_type = opts[:debug_return_type] || 'PaymentProcessorAuthorizationCodeResponseBody'
5470
+
5471
+ # auth_names
5472
+ auth_names = opts[:debug_auth_names] || ['basicAuth']
5473
+
5474
+ new_options = opts.merge(
5475
+ :operation => :"MxPlatformApi.request_payment_processor_authorization_code",
5476
+ :header_params => header_params,
5477
+ :query_params => query_params,
5478
+ :form_params => form_params,
5479
+ :body => post_body,
5480
+ :auth_names => auth_names,
5481
+ :return_type => return_type
5482
+ )
5483
+
5484
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
5485
+ if @api_client.config.debugging
5486
+ @api_client.config.logger.debug "API called: MxPlatformApi#request_payment_processor_authorization_code\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
5487
+ end
5488
+ return data, status_code, headers
5489
+ end
5490
+
5491
+ # Request payment processor token
5492
+ # Use this endpoint to request a payment processor token.
5493
+ # @param [Hash] opts the optional parameters
5494
+ # @option opts [String] :code Code to request processor token.
5495
+ # @option opts [String] :grant_type Specify grant type.
5496
+ # @return [PaymentProcessorTokenResponseBody]
5497
+ def request_payment_processor_token(opts = {})
5498
+ data, _status_code, _headers = request_payment_processor_token_with_http_info(opts)
5499
+ data
5500
+ end
5501
+
5502
+ # Request payment processor token
5503
+ # Use this endpoint to request a payment processor token.
5504
+ # @param [Hash] opts the optional parameters
5505
+ # @option opts [String] :code Code to request processor token.
5506
+ # @option opts [String] :grant_type Specify grant type.
5507
+ # @return [Array<(PaymentProcessorTokenResponseBody, Integer, Hash)>] PaymentProcessorTokenResponseBody data, response status code and response headers
5508
+ def request_payment_processor_token_with_http_info(opts = {})
5509
+ if @api_client.config.debugging
5510
+ @api_client.config.logger.debug 'Calling API: MxPlatformApi.request_payment_processor_token ...'
5511
+ end
5512
+ # resource path
5513
+ local_var_path = '/payment_processor_token'
5514
+
5515
+ # query parameters
5516
+ query_params = opts[:query_params] || {}
5517
+ query_params[:'code'] = opts[:'code'] if !opts[:'code'].nil?
5518
+ query_params[:'grant_type'] = opts[:'grant_type'] if !opts[:'grant_type'].nil?
5519
+
5520
+ # header parameters
5521
+ header_params = opts[:header_params] || {}
5522
+ # HTTP header 'Accept' (if needed)
5523
+ header_params['Accept'] = @api_client.select_header_accept(['application/vnd.mx.api.v1+json'])
5524
+
5525
+ # form parameters
5526
+ form_params = opts[:form_params] || {}
5527
+
5528
+ # http body (model)
5529
+ post_body = opts[:debug_body]
5530
+
5531
+ # return_type
5532
+ return_type = opts[:debug_return_type] || 'PaymentProcessorTokenResponseBody'
5533
+
5534
+ # auth_names
5535
+ auth_names = opts[:debug_auth_names] || ['basicAuth']
5536
+
5537
+ new_options = opts.merge(
5538
+ :operation => :"MxPlatformApi.request_payment_processor_token",
5539
+ :header_params => header_params,
5540
+ :query_params => query_params,
5541
+ :form_params => form_params,
5542
+ :body => post_body,
5543
+ :auth_names => auth_names,
5544
+ :return_type => return_type
5545
+ )
5546
+
5547
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
5548
+ if @api_client.config.debugging
5549
+ @api_client.config.logger.debug "API called: MxPlatformApi#request_payment_processor_token\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
5550
+ end
5551
+ return data, status_code, headers
5552
+ end
5553
+
5366
5554
  # Request widget url
5367
5555
  # This endpoint allows partners to get a URL by passing the `widget_type` in the request body, as well as configuring it in several different ways. In the case of Connect, that means setting the `widget_type` to `connect_widget`. Partners may also pass an optional `Accept-Language` header as well as a number of configuration options. Note that this is a `POST` request.
5368
5556
  # @param user_guid [String] The unique id for a &#x60;user&#x60;.
@@ -6345,7 +6533,7 @@ module MxPlatformRuby
6345
6533
  end
6346
6534
 
6347
6535
  # Update user
6348
- # Use this endpoint to update the attributes of a specific user. The MX Platform API will respond with the updated user object. Disabling a user means that accounts and transactions associated with it will not be updated in the background by MX. It will also restrict access to that users data until they are no longer disabled. Users who are disabled for the entirety of an MX Platform API billing period will not be factored into that months bill. To disable a user, update it and set the is_disabled parameter to true. Set it to false to re-enable the user.
6536
+ # Use this endpoint to update the attributes of the specified user.
6349
6537
  # @param user_guid [String] The unique id for a &#x60;user&#x60;.
6350
6538
  # @param user_update_request_body [UserUpdateRequestBody] User object to be updated (None of these parameters are required, but the user object cannot be empty.)
6351
6539
  # @param [Hash] opts the optional parameters
@@ -6356,7 +6544,7 @@ module MxPlatformRuby
6356
6544
  end
6357
6545
 
6358
6546
  # Update user
6359
- # Use this endpoint to update the attributes of a specific user. The MX Platform API will respond with the updated user object. Disabling a user means that accounts and transactions associated with it will not be updated in the background by MX. It will also restrict access to that users data until they are no longer disabled. Users who are disabled for the entirety of an MX Platform API billing period will not be factored into that months bill. To disable a user, update it and set the is_disabled parameter to true. Set it to false to re-enable the user.
6547
+ # Use this endpoint to update the attributes of the specified user.
6360
6548
  # @param user_guid [String] The unique id for a &#x60;user&#x60;.
6361
6549
  # @param user_update_request_body [UserUpdateRequestBody] User object to be updated (None of these parameters are required, but the user object cannot be empty.)
6362
6550
  # @param [Hash] opts the optional parameters
@@ -220,6 +220,13 @@ module MxPlatformRuby
220
220
  key: 'Authorization',
221
221
  value: basic_auth_token
222
222
  },
223
+ 'bearerAuth' =>
224
+ {
225
+ type: 'bearer',
226
+ in: 'header',
227
+ key: 'Authorization',
228
+ value: "Bearer #{access_token}"
229
+ },
223
230
  }
224
231
  end
225
232
 
@@ -25,6 +25,8 @@ module MxPlatformRuby
25
25
 
26
26
  attr_accessor :label
27
27
 
28
+ attr_accessor :type
29
+
28
30
  # Attribute mapping from ruby-style variable name to JSON key.
29
31
  def self.attribute_map
30
32
  {
@@ -32,7 +34,8 @@ module MxPlatformRuby
32
34
  :'field_name' => :'field_name',
33
35
  :'field_type' => :'field_type',
34
36
  :'guid' => :'guid',
35
- :'label' => :'label'
37
+ :'label' => :'label',
38
+ :'type' => :'type'
36
39
  }
37
40
  end
38
41
 
@@ -48,7 +51,8 @@ module MxPlatformRuby
48
51
  :'field_name' => :'String',
49
52
  :'field_type' => :'String',
50
53
  :'guid' => :'String',
51
- :'label' => :'String'
54
+ :'label' => :'String',
55
+ :'type' => :'String'
52
56
  }
53
57
  end
54
58
 
@@ -59,7 +63,8 @@ module MxPlatformRuby
59
63
  :'field_name',
60
64
  :'field_type',
61
65
  :'guid',
62
- :'label'
66
+ :'label',
67
+ :'type'
63
68
  ])
64
69
  end
65
70
 
@@ -97,6 +102,10 @@ module MxPlatformRuby
97
102
  if attributes.key?(:'label')
98
103
  self.label = attributes[:'label']
99
104
  end
105
+
106
+ if attributes.key?(:'type')
107
+ self.type = attributes[:'type']
108
+ end
100
109
  end
101
110
 
102
111
  # Show invalid properties with the reasons. Usually used together with valid?
@@ -121,7 +130,8 @@ module MxPlatformRuby
121
130
  field_name == o.field_name &&
122
131
  field_type == o.field_type &&
123
132
  guid == o.guid &&
124
- label == o.label
133
+ label == o.label &&
134
+ type == o.type
125
135
  end
126
136
 
127
137
  # @see the `==` method
@@ -133,7 +143,7 @@ module MxPlatformRuby
133
143
  # Calculates hash code according to all attributes.
134
144
  # @return [Integer] Hash code
135
145
  def hash
136
- [display_order, field_name, field_type, guid, label].hash
146
+ [display_order, field_name, field_type, guid, label, type].hash
137
147
  end
138
148
 
139
149
  # Builds the object from hash
@@ -0,0 +1,279 @@
1
+ =begin
2
+ #MX Platform API
3
+
4
+ #The MX Platform API is a powerful, fully-featured API designed to make aggregating and enhancing financial data easy and reliable. It can seamlessly connect your app or website to tens of thousands of financial institutions.
5
+
6
+ The version of the OpenAPI document: 0.1.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 5.4.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module MxPlatformRuby
17
+ class PaymentAccountResponse
18
+ attr_accessor :account_name
19
+
20
+ attr_accessor :account_number
21
+
22
+ attr_accessor :account_type
23
+
24
+ attr_accessor :available_balance
25
+
26
+ attr_accessor :balance
27
+
28
+ attr_accessor :routing_number
29
+
30
+ attr_accessor :transit_number
31
+
32
+ # Attribute mapping from ruby-style variable name to JSON key.
33
+ def self.attribute_map
34
+ {
35
+ :'account_name' => :'account_name',
36
+ :'account_number' => :'account_number',
37
+ :'account_type' => :'account_type',
38
+ :'available_balance' => :'available_balance',
39
+ :'balance' => :'balance',
40
+ :'routing_number' => :'routing_number',
41
+ :'transit_number' => :'transit_number'
42
+ }
43
+ end
44
+
45
+ # Returns all the JSON keys this model knows about
46
+ def self.acceptable_attributes
47
+ attribute_map.values
48
+ end
49
+
50
+ # Attribute type mapping.
51
+ def self.openapi_types
52
+ {
53
+ :'account_name' => :'String',
54
+ :'account_number' => :'String',
55
+ :'account_type' => :'String',
56
+ :'available_balance' => :'Float',
57
+ :'balance' => :'Float',
58
+ :'routing_number' => :'String',
59
+ :'transit_number' => :'String'
60
+ }
61
+ end
62
+
63
+ # List of attributes with nullable: true
64
+ def self.openapi_nullable
65
+ Set.new([
66
+ :'account_name',
67
+ :'account_number',
68
+ :'account_type',
69
+ :'available_balance',
70
+ :'balance',
71
+ :'routing_number',
72
+ :'transit_number'
73
+ ])
74
+ end
75
+
76
+ # Initializes the object
77
+ # @param [Hash] attributes Model attributes in the form of hash
78
+ def initialize(attributes = {})
79
+ if (!attributes.is_a?(Hash))
80
+ fail ArgumentError, "The input argument (attributes) must be a hash in `MxPlatformRuby::PaymentAccountResponse` initialize method"
81
+ end
82
+
83
+ # check to see if the attribute exists and convert string to symbol for hash key
84
+ attributes = attributes.each_with_object({}) { |(k, v), h|
85
+ if (!self.class.attribute_map.key?(k.to_sym))
86
+ fail ArgumentError, "`#{k}` is not a valid attribute in `MxPlatformRuby::PaymentAccountResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
87
+ end
88
+ h[k.to_sym] = v
89
+ }
90
+
91
+ if attributes.key?(:'account_name')
92
+ self.account_name = attributes[:'account_name']
93
+ end
94
+
95
+ if attributes.key?(:'account_number')
96
+ self.account_number = attributes[:'account_number']
97
+ end
98
+
99
+ if attributes.key?(:'account_type')
100
+ self.account_type = attributes[:'account_type']
101
+ end
102
+
103
+ if attributes.key?(:'available_balance')
104
+ self.available_balance = attributes[:'available_balance']
105
+ end
106
+
107
+ if attributes.key?(:'balance')
108
+ self.balance = attributes[:'balance']
109
+ end
110
+
111
+ if attributes.key?(:'routing_number')
112
+ self.routing_number = attributes[:'routing_number']
113
+ end
114
+
115
+ if attributes.key?(:'transit_number')
116
+ self.transit_number = attributes[:'transit_number']
117
+ end
118
+ end
119
+
120
+ # Show invalid properties with the reasons. Usually used together with valid?
121
+ # @return Array for valid properties with the reasons
122
+ def list_invalid_properties
123
+ invalid_properties = Array.new
124
+ invalid_properties
125
+ end
126
+
127
+ # Check to see if the all the properties in the model are valid
128
+ # @return true if the model is valid
129
+ def valid?
130
+ true
131
+ end
132
+
133
+ # Checks equality by comparing each attribute.
134
+ # @param [Object] Object to be compared
135
+ def ==(o)
136
+ return true if self.equal?(o)
137
+ self.class == o.class &&
138
+ account_name == o.account_name &&
139
+ account_number == o.account_number &&
140
+ account_type == o.account_type &&
141
+ available_balance == o.available_balance &&
142
+ balance == o.balance &&
143
+ routing_number == o.routing_number &&
144
+ transit_number == o.transit_number
145
+ end
146
+
147
+ # @see the `==` method
148
+ # @param [Object] Object to be compared
149
+ def eql?(o)
150
+ self == o
151
+ end
152
+
153
+ # Calculates hash code according to all attributes.
154
+ # @return [Integer] Hash code
155
+ def hash
156
+ [account_name, account_number, account_type, available_balance, balance, routing_number, transit_number].hash
157
+ end
158
+
159
+ # Builds the object from hash
160
+ # @param [Hash] attributes Model attributes in the form of hash
161
+ # @return [Object] Returns the model itself
162
+ def self.build_from_hash(attributes)
163
+ new.build_from_hash(attributes)
164
+ end
165
+
166
+ # Builds the object from hash
167
+ # @param [Hash] attributes Model attributes in the form of hash
168
+ # @return [Object] Returns the model itself
169
+ def build_from_hash(attributes)
170
+ return nil unless attributes.is_a?(Hash)
171
+ self.class.openapi_types.each_pair do |key, type|
172
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
173
+ self.send("#{key}=", nil)
174
+ elsif type =~ /\AArray<(.*)>/i
175
+ # check to ensure the input is an array given that the attribute
176
+ # is documented as an array but the input is not
177
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
178
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
179
+ end
180
+ elsif !attributes[self.class.attribute_map[key]].nil?
181
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
182
+ end
183
+ end
184
+
185
+ self
186
+ end
187
+
188
+ # Deserializes the data based on type
189
+ # @param string type Data type
190
+ # @param string value Value to be deserialized
191
+ # @return [Object] Deserialized data
192
+ def _deserialize(type, value)
193
+ case type.to_sym
194
+ when :Time
195
+ Time.parse(value)
196
+ when :Date
197
+ Date.parse(value)
198
+ when :String
199
+ value.to_s
200
+ when :Integer
201
+ value.to_i
202
+ when :Float
203
+ value.to_f
204
+ when :Boolean
205
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
206
+ true
207
+ else
208
+ false
209
+ end
210
+ when :Object
211
+ # generic object (usually a Hash), return directly
212
+ value
213
+ when /\AArray<(?<inner_type>.+)>\z/
214
+ inner_type = Regexp.last_match[:inner_type]
215
+ value.map { |v| _deserialize(inner_type, v) }
216
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
217
+ k_type = Regexp.last_match[:k_type]
218
+ v_type = Regexp.last_match[:v_type]
219
+ {}.tap do |hash|
220
+ value.each do |k, v|
221
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
222
+ end
223
+ end
224
+ else # model
225
+ # models (e.g. Pet) or oneOf
226
+ klass = MxPlatformRuby.const_get(type)
227
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
228
+ end
229
+ end
230
+
231
+ # Returns the string representation of the object
232
+ # @return [String] String presentation of the object
233
+ def to_s
234
+ to_hash.to_s
235
+ end
236
+
237
+ # to_body is an alias to to_hash (backward compatibility)
238
+ # @return [Hash] Returns the object in the form of hash
239
+ def to_body
240
+ to_hash
241
+ end
242
+
243
+ # Returns the object in the form of hash
244
+ # @return [Hash] Returns the object in the form of hash
245
+ def to_hash
246
+ hash = {}
247
+ self.class.attribute_map.each_pair do |attr, param|
248
+ value = self.send(attr)
249
+ if value.nil?
250
+ is_nullable = self.class.openapi_nullable.include?(attr)
251
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
252
+ end
253
+
254
+ hash[param] = _to_hash(value)
255
+ end
256
+ hash
257
+ end
258
+
259
+ # Outputs non-array value in the form of hash
260
+ # For object, use to_hash. Otherwise, just return the value
261
+ # @param [Object] value Any valid value
262
+ # @return [Hash] Returns the value in the form of hash
263
+ def _to_hash(value)
264
+ if value.is_a?(Array)
265
+ value.compact.map { |v| _to_hash(v) }
266
+ elsif value.is_a?(Hash)
267
+ {}.tap do |hash|
268
+ value.each { |k, v| hash[k] = _to_hash(v) }
269
+ end
270
+ elsif value.respond_to? :to_hash
271
+ value.to_hash
272
+ else
273
+ value
274
+ end
275
+ end
276
+
277
+ end
278
+
279
+ end