mx-platform-ruby 0.39.0 → 0.41.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (99) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +4 -4
  3. data/docs/BudgetCreateRequest.md +26 -0
  4. data/docs/BudgetCreateRequestBody.md +18 -0
  5. data/docs/BudgetResponse.md +48 -0
  6. data/docs/BudgetResponseBody.md +18 -0
  7. data/docs/BudgetUpdateRequest.md +22 -0
  8. data/docs/BudgetUpdateRequestBody.md +18 -0
  9. data/docs/BudgetsApi.md +444 -0
  10. data/docs/CreditCardProduct.md +8 -8
  11. data/docs/CreditCardProductResponse.md +2 -2
  12. data/docs/GoalRequest.md +38 -0
  13. data/docs/GoalRequestBody.md +18 -0
  14. data/docs/GoalResponse.md +48 -0
  15. data/docs/GoalResponseBody.md +18 -0
  16. data/docs/GoalsApi.md +450 -0
  17. data/docs/GoalsResponse.md +48 -0
  18. data/docs/GoalsResponseBody.md +20 -0
  19. data/docs/MonthlyCashFlowProfileRequest.md +20 -0
  20. data/docs/MonthlyCashFlowProfileRequestBody.md +18 -0
  21. data/docs/MonthlyCashFlowResponse.md +30 -0
  22. data/docs/MonthlyCashFlowResponseBody.md +18 -0
  23. data/docs/MxPlatformApi.md +294 -3
  24. data/docs/RepositionRequest.md +20 -0
  25. data/docs/RepositionRequestBody.md +18 -0
  26. data/docs/RepositionResponseBody.md +18 -0
  27. data/docs/RewardResponse.md +2 -0
  28. data/docs/RewardsResponse.md +2 -0
  29. data/docs/SplitTransactionRequest.md +24 -0
  30. data/docs/SplitTransactionRequestBody.md +18 -0
  31. data/docs/SplitTransactionsResponseBody.md +18 -0
  32. data/docs/UpdateGoalRequest.md +38 -0
  33. data/docs/UpdateGoalRequestBody.md +18 -0
  34. data/lib/mx-platform-ruby/api/budgets_api.rb +434 -0
  35. data/lib/mx-platform-ruby/api/goals_api.rb +455 -0
  36. data/lib/mx-platform-ruby/api/mx_platform_api.rb +282 -4
  37. data/lib/mx-platform-ruby/models/budget_create_request.rb +269 -0
  38. data/lib/mx-platform-ruby/models/budget_create_request_body.rb +214 -0
  39. data/lib/mx-platform-ruby/models/budget_response.rb +373 -0
  40. data/lib/mx-platform-ruby/models/budget_response_body.rb +214 -0
  41. data/lib/mx-platform-ruby/models/budget_update_request.rb +235 -0
  42. data/lib/mx-platform-ruby/models/budget_update_request_body.rb +214 -0
  43. data/lib/mx-platform-ruby/models/credit_card_product.rb +17 -21
  44. data/lib/mx-platform-ruby/models/credit_card_product_response.rb +7 -7
  45. data/lib/mx-platform-ruby/models/goal_request.rb +350 -0
  46. data/lib/mx-platform-ruby/models/goal_request_body.rb +214 -0
  47. data/lib/mx-platform-ruby/models/goal_response.rb +364 -0
  48. data/lib/mx-platform-ruby/models/goal_response_body.rb +214 -0
  49. data/lib/mx-platform-ruby/models/goals_response.rb +363 -0
  50. data/lib/mx-platform-ruby/models/goals_response_body.rb +225 -0
  51. data/lib/mx-platform-ruby/models/monthly_cash_flow_profile_request.rb +225 -0
  52. data/lib/mx-platform-ruby/models/monthly_cash_flow_profile_request_body.rb +214 -0
  53. data/lib/mx-platform-ruby/models/monthly_cash_flow_response.rb +274 -0
  54. data/lib/mx-platform-ruby/models/monthly_cash_flow_response_body.rb +214 -0
  55. data/lib/mx-platform-ruby/models/reposition_request.rb +239 -0
  56. data/lib/mx-platform-ruby/models/reposition_request_body.rb +216 -0
  57. data/lib/mx-platform-ruby/models/reposition_response_body.rb +216 -0
  58. data/lib/mx-platform-ruby/models/reward_response.rb +10 -1
  59. data/lib/mx-platform-ruby/models/rewards_response.rb +10 -1
  60. data/lib/mx-platform-ruby/models/split_transaction_request.rb +252 -0
  61. data/lib/mx-platform-ruby/models/split_transaction_request_body.rb +221 -0
  62. data/lib/mx-platform-ruby/models/split_transactions_response_body.rb +216 -0
  63. data/lib/mx-platform-ruby/models/update_goal_request.rb +315 -0
  64. data/lib/mx-platform-ruby/models/update_goal_request_body.rb +214 -0
  65. data/lib/mx-platform-ruby/version.rb +1 -1
  66. data/lib/mx-platform-ruby.rb +26 -0
  67. data/openapi/config.yml +1 -1
  68. data/spec/api/budgets_api_spec.rb +112 -0
  69. data/spec/api/goals_api_spec.rb +115 -0
  70. data/spec/api/mx_platform_api_spec.rb +53 -2
  71. data/spec/models/budget_create_request_body_spec.rb +34 -0
  72. data/spec/models/budget_create_request_spec.rb +58 -0
  73. data/spec/models/budget_response_body_spec.rb +34 -0
  74. data/spec/models/budget_response_spec.rb +124 -0
  75. data/spec/models/budget_update_request_body_spec.rb +34 -0
  76. data/spec/models/budget_update_request_spec.rb +46 -0
  77. data/spec/models/credit_card_product_response_spec.rb +1 -1
  78. data/spec/models/credit_card_product_spec.rb +2 -2
  79. data/spec/models/goal_request_body_spec.rb +34 -0
  80. data/spec/models/goal_request_spec.rb +94 -0
  81. data/spec/models/goal_response_body_spec.rb +34 -0
  82. data/spec/models/goal_response_spec.rb +124 -0
  83. data/spec/models/goals_response_body_spec.rb +40 -0
  84. data/spec/models/goals_response_spec.rb +124 -0
  85. data/spec/models/monthly_cash_flow_profile_request_body_spec.rb +34 -0
  86. data/spec/models/monthly_cash_flow_profile_request_spec.rb +40 -0
  87. data/spec/models/monthly_cash_flow_response_body_spec.rb +34 -0
  88. data/spec/models/monthly_cash_flow_response_spec.rb +70 -0
  89. data/spec/models/reposition_request_body_spec.rb +34 -0
  90. data/spec/models/reposition_request_spec.rb +40 -0
  91. data/spec/models/reposition_response_body_spec.rb +34 -0
  92. data/spec/models/reward_response_spec.rb +6 -0
  93. data/spec/models/rewards_response_spec.rb +6 -0
  94. data/spec/models/split_transaction_request_body_spec.rb +34 -0
  95. data/spec/models/split_transaction_request_spec.rb +52 -0
  96. data/spec/models/split_transactions_response_body_spec.rb +34 -0
  97. data/spec/models/update_goal_request_body_spec.rb +34 -0
  98. data/spec/models/update_goal_request_spec.rb +94 -0
  99. metadata +228 -124
@@ -33,6 +33,8 @@ module MxPlatformRuby
33
33
 
34
34
  attr_accessor :unit_type
35
35
 
36
+ attr_accessor :updated_at
37
+
36
38
  attr_accessor :user_guid
37
39
 
38
40
  # Attribute mapping from ruby-style variable name to JSON key.
@@ -47,6 +49,7 @@ module MxPlatformRuby
47
49
  :'guid' => :'guid',
48
50
  :'member_guid' => :'member_guid',
49
51
  :'unit_type' => :'unit_type',
52
+ :'updated_at' => :'updated_at',
50
53
  :'user_guid' => :'user_guid'
51
54
  }
52
55
  end
@@ -68,6 +71,7 @@ module MxPlatformRuby
68
71
  :'guid' => :'String',
69
72
  :'member_guid' => :'String',
70
73
  :'unit_type' => :'String',
74
+ :'updated_at' => :'String',
71
75
  :'user_guid' => :'String'
72
76
  }
73
77
  end
@@ -129,6 +133,10 @@ module MxPlatformRuby
129
133
  self.unit_type = attributes[:'unit_type']
130
134
  end
131
135
 
136
+ if attributes.key?(:'updated_at')
137
+ self.updated_at = attributes[:'updated_at']
138
+ end
139
+
132
140
  if attributes.key?(:'user_guid')
133
141
  self.user_guid = attributes[:'user_guid']
134
142
  end
@@ -163,6 +171,7 @@ module MxPlatformRuby
163
171
  guid == o.guid &&
164
172
  member_guid == o.member_guid &&
165
173
  unit_type == o.unit_type &&
174
+ updated_at == o.updated_at &&
166
175
  user_guid == o.user_guid
167
176
  end
168
177
 
@@ -175,7 +184,7 @@ module MxPlatformRuby
175
184
  # Calculates hash code according to all attributes.
176
185
  # @return [Integer] Hash code
177
186
  def hash
178
- [account_guid, balance_type, balance, created_at, description, expires_on, guid, member_guid, unit_type, user_guid].hash
187
+ [account_guid, balance_type, balance, created_at, description, expires_on, guid, member_guid, unit_type, updated_at, user_guid].hash
179
188
  end
180
189
 
181
190
  # Builds the object from hash
@@ -33,6 +33,8 @@ module MxPlatformRuby
33
33
 
34
34
  attr_accessor :unit_type
35
35
 
36
+ attr_accessor :updated_at
37
+
36
38
  attr_accessor :user_guid
37
39
 
38
40
  # Attribute mapping from ruby-style variable name to JSON key.
@@ -47,6 +49,7 @@ module MxPlatformRuby
47
49
  :'guid' => :'guid',
48
50
  :'member_guid' => :'member_guid',
49
51
  :'unit_type' => :'unit_type',
52
+ :'updated_at' => :'updated_at',
50
53
  :'user_guid' => :'user_guid'
51
54
  }
52
55
  end
@@ -68,6 +71,7 @@ module MxPlatformRuby
68
71
  :'guid' => :'String',
69
72
  :'member_guid' => :'String',
70
73
  :'unit_type' => :'String',
74
+ :'updated_at' => :'String',
71
75
  :'user_guid' => :'String'
72
76
  }
73
77
  end
@@ -129,6 +133,10 @@ module MxPlatformRuby
129
133
  self.unit_type = attributes[:'unit_type']
130
134
  end
131
135
 
136
+ if attributes.key?(:'updated_at')
137
+ self.updated_at = attributes[:'updated_at']
138
+ end
139
+
132
140
  if attributes.key?(:'user_guid')
133
141
  self.user_guid = attributes[:'user_guid']
134
142
  end
@@ -163,6 +171,7 @@ module MxPlatformRuby
163
171
  guid == o.guid &&
164
172
  member_guid == o.member_guid &&
165
173
  unit_type == o.unit_type &&
174
+ updated_at == o.updated_at &&
166
175
  user_guid == o.user_guid
167
176
  end
168
177
 
@@ -175,7 +184,7 @@ module MxPlatformRuby
175
184
  # Calculates hash code according to all attributes.
176
185
  # @return [Integer] Hash code
177
186
  def hash
178
- [account_guid, balance_type, balance, created_at, description, expires_on, guid, member_guid, unit_type, user_guid].hash
187
+ [account_guid, balance_type, balance, created_at, description, expires_on, guid, member_guid, unit_type, updated_at, user_guid].hash
179
188
  end
180
189
 
181
190
  # Builds the object from hash
@@ -0,0 +1,252 @@
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: 7.0.1
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module MxPlatformRuby
17
+ class SplitTransactionRequest
18
+ # Amount of money you want to re-categorize.
19
+ attr_accessor :amount
20
+
21
+ # Description for the split transaction.
22
+ attr_accessor :description
23
+
24
+ # Unique identifier of the category.
25
+ attr_accessor :category_guid
26
+
27
+ # Memo for the split transaction
28
+ attr_accessor :memo
29
+
30
+ # Attribute mapping from ruby-style variable name to JSON key.
31
+ def self.attribute_map
32
+ {
33
+ :'amount' => :'amount',
34
+ :'description' => :'description',
35
+ :'category_guid' => :'category_guid',
36
+ :'memo' => :'memo'
37
+ }
38
+ end
39
+
40
+ # Returns all the JSON keys this model knows about
41
+ def self.acceptable_attributes
42
+ attribute_map.values
43
+ end
44
+
45
+ # Attribute type mapping.
46
+ def self.openapi_types
47
+ {
48
+ :'amount' => :'Float',
49
+ :'description' => :'String',
50
+ :'category_guid' => :'String',
51
+ :'memo' => :'String'
52
+ }
53
+ end
54
+
55
+ # List of attributes with nullable: true
56
+ def self.openapi_nullable
57
+ Set.new([
58
+ ])
59
+ end
60
+
61
+ # Initializes the object
62
+ # @param [Hash] attributes Model attributes in the form of hash
63
+ def initialize(attributes = {})
64
+ if (!attributes.is_a?(Hash))
65
+ fail ArgumentError, "The input argument (attributes) must be a hash in `MxPlatformRuby::SplitTransactionRequest` initialize method"
66
+ end
67
+
68
+ # check to see if the attribute exists and convert string to symbol for hash key
69
+ attributes = attributes.each_with_object({}) { |(k, v), h|
70
+ if (!self.class.attribute_map.key?(k.to_sym))
71
+ fail ArgumentError, "`#{k}` is not a valid attribute in `MxPlatformRuby::SplitTransactionRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
72
+ end
73
+ h[k.to_sym] = v
74
+ }
75
+
76
+ if attributes.key?(:'amount')
77
+ self.amount = attributes[:'amount']
78
+ else
79
+ self.amount = nil
80
+ end
81
+
82
+ if attributes.key?(:'description')
83
+ self.description = attributes[:'description']
84
+ end
85
+
86
+ if attributes.key?(:'category_guid')
87
+ self.category_guid = attributes[:'category_guid']
88
+ end
89
+
90
+ if attributes.key?(:'memo')
91
+ self.memo = attributes[:'memo']
92
+ end
93
+ end
94
+
95
+ # Show invalid properties with the reasons. Usually used together with valid?
96
+ # @return Array for valid properties with the reasons
97
+ def list_invalid_properties
98
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
99
+ invalid_properties = Array.new
100
+ if @amount.nil?
101
+ invalid_properties.push('invalid value for "amount", amount cannot be nil.')
102
+ end
103
+
104
+ invalid_properties
105
+ end
106
+
107
+ # Check to see if the all the properties in the model are valid
108
+ # @return true if the model is valid
109
+ def valid?
110
+ warn '[DEPRECATED] the `valid?` method is obsolete'
111
+ return false if @amount.nil?
112
+ true
113
+ end
114
+
115
+ # Checks equality by comparing each attribute.
116
+ # @param [Object] Object to be compared
117
+ def ==(o)
118
+ return true if self.equal?(o)
119
+ self.class == o.class &&
120
+ amount == o.amount &&
121
+ description == o.description &&
122
+ category_guid == o.category_guid &&
123
+ memo == o.memo
124
+ end
125
+
126
+ # @see the `==` method
127
+ # @param [Object] Object to be compared
128
+ def eql?(o)
129
+ self == o
130
+ end
131
+
132
+ # Calculates hash code according to all attributes.
133
+ # @return [Integer] Hash code
134
+ def hash
135
+ [amount, description, category_guid, memo].hash
136
+ end
137
+
138
+ # Builds the object from hash
139
+ # @param [Hash] attributes Model attributes in the form of hash
140
+ # @return [Object] Returns the model itself
141
+ def self.build_from_hash(attributes)
142
+ return nil unless attributes.is_a?(Hash)
143
+ attributes = attributes.transform_keys(&:to_sym)
144
+ transformed_hash = {}
145
+ openapi_types.each_pair do |key, type|
146
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
147
+ transformed_hash["#{key}"] = nil
148
+ elsif type =~ /\AArray<(.*)>/i
149
+ # check to ensure the input is an array given that the attribute
150
+ # is documented as an array but the input is not
151
+ if attributes[attribute_map[key]].is_a?(Array)
152
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
153
+ end
154
+ elsif !attributes[attribute_map[key]].nil?
155
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
156
+ end
157
+ end
158
+ new(transformed_hash)
159
+ end
160
+
161
+ # Deserializes the data based on type
162
+ # @param string type Data type
163
+ # @param string value Value to be deserialized
164
+ # @return [Object] Deserialized data
165
+ def self._deserialize(type, value)
166
+ case type.to_sym
167
+ when :Time
168
+ Time.parse(value)
169
+ when :Date
170
+ Date.parse(value)
171
+ when :String
172
+ value.to_s
173
+ when :Integer
174
+ value.to_i
175
+ when :Float
176
+ value.to_f
177
+ when :Boolean
178
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
179
+ true
180
+ else
181
+ false
182
+ end
183
+ when :Object
184
+ # generic object (usually a Hash), return directly
185
+ value
186
+ when /\AArray<(?<inner_type>.+)>\z/
187
+ inner_type = Regexp.last_match[:inner_type]
188
+ value.map { |v| _deserialize(inner_type, v) }
189
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
190
+ k_type = Regexp.last_match[:k_type]
191
+ v_type = Regexp.last_match[:v_type]
192
+ {}.tap do |hash|
193
+ value.each do |k, v|
194
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
195
+ end
196
+ end
197
+ else # model
198
+ # models (e.g. Pet) or oneOf
199
+ klass = MxPlatformRuby.const_get(type)
200
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
201
+ end
202
+ end
203
+
204
+ # Returns the string representation of the object
205
+ # @return [String] String presentation of the object
206
+ def to_s
207
+ to_hash.to_s
208
+ end
209
+
210
+ # to_body is an alias to to_hash (backward compatibility)
211
+ # @return [Hash] Returns the object in the form of hash
212
+ def to_body
213
+ to_hash
214
+ end
215
+
216
+ # Returns the object in the form of hash
217
+ # @return [Hash] Returns the object in the form of hash
218
+ def to_hash
219
+ hash = {}
220
+ self.class.attribute_map.each_pair do |attr, param|
221
+ value = self.send(attr)
222
+ if value.nil?
223
+ is_nullable = self.class.openapi_nullable.include?(attr)
224
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
225
+ end
226
+
227
+ hash[param] = _to_hash(value)
228
+ end
229
+ hash
230
+ end
231
+
232
+ # Outputs non-array value in the form of hash
233
+ # For object, use to_hash. Otherwise, just return the value
234
+ # @param [Object] value Any valid value
235
+ # @return [Hash] Returns the value in the form of hash
236
+ def _to_hash(value)
237
+ if value.is_a?(Array)
238
+ value.compact.map { |v| _to_hash(v) }
239
+ elsif value.is_a?(Hash)
240
+ {}.tap do |hash|
241
+ value.each { |k, v| hash[k] = _to_hash(v) }
242
+ end
243
+ elsif value.respond_to? :to_hash
244
+ value.to_hash
245
+ else
246
+ value
247
+ end
248
+ end
249
+
250
+ end
251
+
252
+ end
@@ -0,0 +1,221 @@
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: 7.0.1
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module MxPlatformRuby
17
+ class SplitTransactionRequestBody
18
+ attr_accessor :transactions
19
+
20
+ # Attribute mapping from ruby-style variable name to JSON key.
21
+ def self.attribute_map
22
+ {
23
+ :'transactions' => :'transactions'
24
+ }
25
+ end
26
+
27
+ # Returns all the JSON keys this model knows about
28
+ def self.acceptable_attributes
29
+ attribute_map.values
30
+ end
31
+
32
+ # Attribute type mapping.
33
+ def self.openapi_types
34
+ {
35
+ :'transactions' => :'SplitTransactionRequest'
36
+ }
37
+ end
38
+
39
+ # List of attributes with nullable: true
40
+ def self.openapi_nullable
41
+ Set.new([
42
+ ])
43
+ end
44
+
45
+ # Initializes the object
46
+ # @param [Hash] attributes Model attributes in the form of hash
47
+ def initialize(attributes = {})
48
+ if (!attributes.is_a?(Hash))
49
+ fail ArgumentError, "The input argument (attributes) must be a hash in `MxPlatformRuby::SplitTransactionRequestBody` initialize method"
50
+ end
51
+
52
+ # check to see if the attribute exists and convert string to symbol for hash key
53
+ attributes = attributes.each_with_object({}) { |(k, v), h|
54
+ if (!self.class.attribute_map.key?(k.to_sym))
55
+ fail ArgumentError, "`#{k}` is not a valid attribute in `MxPlatformRuby::SplitTransactionRequestBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
56
+ end
57
+ h[k.to_sym] = v
58
+ }
59
+
60
+ if attributes.key?(:'transactions')
61
+ self.transactions = attributes[:'transactions']
62
+ else
63
+ self.transactions = nil
64
+ end
65
+ end
66
+
67
+ # Show invalid properties with the reasons. Usually used together with valid?
68
+ # @return Array for valid properties with the reasons
69
+ def list_invalid_properties
70
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
71
+ invalid_properties = Array.new
72
+ if @transactions.nil?
73
+ invalid_properties.push('invalid value for "transactions", transactions cannot be nil.')
74
+ end
75
+
76
+ invalid_properties
77
+ end
78
+
79
+ # Check to see if the all the properties in the model are valid
80
+ # @return true if the model is valid
81
+ def valid?
82
+ warn '[DEPRECATED] the `valid?` method is obsolete'
83
+ return false if @transactions.nil?
84
+ true
85
+ end
86
+
87
+ # Checks equality by comparing each attribute.
88
+ # @param [Object] Object to be compared
89
+ def ==(o)
90
+ return true if self.equal?(o)
91
+ self.class == o.class &&
92
+ transactions == o.transactions
93
+ end
94
+
95
+ # @see the `==` method
96
+ # @param [Object] Object to be compared
97
+ def eql?(o)
98
+ self == o
99
+ end
100
+
101
+ # Calculates hash code according to all attributes.
102
+ # @return [Integer] Hash code
103
+ def hash
104
+ [transactions].hash
105
+ end
106
+
107
+ # Builds the object from hash
108
+ # @param [Hash] attributes Model attributes in the form of hash
109
+ # @return [Object] Returns the model itself
110
+ def self.build_from_hash(attributes)
111
+ return nil unless attributes.is_a?(Hash)
112
+ attributes = attributes.transform_keys(&:to_sym)
113
+ transformed_hash = {}
114
+ openapi_types.each_pair do |key, type|
115
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
116
+ transformed_hash["#{key}"] = nil
117
+ elsif type =~ /\AArray<(.*)>/i
118
+ # check to ensure the input is an array given that the attribute
119
+ # is documented as an array but the input is not
120
+ if attributes[attribute_map[key]].is_a?(Array)
121
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
122
+ end
123
+ elsif !attributes[attribute_map[key]].nil?
124
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
125
+ end
126
+ end
127
+ new(transformed_hash)
128
+ end
129
+
130
+ # Deserializes the data based on type
131
+ # @param string type Data type
132
+ # @param string value Value to be deserialized
133
+ # @return [Object] Deserialized data
134
+ def self._deserialize(type, value)
135
+ case type.to_sym
136
+ when :Time
137
+ Time.parse(value)
138
+ when :Date
139
+ Date.parse(value)
140
+ when :String
141
+ value.to_s
142
+ when :Integer
143
+ value.to_i
144
+ when :Float
145
+ value.to_f
146
+ when :Boolean
147
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
148
+ true
149
+ else
150
+ false
151
+ end
152
+ when :Object
153
+ # generic object (usually a Hash), return directly
154
+ value
155
+ when /\AArray<(?<inner_type>.+)>\z/
156
+ inner_type = Regexp.last_match[:inner_type]
157
+ value.map { |v| _deserialize(inner_type, v) }
158
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
159
+ k_type = Regexp.last_match[:k_type]
160
+ v_type = Regexp.last_match[:v_type]
161
+ {}.tap do |hash|
162
+ value.each do |k, v|
163
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
164
+ end
165
+ end
166
+ else # model
167
+ # models (e.g. Pet) or oneOf
168
+ klass = MxPlatformRuby.const_get(type)
169
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
170
+ end
171
+ end
172
+
173
+ # Returns the string representation of the object
174
+ # @return [String] String presentation of the object
175
+ def to_s
176
+ to_hash.to_s
177
+ end
178
+
179
+ # to_body is an alias to to_hash (backward compatibility)
180
+ # @return [Hash] Returns the object in the form of hash
181
+ def to_body
182
+ to_hash
183
+ end
184
+
185
+ # Returns the object in the form of hash
186
+ # @return [Hash] Returns the object in the form of hash
187
+ def to_hash
188
+ hash = {}
189
+ self.class.attribute_map.each_pair do |attr, param|
190
+ value = self.send(attr)
191
+ if value.nil?
192
+ is_nullable = self.class.openapi_nullable.include?(attr)
193
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
194
+ end
195
+
196
+ hash[param] = _to_hash(value)
197
+ end
198
+ hash
199
+ end
200
+
201
+ # Outputs non-array value in the form of hash
202
+ # For object, use to_hash. Otherwise, just return the value
203
+ # @param [Object] value Any valid value
204
+ # @return [Hash] Returns the value in the form of hash
205
+ def _to_hash(value)
206
+ if value.is_a?(Array)
207
+ value.compact.map { |v| _to_hash(v) }
208
+ elsif value.is_a?(Hash)
209
+ {}.tap do |hash|
210
+ value.each { |k, v| hash[k] = _to_hash(v) }
211
+ end
212
+ elsif value.respond_to? :to_hash
213
+ value.to_hash
214
+ else
215
+ value
216
+ end
217
+ end
218
+
219
+ end
220
+
221
+ end