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