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
@@ -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 BudgetResponseBody
18
+ attr_accessor :budget
19
+
20
+ # Attribute mapping from ruby-style variable name to JSON key.
21
+ def self.attribute_map
22
+ {
23
+ :'budget' => :'budget'
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
+ :'budget' => :'BudgetResponse'
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::BudgetResponseBody` 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::BudgetResponseBody`. 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?(:'budget')
61
+ self.budget = attributes[:'budget']
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
+ budget == o.budget
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
+ [budget].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
@@ -0,0 +1,235 @@
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 BudgetUpdateRequest
18
+ # Amount of the budget.
19
+ attr_accessor :amount
20
+
21
+ # Additional information a partner can store on the budget.
22
+ attr_accessor :metadata
23
+
24
+ # When set to true, this parameter will prevent a webhook from being triggered by the request.
25
+ attr_accessor :skip_webhook
26
+
27
+ # Attribute mapping from ruby-style variable name to JSON key.
28
+ def self.attribute_map
29
+ {
30
+ :'amount' => :'amount',
31
+ :'metadata' => :'metadata',
32
+ :'skip_webhook' => :'skip_webhook'
33
+ }
34
+ end
35
+
36
+ # Returns all the JSON keys this model knows about
37
+ def self.acceptable_attributes
38
+ attribute_map.values
39
+ end
40
+
41
+ # Attribute type mapping.
42
+ def self.openapi_types
43
+ {
44
+ :'amount' => :'Integer',
45
+ :'metadata' => :'String',
46
+ :'skip_webhook' => :'Boolean'
47
+ }
48
+ end
49
+
50
+ # List of attributes with nullable: true
51
+ def self.openapi_nullable
52
+ Set.new([
53
+ ])
54
+ end
55
+
56
+ # Initializes the object
57
+ # @param [Hash] attributes Model attributes in the form of hash
58
+ def initialize(attributes = {})
59
+ if (!attributes.is_a?(Hash))
60
+ fail ArgumentError, "The input argument (attributes) must be a hash in `MxPlatformRuby::BudgetUpdateRequest` initialize method"
61
+ end
62
+
63
+ # check to see if the attribute exists and convert string to symbol for hash key
64
+ attributes = attributes.each_with_object({}) { |(k, v), h|
65
+ if (!self.class.attribute_map.key?(k.to_sym))
66
+ fail ArgumentError, "`#{k}` is not a valid attribute in `MxPlatformRuby::BudgetUpdateRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
67
+ end
68
+ h[k.to_sym] = v
69
+ }
70
+
71
+ if attributes.key?(:'amount')
72
+ self.amount = attributes[:'amount']
73
+ end
74
+
75
+ if attributes.key?(:'metadata')
76
+ self.metadata = attributes[:'metadata']
77
+ end
78
+
79
+ if attributes.key?(:'skip_webhook')
80
+ self.skip_webhook = attributes[:'skip_webhook']
81
+ end
82
+ end
83
+
84
+ # Show invalid properties with the reasons. Usually used together with valid?
85
+ # @return Array for valid properties with the reasons
86
+ def list_invalid_properties
87
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
88
+ invalid_properties = Array.new
89
+ invalid_properties
90
+ end
91
+
92
+ # Check to see if the all the properties in the model are valid
93
+ # @return true if the model is valid
94
+ def valid?
95
+ warn '[DEPRECATED] the `valid?` method is obsolete'
96
+ true
97
+ end
98
+
99
+ # Checks equality by comparing each attribute.
100
+ # @param [Object] Object to be compared
101
+ def ==(o)
102
+ return true if self.equal?(o)
103
+ self.class == o.class &&
104
+ amount == o.amount &&
105
+ metadata == o.metadata &&
106
+ skip_webhook == o.skip_webhook
107
+ end
108
+
109
+ # @see the `==` method
110
+ # @param [Object] Object to be compared
111
+ def eql?(o)
112
+ self == o
113
+ end
114
+
115
+ # Calculates hash code according to all attributes.
116
+ # @return [Integer] Hash code
117
+ def hash
118
+ [amount, metadata, skip_webhook].hash
119
+ end
120
+
121
+ # Builds the object from hash
122
+ # @param [Hash] attributes Model attributes in the form of hash
123
+ # @return [Object] Returns the model itself
124
+ def self.build_from_hash(attributes)
125
+ return nil unless attributes.is_a?(Hash)
126
+ attributes = attributes.transform_keys(&:to_sym)
127
+ transformed_hash = {}
128
+ openapi_types.each_pair do |key, type|
129
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
130
+ transformed_hash["#{key}"] = nil
131
+ elsif type =~ /\AArray<(.*)>/i
132
+ # check to ensure the input is an array given that the attribute
133
+ # is documented as an array but the input is not
134
+ if attributes[attribute_map[key]].is_a?(Array)
135
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
136
+ end
137
+ elsif !attributes[attribute_map[key]].nil?
138
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
139
+ end
140
+ end
141
+ new(transformed_hash)
142
+ end
143
+
144
+ # Deserializes the data based on type
145
+ # @param string type Data type
146
+ # @param string value Value to be deserialized
147
+ # @return [Object] Deserialized data
148
+ def self._deserialize(type, value)
149
+ case type.to_sym
150
+ when :Time
151
+ Time.parse(value)
152
+ when :Date
153
+ Date.parse(value)
154
+ when :String
155
+ value.to_s
156
+ when :Integer
157
+ value.to_i
158
+ when :Float
159
+ value.to_f
160
+ when :Boolean
161
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
162
+ true
163
+ else
164
+ false
165
+ end
166
+ when :Object
167
+ # generic object (usually a Hash), return directly
168
+ value
169
+ when /\AArray<(?<inner_type>.+)>\z/
170
+ inner_type = Regexp.last_match[:inner_type]
171
+ value.map { |v| _deserialize(inner_type, v) }
172
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
173
+ k_type = Regexp.last_match[:k_type]
174
+ v_type = Regexp.last_match[:v_type]
175
+ {}.tap do |hash|
176
+ value.each do |k, v|
177
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
178
+ end
179
+ end
180
+ else # model
181
+ # models (e.g. Pet) or oneOf
182
+ klass = MxPlatformRuby.const_get(type)
183
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
184
+ end
185
+ end
186
+
187
+ # Returns the string representation of the object
188
+ # @return [String] String presentation of the object
189
+ def to_s
190
+ to_hash.to_s
191
+ end
192
+
193
+ # to_body is an alias to to_hash (backward compatibility)
194
+ # @return [Hash] Returns the object in the form of hash
195
+ def to_body
196
+ to_hash
197
+ end
198
+
199
+ # Returns the object in the form of hash
200
+ # @return [Hash] Returns the object in the form of hash
201
+ def to_hash
202
+ hash = {}
203
+ self.class.attribute_map.each_pair do |attr, param|
204
+ value = self.send(attr)
205
+ if value.nil?
206
+ is_nullable = self.class.openapi_nullable.include?(attr)
207
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
208
+ end
209
+
210
+ hash[param] = _to_hash(value)
211
+ end
212
+ hash
213
+ end
214
+
215
+ # Outputs non-array value in the form of hash
216
+ # For object, use to_hash. Otherwise, just return the value
217
+ # @param [Object] value Any valid value
218
+ # @return [Hash] Returns the value in the form of hash
219
+ def _to_hash(value)
220
+ if value.is_a?(Array)
221
+ value.compact.map { |v| _to_hash(v) }
222
+ elsif value.is_a?(Hash)
223
+ {}.tap do |hash|
224
+ value.each { |k, v| hash[k] = _to_hash(v) }
225
+ end
226
+ elsif value.respond_to? :to_hash
227
+ value.to_hash
228
+ else
229
+ value
230
+ end
231
+ end
232
+
233
+ end
234
+
235
+ 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 BudgetUpdateRequestBody
18
+ attr_accessor :budget
19
+
20
+ # Attribute mapping from ruby-style variable name to JSON key.
21
+ def self.attribute_map
22
+ {
23
+ :'budget' => :'budget'
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
+ :'budget' => :'BudgetUpdateRequest'
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::BudgetUpdateRequestBody` 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::BudgetUpdateRequestBody`. 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?(:'budget')
61
+ self.budget = attributes[:'budget']
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
+ budget == o.budget
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
+ [budget].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