mx-platform-ruby 0.21.0 → 0.22.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 +92 -0
- data/docs/MxPlatformApi.md +1586 -507
- data/docs/SpendingPlanAccountResponse.md +30 -0
- data/docs/SpendingPlanAccountsResponse.md +20 -0
- data/docs/SpendingPlanIterationItemCreateRequestBody.md +26 -0
- data/docs/SpendingPlanIterationItemResponse.md +40 -0
- data/docs/SpendingPlanIterationItemsResponseBody.md +20 -0
- data/docs/SpendingPlanIterationResponse.md +32 -0
- data/docs/SpendingPlanIterationsResponse.md +20 -0
- data/docs/SpendingPlanResponse.md +26 -0
- data/docs/SpendingPlansResponseBody.md +20 -0
- data/lib/mx-platform-ruby/api/mx_platform_api.rb +1062 -8
- data/lib/mx-platform-ruby/models/spending_plan_account_response.rb +272 -0
- data/lib/mx-platform-ruby/models/spending_plan_accounts_response.rb +229 -0
- data/lib/mx-platform-ruby/models/spending_plan_iteration_item_create_request_body.rb +259 -0
- data/lib/mx-platform-ruby/models/spending_plan_iteration_item_response.rb +330 -0
- data/lib/mx-platform-ruby/models/spending_plan_iteration_items_response_body.rb +229 -0
- data/lib/mx-platform-ruby/models/spending_plan_iteration_response.rb +289 -0
- data/lib/mx-platform-ruby/models/spending_plan_iterations_response.rb +229 -0
- data/lib/mx-platform-ruby/models/spending_plan_response.rb +259 -0
- data/lib/mx-platform-ruby/models/spending_plans_response_body.rb +229 -0
- data/lib/mx-platform-ruby/version.rb +1 -1
- data/lib/mx-platform-ruby.rb +9 -0
- data/openapi/config.yml +1 -1
- data/spec/api/mx_platform_api_spec.rb +204 -0
- data/spec/models/spending_plan_account_response_spec.rb +70 -0
- data/spec/models/spending_plan_accounts_response_spec.rb +40 -0
- data/spec/models/spending_plan_iteration_item_create_request_body_spec.rb +58 -0
- data/spec/models/spending_plan_iteration_item_response_spec.rb +100 -0
- data/spec/models/spending_plan_iteration_items_response_body_spec.rb +40 -0
- data/spec/models/spending_plan_iteration_response_spec.rb +76 -0
- data/spec/models/spending_plan_iterations_response_spec.rb +40 -0
- data/spec/models/spending_plan_response_spec.rb +58 -0
- data/spec/models/spending_plans_response_body_spec.rb +40 -0
- metadata +152 -115
@@ -0,0 +1,259 @@
|
|
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 SpendingPlanIterationItemCreateRequestBody
|
18
|
+
attr_accessor :category_guid
|
19
|
+
|
20
|
+
attr_accessor :item_type
|
21
|
+
|
22
|
+
attr_accessor :planned_amount
|
23
|
+
|
24
|
+
attr_accessor :scheduled_payment_guid
|
25
|
+
|
26
|
+
attr_accessor :top_level_category_guid
|
27
|
+
|
28
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
29
|
+
def self.attribute_map
|
30
|
+
{
|
31
|
+
:'category_guid' => :'category_guid',
|
32
|
+
:'item_type' => :'item_type',
|
33
|
+
:'planned_amount' => :'planned_amount',
|
34
|
+
:'scheduled_payment_guid' => :'scheduled_payment_guid',
|
35
|
+
:'top_level_category_guid' => :'top_level_category_guid'
|
36
|
+
}
|
37
|
+
end
|
38
|
+
|
39
|
+
# Returns all the JSON keys this model knows about
|
40
|
+
def self.acceptable_attributes
|
41
|
+
attribute_map.values
|
42
|
+
end
|
43
|
+
|
44
|
+
# Attribute type mapping.
|
45
|
+
def self.openapi_types
|
46
|
+
{
|
47
|
+
:'category_guid' => :'String',
|
48
|
+
:'item_type' => :'Float',
|
49
|
+
:'planned_amount' => :'Float',
|
50
|
+
:'scheduled_payment_guid' => :'String',
|
51
|
+
:'top_level_category_guid' => :'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::SpendingPlanIterationItemCreateRequestBody` 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::SpendingPlanIterationItemCreateRequestBody`. 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?(:'category_guid')
|
77
|
+
self.category_guid = attributes[:'category_guid']
|
78
|
+
end
|
79
|
+
|
80
|
+
if attributes.key?(:'item_type')
|
81
|
+
self.item_type = attributes[:'item_type']
|
82
|
+
end
|
83
|
+
|
84
|
+
if attributes.key?(:'planned_amount')
|
85
|
+
self.planned_amount = attributes[:'planned_amount']
|
86
|
+
end
|
87
|
+
|
88
|
+
if attributes.key?(:'scheduled_payment_guid')
|
89
|
+
self.scheduled_payment_guid = attributes[:'scheduled_payment_guid']
|
90
|
+
end
|
91
|
+
|
92
|
+
if attributes.key?(:'top_level_category_guid')
|
93
|
+
self.top_level_category_guid = attributes[:'top_level_category_guid']
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
98
|
+
# @return Array for valid properties with the reasons
|
99
|
+
def list_invalid_properties
|
100
|
+
invalid_properties = Array.new
|
101
|
+
if @planned_amount.nil?
|
102
|
+
invalid_properties.push('invalid value for "planned_amount", planned_amount cannot be nil.')
|
103
|
+
end
|
104
|
+
|
105
|
+
invalid_properties
|
106
|
+
end
|
107
|
+
|
108
|
+
# Check to see if the all the properties in the model are valid
|
109
|
+
# @return true if the model is valid
|
110
|
+
def valid?
|
111
|
+
return false if @planned_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
|
+
category_guid == o.category_guid &&
|
121
|
+
item_type == o.item_type &&
|
122
|
+
planned_amount == o.planned_amount &&
|
123
|
+
scheduled_payment_guid == o.scheduled_payment_guid &&
|
124
|
+
top_level_category_guid == o.top_level_category_guid
|
125
|
+
end
|
126
|
+
|
127
|
+
# @see the `==` method
|
128
|
+
# @param [Object] Object to be compared
|
129
|
+
def eql?(o)
|
130
|
+
self == o
|
131
|
+
end
|
132
|
+
|
133
|
+
# Calculates hash code according to all attributes.
|
134
|
+
# @return [Integer] Hash code
|
135
|
+
def hash
|
136
|
+
[category_guid, item_type, planned_amount, scheduled_payment_guid, top_level_category_guid].hash
|
137
|
+
end
|
138
|
+
|
139
|
+
# Builds the object from hash
|
140
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
141
|
+
# @return [Object] Returns the model itself
|
142
|
+
def self.build_from_hash(attributes)
|
143
|
+
new.build_from_hash(attributes)
|
144
|
+
end
|
145
|
+
|
146
|
+
# Builds the object from hash
|
147
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
148
|
+
# @return [Object] Returns the model itself
|
149
|
+
def build_from_hash(attributes)
|
150
|
+
return nil unless attributes.is_a?(Hash)
|
151
|
+
self.class.openapi_types.each_pair do |key, type|
|
152
|
+
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
153
|
+
self.send("#{key}=", nil)
|
154
|
+
elsif type =~ /\AArray<(.*)>/i
|
155
|
+
# check to ensure the input is an array given that the attribute
|
156
|
+
# is documented as an array but the input is not
|
157
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
158
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
159
|
+
end
|
160
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
161
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
self
|
166
|
+
end
|
167
|
+
|
168
|
+
# Deserializes the data based on type
|
169
|
+
# @param string type Data type
|
170
|
+
# @param string value Value to be deserialized
|
171
|
+
# @return [Object] Deserialized data
|
172
|
+
def _deserialize(type, value)
|
173
|
+
case type.to_sym
|
174
|
+
when :Time
|
175
|
+
Time.parse(value)
|
176
|
+
when :Date
|
177
|
+
Date.parse(value)
|
178
|
+
when :String
|
179
|
+
value.to_s
|
180
|
+
when :Integer
|
181
|
+
value.to_i
|
182
|
+
when :Float
|
183
|
+
value.to_f
|
184
|
+
when :Boolean
|
185
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
186
|
+
true
|
187
|
+
else
|
188
|
+
false
|
189
|
+
end
|
190
|
+
when :Object
|
191
|
+
# generic object (usually a Hash), return directly
|
192
|
+
value
|
193
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
194
|
+
inner_type = Regexp.last_match[:inner_type]
|
195
|
+
value.map { |v| _deserialize(inner_type, v) }
|
196
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
197
|
+
k_type = Regexp.last_match[:k_type]
|
198
|
+
v_type = Regexp.last_match[:v_type]
|
199
|
+
{}.tap do |hash|
|
200
|
+
value.each do |k, v|
|
201
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
202
|
+
end
|
203
|
+
end
|
204
|
+
else # model
|
205
|
+
# models (e.g. Pet) or oneOf
|
206
|
+
klass = MxPlatformRuby.const_get(type)
|
207
|
+
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
211
|
+
# Returns the string representation of the object
|
212
|
+
# @return [String] String presentation of the object
|
213
|
+
def to_s
|
214
|
+
to_hash.to_s
|
215
|
+
end
|
216
|
+
|
217
|
+
# to_body is an alias to to_hash (backward compatibility)
|
218
|
+
# @return [Hash] Returns the object in the form of hash
|
219
|
+
def to_body
|
220
|
+
to_hash
|
221
|
+
end
|
222
|
+
|
223
|
+
# Returns the object in the form of hash
|
224
|
+
# @return [Hash] Returns the object in the form of hash
|
225
|
+
def to_hash
|
226
|
+
hash = {}
|
227
|
+
self.class.attribute_map.each_pair do |attr, param|
|
228
|
+
value = self.send(attr)
|
229
|
+
if value.nil?
|
230
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
231
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
232
|
+
end
|
233
|
+
|
234
|
+
hash[param] = _to_hash(value)
|
235
|
+
end
|
236
|
+
hash
|
237
|
+
end
|
238
|
+
|
239
|
+
# Outputs non-array value in the form of hash
|
240
|
+
# For object, use to_hash. Otherwise, just return the value
|
241
|
+
# @param [Object] value Any valid value
|
242
|
+
# @return [Hash] Returns the value in the form of hash
|
243
|
+
def _to_hash(value)
|
244
|
+
if value.is_a?(Array)
|
245
|
+
value.compact.map { |v| _to_hash(v) }
|
246
|
+
elsif value.is_a?(Hash)
|
247
|
+
{}.tap do |hash|
|
248
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
249
|
+
end
|
250
|
+
elsif value.respond_to? :to_hash
|
251
|
+
value.to_hash
|
252
|
+
else
|
253
|
+
value
|
254
|
+
end
|
255
|
+
end
|
256
|
+
|
257
|
+
end
|
258
|
+
|
259
|
+
end
|
@@ -0,0 +1,330 @@
|
|
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 SpendingPlanIterationItemResponse
|
18
|
+
attr_accessor :actual_amount
|
19
|
+
|
20
|
+
attr_accessor :category_guid
|
21
|
+
|
22
|
+
attr_accessor :created_at
|
23
|
+
|
24
|
+
attr_accessor :guid
|
25
|
+
|
26
|
+
attr_accessor :item_type
|
27
|
+
|
28
|
+
attr_accessor :planned_amount
|
29
|
+
|
30
|
+
attr_accessor :scheduled_payment_guid
|
31
|
+
|
32
|
+
attr_accessor :spending_plan_iteration_guid
|
33
|
+
|
34
|
+
attr_accessor :top_level_category_guid
|
35
|
+
|
36
|
+
attr_accessor :transaction_guids
|
37
|
+
|
38
|
+
attr_accessor :updated_at
|
39
|
+
|
40
|
+
attr_accessor :user_guid
|
41
|
+
|
42
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
43
|
+
def self.attribute_map
|
44
|
+
{
|
45
|
+
:'actual_amount' => :'actual_amount',
|
46
|
+
:'category_guid' => :'category_guid',
|
47
|
+
:'created_at' => :'created_at',
|
48
|
+
:'guid' => :'guid',
|
49
|
+
:'item_type' => :'item_type',
|
50
|
+
:'planned_amount' => :'planned_amount',
|
51
|
+
:'scheduled_payment_guid' => :'scheduled_payment_guid',
|
52
|
+
:'spending_plan_iteration_guid' => :'spending_plan_iteration_guid',
|
53
|
+
:'top_level_category_guid' => :'top_level_category_guid',
|
54
|
+
:'transaction_guids' => :'transaction_guids',
|
55
|
+
:'updated_at' => :'updated_at',
|
56
|
+
:'user_guid' => :'user_guid'
|
57
|
+
}
|
58
|
+
end
|
59
|
+
|
60
|
+
# Returns all the JSON keys this model knows about
|
61
|
+
def self.acceptable_attributes
|
62
|
+
attribute_map.values
|
63
|
+
end
|
64
|
+
|
65
|
+
# Attribute type mapping.
|
66
|
+
def self.openapi_types
|
67
|
+
{
|
68
|
+
:'actual_amount' => :'Float',
|
69
|
+
:'category_guid' => :'String',
|
70
|
+
:'created_at' => :'String',
|
71
|
+
:'guid' => :'String',
|
72
|
+
:'item_type' => :'String',
|
73
|
+
:'planned_amount' => :'Float',
|
74
|
+
:'scheduled_payment_guid' => :'String',
|
75
|
+
:'spending_plan_iteration_guid' => :'String',
|
76
|
+
:'top_level_category_guid' => :'String',
|
77
|
+
:'transaction_guids' => :'Array<String>',
|
78
|
+
:'updated_at' => :'String',
|
79
|
+
:'user_guid' => :'String'
|
80
|
+
}
|
81
|
+
end
|
82
|
+
|
83
|
+
# List of attributes with nullable: true
|
84
|
+
def self.openapi_nullable
|
85
|
+
Set.new([
|
86
|
+
:'actual_amount',
|
87
|
+
:'category_guid',
|
88
|
+
:'created_at',
|
89
|
+
:'guid',
|
90
|
+
:'item_type',
|
91
|
+
:'planned_amount',
|
92
|
+
:'scheduled_payment_guid',
|
93
|
+
:'spending_plan_iteration_guid',
|
94
|
+
:'top_level_category_guid',
|
95
|
+
:'updated_at',
|
96
|
+
:'user_guid'
|
97
|
+
])
|
98
|
+
end
|
99
|
+
|
100
|
+
# Initializes the object
|
101
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
102
|
+
def initialize(attributes = {})
|
103
|
+
if (!attributes.is_a?(Hash))
|
104
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `MxPlatformRuby::SpendingPlanIterationItemResponse` initialize method"
|
105
|
+
end
|
106
|
+
|
107
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
108
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
109
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
110
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `MxPlatformRuby::SpendingPlanIterationItemResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
111
|
+
end
|
112
|
+
h[k.to_sym] = v
|
113
|
+
}
|
114
|
+
|
115
|
+
if attributes.key?(:'actual_amount')
|
116
|
+
self.actual_amount = attributes[:'actual_amount']
|
117
|
+
end
|
118
|
+
|
119
|
+
if attributes.key?(:'category_guid')
|
120
|
+
self.category_guid = attributes[:'category_guid']
|
121
|
+
end
|
122
|
+
|
123
|
+
if attributes.key?(:'created_at')
|
124
|
+
self.created_at = attributes[:'created_at']
|
125
|
+
end
|
126
|
+
|
127
|
+
if attributes.key?(:'guid')
|
128
|
+
self.guid = attributes[:'guid']
|
129
|
+
end
|
130
|
+
|
131
|
+
if attributes.key?(:'item_type')
|
132
|
+
self.item_type = attributes[:'item_type']
|
133
|
+
end
|
134
|
+
|
135
|
+
if attributes.key?(:'planned_amount')
|
136
|
+
self.planned_amount = attributes[:'planned_amount']
|
137
|
+
end
|
138
|
+
|
139
|
+
if attributes.key?(:'scheduled_payment_guid')
|
140
|
+
self.scheduled_payment_guid = attributes[:'scheduled_payment_guid']
|
141
|
+
end
|
142
|
+
|
143
|
+
if attributes.key?(:'spending_plan_iteration_guid')
|
144
|
+
self.spending_plan_iteration_guid = attributes[:'spending_plan_iteration_guid']
|
145
|
+
end
|
146
|
+
|
147
|
+
if attributes.key?(:'top_level_category_guid')
|
148
|
+
self.top_level_category_guid = attributes[:'top_level_category_guid']
|
149
|
+
end
|
150
|
+
|
151
|
+
if attributes.key?(:'transaction_guids')
|
152
|
+
if (value = attributes[:'transaction_guids']).is_a?(Array)
|
153
|
+
self.transaction_guids = value
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
if attributes.key?(:'updated_at')
|
158
|
+
self.updated_at = attributes[:'updated_at']
|
159
|
+
end
|
160
|
+
|
161
|
+
if attributes.key?(:'user_guid')
|
162
|
+
self.user_guid = attributes[:'user_guid']
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
167
|
+
# @return Array for valid properties with the reasons
|
168
|
+
def list_invalid_properties
|
169
|
+
invalid_properties = Array.new
|
170
|
+
invalid_properties
|
171
|
+
end
|
172
|
+
|
173
|
+
# Check to see if the all the properties in the model are valid
|
174
|
+
# @return true if the model is valid
|
175
|
+
def valid?
|
176
|
+
true
|
177
|
+
end
|
178
|
+
|
179
|
+
# Checks equality by comparing each attribute.
|
180
|
+
# @param [Object] Object to be compared
|
181
|
+
def ==(o)
|
182
|
+
return true if self.equal?(o)
|
183
|
+
self.class == o.class &&
|
184
|
+
actual_amount == o.actual_amount &&
|
185
|
+
category_guid == o.category_guid &&
|
186
|
+
created_at == o.created_at &&
|
187
|
+
guid == o.guid &&
|
188
|
+
item_type == o.item_type &&
|
189
|
+
planned_amount == o.planned_amount &&
|
190
|
+
scheduled_payment_guid == o.scheduled_payment_guid &&
|
191
|
+
spending_plan_iteration_guid == o.spending_plan_iteration_guid &&
|
192
|
+
top_level_category_guid == o.top_level_category_guid &&
|
193
|
+
transaction_guids == o.transaction_guids &&
|
194
|
+
updated_at == o.updated_at &&
|
195
|
+
user_guid == o.user_guid
|
196
|
+
end
|
197
|
+
|
198
|
+
# @see the `==` method
|
199
|
+
# @param [Object] Object to be compared
|
200
|
+
def eql?(o)
|
201
|
+
self == o
|
202
|
+
end
|
203
|
+
|
204
|
+
# Calculates hash code according to all attributes.
|
205
|
+
# @return [Integer] Hash code
|
206
|
+
def hash
|
207
|
+
[actual_amount, category_guid, created_at, guid, item_type, planned_amount, scheduled_payment_guid, spending_plan_iteration_guid, top_level_category_guid, transaction_guids, updated_at, user_guid].hash
|
208
|
+
end
|
209
|
+
|
210
|
+
# Builds the object from hash
|
211
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
212
|
+
# @return [Object] Returns the model itself
|
213
|
+
def self.build_from_hash(attributes)
|
214
|
+
new.build_from_hash(attributes)
|
215
|
+
end
|
216
|
+
|
217
|
+
# Builds the object from hash
|
218
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
219
|
+
# @return [Object] Returns the model itself
|
220
|
+
def build_from_hash(attributes)
|
221
|
+
return nil unless attributes.is_a?(Hash)
|
222
|
+
self.class.openapi_types.each_pair do |key, type|
|
223
|
+
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
224
|
+
self.send("#{key}=", nil)
|
225
|
+
elsif type =~ /\AArray<(.*)>/i
|
226
|
+
# check to ensure the input is an array given that the attribute
|
227
|
+
# is documented as an array but the input is not
|
228
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
229
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
230
|
+
end
|
231
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
232
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
233
|
+
end
|
234
|
+
end
|
235
|
+
|
236
|
+
self
|
237
|
+
end
|
238
|
+
|
239
|
+
# Deserializes the data based on type
|
240
|
+
# @param string type Data type
|
241
|
+
# @param string value Value to be deserialized
|
242
|
+
# @return [Object] Deserialized data
|
243
|
+
def _deserialize(type, value)
|
244
|
+
case type.to_sym
|
245
|
+
when :Time
|
246
|
+
Time.parse(value)
|
247
|
+
when :Date
|
248
|
+
Date.parse(value)
|
249
|
+
when :String
|
250
|
+
value.to_s
|
251
|
+
when :Integer
|
252
|
+
value.to_i
|
253
|
+
when :Float
|
254
|
+
value.to_f
|
255
|
+
when :Boolean
|
256
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
257
|
+
true
|
258
|
+
else
|
259
|
+
false
|
260
|
+
end
|
261
|
+
when :Object
|
262
|
+
# generic object (usually a Hash), return directly
|
263
|
+
value
|
264
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
265
|
+
inner_type = Regexp.last_match[:inner_type]
|
266
|
+
value.map { |v| _deserialize(inner_type, v) }
|
267
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
268
|
+
k_type = Regexp.last_match[:k_type]
|
269
|
+
v_type = Regexp.last_match[:v_type]
|
270
|
+
{}.tap do |hash|
|
271
|
+
value.each do |k, v|
|
272
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
273
|
+
end
|
274
|
+
end
|
275
|
+
else # model
|
276
|
+
# models (e.g. Pet) or oneOf
|
277
|
+
klass = MxPlatformRuby.const_get(type)
|
278
|
+
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
279
|
+
end
|
280
|
+
end
|
281
|
+
|
282
|
+
# Returns the string representation of the object
|
283
|
+
# @return [String] String presentation of the object
|
284
|
+
def to_s
|
285
|
+
to_hash.to_s
|
286
|
+
end
|
287
|
+
|
288
|
+
# to_body is an alias to to_hash (backward compatibility)
|
289
|
+
# @return [Hash] Returns the object in the form of hash
|
290
|
+
def to_body
|
291
|
+
to_hash
|
292
|
+
end
|
293
|
+
|
294
|
+
# Returns the object in the form of hash
|
295
|
+
# @return [Hash] Returns the object in the form of hash
|
296
|
+
def to_hash
|
297
|
+
hash = {}
|
298
|
+
self.class.attribute_map.each_pair do |attr, param|
|
299
|
+
value = self.send(attr)
|
300
|
+
if value.nil?
|
301
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
302
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
303
|
+
end
|
304
|
+
|
305
|
+
hash[param] = _to_hash(value)
|
306
|
+
end
|
307
|
+
hash
|
308
|
+
end
|
309
|
+
|
310
|
+
# Outputs non-array value in the form of hash
|
311
|
+
# For object, use to_hash. Otherwise, just return the value
|
312
|
+
# @param [Object] value Any valid value
|
313
|
+
# @return [Hash] Returns the value in the form of hash
|
314
|
+
def _to_hash(value)
|
315
|
+
if value.is_a?(Array)
|
316
|
+
value.compact.map { |v| _to_hash(v) }
|
317
|
+
elsif value.is_a?(Hash)
|
318
|
+
{}.tap do |hash|
|
319
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
320
|
+
end
|
321
|
+
elsif value.respond_to? :to_hash
|
322
|
+
value.to_hash
|
323
|
+
else
|
324
|
+
value
|
325
|
+
end
|
326
|
+
end
|
327
|
+
|
328
|
+
end
|
329
|
+
|
330
|
+
end
|