fuse_client 1.0.33 → 1.0.34

Sign up to get free protection for your applications and to get access to all the features.
Files changed (126) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +2 -2
  3. data/README.md +6 -1
  4. data/docs/AddAccountEventsRequest.md +18 -0
  5. data/docs/AddAccountEventsRequestEventsInner.md +51 -0
  6. data/docs/{AddSpendPowerTransactionResponse.md → AddAccountEventsResponse.md} +2 -2
  7. data/docs/AssetReportTransaction.md +1 -1
  8. data/docs/CreateSessionRequest.md +1 -1
  9. data/docs/CreateSpendPowerCustomizationRequest.md +22 -0
  10. data/docs/CreateSpendPowerRequest.md +5 -5
  11. data/docs/CreateSpendPowerResponse.md +1 -1
  12. data/docs/DeleteSpendPowerResponse.md +2 -2
  13. data/docs/EnrichTransactionsRequest.md +18 -0
  14. data/docs/EnrichTransactionsResponse.md +18 -0
  15. data/docs/EnrichedTransaction.md +46 -0
  16. data/docs/EnrichedTransactionLogo.md +18 -0
  17. data/docs/EvalSpendPowerRequest.md +22 -0
  18. data/docs/EvalSpendPowerRequestEventsInner.md +20 -0
  19. data/docs/EvalSpendPowerResponse.md +20 -0
  20. data/docs/ExternalTransactionEvent.md +36 -0
  21. data/docs/ExternalTransactionEventStatus.md +15 -0
  22. data/docs/FinancialConnectionsAccountBalance.md +2 -2
  23. data/docs/FinancialConnectionsAccountCachedBalance.md +2 -2
  24. data/docs/FinancialConnectionsHolding.md +3 -3
  25. data/docs/FinancialConnectionsInvestmentSecurity.md +1 -1
  26. data/docs/FinancialConnectionsInvestmentTransaction.md +5 -3
  27. data/docs/FinancialConnectionsInvestmentTransactionSubtype.md +15 -0
  28. data/docs/FuseApi.md +193 -35
  29. data/docs/GetFinanceScoreResponse.md +20 -0
  30. data/docs/GetInvestmentTransactionsRequest.md +4 -4
  31. data/docs/GetSpendPowerCustomizationResponse.md +20 -0
  32. data/docs/InAppTransactionEvent.md +34 -0
  33. data/docs/InAppTransactionEventStatus.md +15 -0
  34. data/docs/SpendPower.md +6 -6
  35. data/docs/SpendPowerApi.md +87 -44
  36. data/docs/SpendPowerCustomization.md +5 -3
  37. data/docs/SpendPowerTimeFrame.md +15 -0
  38. data/docs/Transaction.md +1 -1
  39. data/docs/TransactionCategory.md +20 -0
  40. data/docs/TransactionCategoryDetailed.md +15 -0
  41. data/docs/TransactionCategoryPrimary.md +15 -0
  42. data/docs/TransactionEventType.md +15 -0
  43. data/docs/TransactionToEnrich.md +26 -0
  44. data/docs/UpdateSpendPowerCustomizationRequest.md +22 -0
  45. data/docs/UpdatedBalanceEvent.md +26 -0
  46. data/lib/fuse_client/api/fuse_api.rb +176 -31
  47. data/lib/fuse_client/api/spend_power_api.rb +78 -52
  48. data/lib/fuse_client/models/add_account_events_request.rb +254 -0
  49. data/lib/fuse_client/models/add_account_events_request_events_inner.rb +106 -0
  50. data/lib/fuse_client/models/{add_spend_power_transaction_response.rb → add_account_events_response.rb} +3 -3
  51. data/lib/fuse_client/models/asset_report_transaction.rb +1 -1
  52. data/lib/fuse_client/models/country_code.rb +2 -1
  53. data/lib/fuse_client/models/create_session_request.rb +1 -1
  54. data/lib/fuse_client/models/create_spend_power_customization_request.rb +314 -0
  55. data/lib/fuse_client/models/create_spend_power_request.rb +22 -22
  56. data/lib/fuse_client/models/create_spend_power_response.rb +1 -1
  57. data/lib/fuse_client/models/delete_spend_power_response.rb +11 -10
  58. data/lib/fuse_client/models/enrich_transactions_request.rb +226 -0
  59. data/lib/fuse_client/models/enrich_transactions_response.rb +222 -0
  60. data/lib/fuse_client/models/enriched_transaction.rb +397 -0
  61. data/lib/fuse_client/models/enriched_transaction_logo.rb +220 -0
  62. data/lib/fuse_client/models/eval_spend_power_request.rb +296 -0
  63. data/lib/fuse_client/models/eval_spend_power_request_events_inner.rb +239 -0
  64. data/lib/fuse_client/models/eval_spend_power_response.rb +230 -0
  65. data/lib/fuse_client/models/external_transaction_event.rb +384 -0
  66. data/lib/fuse_client/models/external_transaction_event_status.rb +40 -0
  67. data/lib/fuse_client/models/financial_connections_account_balance.rb +2 -2
  68. data/lib/fuse_client/models/financial_connections_account_cached_balance.rb +2 -2
  69. data/lib/fuse_client/models/financial_connections_holding.rb +3 -3
  70. data/lib/fuse_client/models/financial_connections_investment_security.rb +1 -1
  71. data/lib/fuse_client/models/financial_connections_investment_transaction.rb +13 -4
  72. data/lib/fuse_client/models/financial_connections_investment_transaction_subtype.rb +87 -0
  73. data/lib/fuse_client/models/fuse_api_error_code.rb +3 -1
  74. data/lib/fuse_client/models/get_finance_score_response.rb +240 -0
  75. data/lib/fuse_client/models/get_investment_transactions_request.rb +37 -9
  76. data/lib/fuse_client/models/get_spend_power_customization_response.rb +239 -0
  77. data/lib/fuse_client/models/in_app_transaction_event.rb +364 -0
  78. data/lib/fuse_client/models/in_app_transaction_event_status.rb +41 -0
  79. data/lib/fuse_client/models/spend_power.rb +18 -18
  80. data/lib/fuse_client/models/spend_power_customization.rb +54 -14
  81. data/lib/fuse_client/models/spend_power_time_frame.rb +41 -0
  82. data/lib/fuse_client/models/transaction.rb +1 -1
  83. data/lib/fuse_client/models/transaction_category.rb +260 -0
  84. data/lib/fuse_client/models/transaction_category_detailed.rb +135 -0
  85. data/lib/fuse_client/models/transaction_category_primary.rb +59 -0
  86. data/lib/fuse_client/models/transaction_event_type.rb +65 -0
  87. data/lib/fuse_client/models/{add_spend_power_transaction_request.rb → transaction_to_enrich.rb} +47 -27
  88. data/lib/fuse_client/models/update_spend_power_customization_request.rb +291 -0
  89. data/lib/fuse_client/models/updated_balance_event.rb +308 -0
  90. data/lib/fuse_client/version.rb +1 -1
  91. data/lib/fuse_client.rb +26 -2
  92. data/spec/api/fuse_api_spec.rb +33 -7
  93. data/spec/api/spend_power_api_spec.rb +14 -17
  94. data/spec/models/add_account_events_request_events_inner_spec.rb +31 -0
  95. data/spec/models/add_account_events_request_spec.rb +34 -0
  96. data/spec/models/{add_spend_power_transaction_response_spec.rb → add_account_events_response_spec.rb} +6 -6
  97. data/spec/models/create_spend_power_customization_request_spec.rb +46 -0
  98. data/spec/models/create_spend_power_request_spec.rb +2 -2
  99. data/spec/models/delete_spend_power_response_spec.rb +1 -1
  100. data/spec/models/enrich_transactions_request_spec.rb +34 -0
  101. data/spec/models/enrich_transactions_response_spec.rb +34 -0
  102. data/spec/models/enriched_transaction_logo_spec.rb +34 -0
  103. data/spec/models/enriched_transaction_spec.rb +122 -0
  104. data/spec/models/eval_spend_power_request_events_inner_spec.rb +40 -0
  105. data/spec/models/eval_spend_power_request_spec.rb +46 -0
  106. data/spec/models/eval_spend_power_response_spec.rb +40 -0
  107. data/spec/models/external_transaction_event_spec.rb +92 -0
  108. data/spec/models/external_transaction_event_status_spec.rb +28 -0
  109. data/spec/models/financial_connections_investment_transaction_spec.rb +6 -0
  110. data/spec/models/financial_connections_investment_transaction_subtype_spec.rb +28 -0
  111. data/spec/models/get_finance_score_response_spec.rb +40 -0
  112. data/spec/models/get_spend_power_customization_response_spec.rb +40 -0
  113. data/spec/models/in_app_transaction_event_spec.rb +86 -0
  114. data/spec/models/in_app_transaction_event_status_spec.rb +28 -0
  115. data/spec/models/spend_power_customization_spec.rb +6 -4
  116. data/spec/models/spend_power_spec.rb +1 -1
  117. data/spec/models/spend_power_time_frame_spec.rb +28 -0
  118. data/spec/models/transaction_category_detailed_spec.rb +28 -0
  119. data/spec/models/transaction_category_primary_spec.rb +28 -0
  120. data/spec/models/transaction_category_spec.rb +40 -0
  121. data/spec/models/transaction_event_type_spec.rb +28 -0
  122. data/spec/models/{add_spend_power_transaction_request_spec.rb → transaction_to_enrich_spec.rb} +23 -11
  123. data/spec/models/update_spend_power_customization_request_spec.rb +46 -0
  124. data/spec/models/updated_balance_event_spec.rb +62 -0
  125. metadata +106 -10
  126. data/docs/AddSpendPowerTransactionRequest.md +0 -22
@@ -0,0 +1,296 @@
1
+ =begin
2
+ #Fuse
3
+
4
+ #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 6.5.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module FuseClient
17
+ class EvalSpendPowerRequest
18
+ # The size of the window for training
19
+ attr_accessor :window_size
20
+
21
+ attr_accessor :time_frame
22
+
23
+ attr_accessor :events
24
+
25
+ class EnumAttributeValidator
26
+ attr_reader :datatype
27
+ attr_reader :allowable_values
28
+
29
+ def initialize(datatype, allowable_values)
30
+ @allowable_values = allowable_values.map do |value|
31
+ case datatype.to_s
32
+ when /Integer/i
33
+ value.to_i
34
+ when /Float/i
35
+ value.to_f
36
+ else
37
+ value
38
+ end
39
+ end
40
+ end
41
+
42
+ def valid?(value)
43
+ !value || allowable_values.include?(value)
44
+ end
45
+ end
46
+
47
+ # Attribute mapping from ruby-style variable name to JSON key.
48
+ def self.attribute_map
49
+ {
50
+ :'window_size' => :'window_size',
51
+ :'time_frame' => :'time_frame',
52
+ :'events' => :'events'
53
+ }
54
+ end
55
+
56
+ # Returns all the JSON keys this model knows about
57
+ def self.acceptable_attributes
58
+ attribute_map.values
59
+ end
60
+
61
+ # Attribute type mapping.
62
+ def self.openapi_types
63
+ {
64
+ :'window_size' => :'Float',
65
+ :'time_frame' => :'SpendPowerTimeFrame',
66
+ :'events' => :'Array<EvalSpendPowerRequestEventsInner>'
67
+ }
68
+ end
69
+
70
+ # List of attributes with nullable: true
71
+ def self.openapi_nullable
72
+ Set.new([
73
+ ])
74
+ end
75
+
76
+ # Initializes the object
77
+ # @param [Hash] attributes Model attributes in the form of hash
78
+ def initialize(attributes = {})
79
+ if (!attributes.is_a?(Hash))
80
+ fail ArgumentError, "The input argument (attributes) must be a hash in `FuseClient::EvalSpendPowerRequest` initialize method"
81
+ end
82
+
83
+ # check to see if the attribute exists and convert string to symbol for hash key
84
+ attributes = attributes.each_with_object({}) { |(k, v), h|
85
+ if (!self.class.attribute_map.key?(k.to_sym))
86
+ fail ArgumentError, "`#{k}` is not a valid attribute in `FuseClient::EvalSpendPowerRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
87
+ end
88
+ h[k.to_sym] = v
89
+ }
90
+
91
+ if attributes.key?(:'window_size')
92
+ self.window_size = attributes[:'window_size']
93
+ end
94
+
95
+ if attributes.key?(:'time_frame')
96
+ self.time_frame = attributes[:'time_frame']
97
+ end
98
+
99
+ if attributes.key?(:'events')
100
+ if (value = attributes[:'events']).is_a?(Array)
101
+ self.events = value
102
+ end
103
+ end
104
+ end
105
+
106
+ # Show invalid properties with the reasons. Usually used together with valid?
107
+ # @return Array for valid properties with the reasons
108
+ def list_invalid_properties
109
+ invalid_properties = Array.new
110
+ if @window_size.nil?
111
+ invalid_properties.push('invalid value for "window_size", window_size cannot be nil.')
112
+ end
113
+
114
+ if @time_frame.nil?
115
+ invalid_properties.push('invalid value for "time_frame", time_frame cannot be nil.')
116
+ end
117
+
118
+ if @events.nil?
119
+ invalid_properties.push('invalid value for "events", events cannot be nil.')
120
+ end
121
+
122
+ if @events.length < 1
123
+ invalid_properties.push('invalid value for "events", number of items must be greater than or equal to 1.')
124
+ end
125
+
126
+ invalid_properties
127
+ end
128
+
129
+ # Check to see if the all the properties in the model are valid
130
+ # @return true if the model is valid
131
+ def valid?
132
+ return false if @window_size.nil?
133
+ return false if @time_frame.nil?
134
+ return false if @events.nil?
135
+ return false if @events.length < 1
136
+ true
137
+ end
138
+
139
+ # Custom attribute writer method with validation
140
+ # @param [Object] events Value to be assigned
141
+ def events=(events)
142
+ if events.nil?
143
+ fail ArgumentError, 'events cannot be nil'
144
+ end
145
+
146
+ if events.length < 1
147
+ fail ArgumentError, 'invalid value for "events", number of items must be greater than or equal to 1.'
148
+ end
149
+
150
+ @events = events
151
+ end
152
+
153
+ # Checks equality by comparing each attribute.
154
+ # @param [Object] Object to be compared
155
+ def ==(o)
156
+ return true if self.equal?(o)
157
+ self.class == o.class &&
158
+ window_size == o.window_size &&
159
+ time_frame == o.time_frame &&
160
+ events == o.events
161
+ end
162
+
163
+ # @see the `==` method
164
+ # @param [Object] Object to be compared
165
+ def eql?(o)
166
+ self == o
167
+ end
168
+
169
+ # Calculates hash code according to all attributes.
170
+ # @return [Integer] Hash code
171
+ def hash
172
+ [window_size, time_frame, events].hash
173
+ end
174
+
175
+ # Builds the object from hash
176
+ # @param [Hash] attributes Model attributes in the form of hash
177
+ # @return [Object] Returns the model itself
178
+ def self.build_from_hash(attributes)
179
+ new.build_from_hash(attributes)
180
+ end
181
+
182
+ # Builds the object from hash
183
+ # @param [Hash] attributes Model attributes in the form of hash
184
+ # @return [Object] Returns the model itself
185
+ def build_from_hash(attributes)
186
+ return nil unless attributes.is_a?(Hash)
187
+ attributes = attributes.transform_keys(&:to_sym)
188
+ self.class.openapi_types.each_pair do |key, type|
189
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
190
+ self.send("#{key}=", nil)
191
+ elsif type =~ /\AArray<(.*)>/i
192
+ # check to ensure the input is an array given that the attribute
193
+ # is documented as an array but the input is not
194
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
195
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
196
+ end
197
+ elsif !attributes[self.class.attribute_map[key]].nil?
198
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
199
+ end
200
+ end
201
+
202
+ self
203
+ end
204
+
205
+ # Deserializes the data based on type
206
+ # @param string type Data type
207
+ # @param string value Value to be deserialized
208
+ # @return [Object] Deserialized data
209
+ def _deserialize(type, value)
210
+ case type.to_sym
211
+ when :Time
212
+ Time.parse(value)
213
+ when :Date
214
+ Date.parse(value)
215
+ when :String
216
+ value.to_s
217
+ when :Integer
218
+ value.to_i
219
+ when :Float
220
+ value.to_f
221
+ when :Boolean
222
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
223
+ true
224
+ else
225
+ false
226
+ end
227
+ when :Object
228
+ # generic object (usually a Hash), return directly
229
+ value
230
+ when /\AArray<(?<inner_type>.+)>\z/
231
+ inner_type = Regexp.last_match[:inner_type]
232
+ value.map { |v| _deserialize(inner_type, v) }
233
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
234
+ k_type = Regexp.last_match[:k_type]
235
+ v_type = Regexp.last_match[:v_type]
236
+ {}.tap do |hash|
237
+ value.each do |k, v|
238
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
239
+ end
240
+ end
241
+ else # model
242
+ # models (e.g. Pet) or oneOf
243
+ klass = FuseClient.const_get(type)
244
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
245
+ end
246
+ end
247
+
248
+ # Returns the string representation of the object
249
+ # @return [String] String presentation of the object
250
+ def to_s
251
+ to_hash.to_s
252
+ end
253
+
254
+ # to_body is an alias to to_hash (backward compatibility)
255
+ # @return [Hash] Returns the object in the form of hash
256
+ def to_body
257
+ to_hash
258
+ end
259
+
260
+ # Returns the object in the form of hash
261
+ # @return [Hash] Returns the object in the form of hash
262
+ def to_hash
263
+ hash = {}
264
+ self.class.attribute_map.each_pair do |attr, param|
265
+ value = self.send(attr)
266
+ if value.nil?
267
+ is_nullable = self.class.openapi_nullable.include?(attr)
268
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
269
+ end
270
+
271
+ hash[param] = _to_hash(value)
272
+ end
273
+ hash
274
+ end
275
+
276
+ # Outputs non-array value in the form of hash
277
+ # For object, use to_hash. Otherwise, just return the value
278
+ # @param [Object] value Any valid value
279
+ # @return [Hash] Returns the value in the form of hash
280
+ def _to_hash(value)
281
+ if value.is_a?(Array)
282
+ value.compact.map { |v| _to_hash(v) }
283
+ elsif value.is_a?(Hash)
284
+ {}.tap do |hash|
285
+ value.each { |k, v| hash[k] = _to_hash(v) }
286
+ end
287
+ elsif value.respond_to? :to_hash
288
+ value.to_hash
289
+ else
290
+ value
291
+ end
292
+ end
293
+
294
+ end
295
+
296
+ end
@@ -0,0 +1,239 @@
1
+ =begin
2
+ #Fuse
3
+
4
+ #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 6.5.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module FuseClient
17
+ class EvalSpendPowerRequestEventsInner
18
+ # The id of the account that event belongs to
19
+ attr_accessor :account_id
20
+
21
+ attr_accessor :event
22
+
23
+ # Attribute mapping from ruby-style variable name to JSON key.
24
+ def self.attribute_map
25
+ {
26
+ :'account_id' => :'account_id',
27
+ :'event' => :'event'
28
+ }
29
+ end
30
+
31
+ # Returns all the JSON keys this model knows about
32
+ def self.acceptable_attributes
33
+ attribute_map.values
34
+ end
35
+
36
+ # Attribute type mapping.
37
+ def self.openapi_types
38
+ {
39
+ :'account_id' => :'String',
40
+ :'event' => :'AddAccountEventsRequestEventsInner'
41
+ }
42
+ end
43
+
44
+ # List of attributes with nullable: true
45
+ def self.openapi_nullable
46
+ Set.new([
47
+ ])
48
+ end
49
+
50
+ # Initializes the object
51
+ # @param [Hash] attributes Model attributes in the form of hash
52
+ def initialize(attributes = {})
53
+ if (!attributes.is_a?(Hash))
54
+ fail ArgumentError, "The input argument (attributes) must be a hash in `FuseClient::EvalSpendPowerRequestEventsInner` initialize method"
55
+ end
56
+
57
+ # check to see if the attribute exists and convert string to symbol for hash key
58
+ attributes = attributes.each_with_object({}) { |(k, v), h|
59
+ if (!self.class.attribute_map.key?(k.to_sym))
60
+ fail ArgumentError, "`#{k}` is not a valid attribute in `FuseClient::EvalSpendPowerRequestEventsInner`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
61
+ end
62
+ h[k.to_sym] = v
63
+ }
64
+
65
+ if attributes.key?(:'account_id')
66
+ self.account_id = attributes[:'account_id']
67
+ end
68
+
69
+ if attributes.key?(:'event')
70
+ self.event = attributes[:'event']
71
+ end
72
+ end
73
+
74
+ # Show invalid properties with the reasons. Usually used together with valid?
75
+ # @return Array for valid properties with the reasons
76
+ def list_invalid_properties
77
+ invalid_properties = Array.new
78
+ if @account_id.nil?
79
+ invalid_properties.push('invalid value for "account_id", account_id cannot be nil.')
80
+ end
81
+
82
+ if @event.nil?
83
+ invalid_properties.push('invalid value for "event", event cannot be nil.')
84
+ end
85
+
86
+ invalid_properties
87
+ end
88
+
89
+ # Check to see if the all the properties in the model are valid
90
+ # @return true if the model is valid
91
+ def valid?
92
+ return false if @account_id.nil?
93
+ return false if @event.nil?
94
+ true
95
+ end
96
+
97
+ # Checks equality by comparing each attribute.
98
+ # @param [Object] Object to be compared
99
+ def ==(o)
100
+ return true if self.equal?(o)
101
+ self.class == o.class &&
102
+ account_id == o.account_id &&
103
+ event == o.event
104
+ end
105
+
106
+ # @see the `==` method
107
+ # @param [Object] Object to be compared
108
+ def eql?(o)
109
+ self == o
110
+ end
111
+
112
+ # Calculates hash code according to all attributes.
113
+ # @return [Integer] Hash code
114
+ def hash
115
+ [account_id, event].hash
116
+ end
117
+
118
+ # Builds the object from hash
119
+ # @param [Hash] attributes Model attributes in the form of hash
120
+ # @return [Object] Returns the model itself
121
+ def self.build_from_hash(attributes)
122
+ new.build_from_hash(attributes)
123
+ end
124
+
125
+ # Builds the object from hash
126
+ # @param [Hash] attributes Model attributes in the form of hash
127
+ # @return [Object] Returns the model itself
128
+ def build_from_hash(attributes)
129
+ return nil unless attributes.is_a?(Hash)
130
+ attributes = attributes.transform_keys(&:to_sym)
131
+ self.class.openapi_types.each_pair do |key, type|
132
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
133
+ self.send("#{key}=", nil)
134
+ elsif type =~ /\AArray<(.*)>/i
135
+ # check to ensure the input is an array given that the attribute
136
+ # is documented as an array but the input is not
137
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
138
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
139
+ end
140
+ elsif !attributes[self.class.attribute_map[key]].nil?
141
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
142
+ end
143
+ end
144
+
145
+ self
146
+ end
147
+
148
+ # Deserializes the data based on type
149
+ # @param string type Data type
150
+ # @param string value Value to be deserialized
151
+ # @return [Object] Deserialized data
152
+ def _deserialize(type, value)
153
+ case type.to_sym
154
+ when :Time
155
+ Time.parse(value)
156
+ when :Date
157
+ Date.parse(value)
158
+ when :String
159
+ value.to_s
160
+ when :Integer
161
+ value.to_i
162
+ when :Float
163
+ value.to_f
164
+ when :Boolean
165
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
166
+ true
167
+ else
168
+ false
169
+ end
170
+ when :Object
171
+ # generic object (usually a Hash), return directly
172
+ value
173
+ when /\AArray<(?<inner_type>.+)>\z/
174
+ inner_type = Regexp.last_match[:inner_type]
175
+ value.map { |v| _deserialize(inner_type, v) }
176
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
177
+ k_type = Regexp.last_match[:k_type]
178
+ v_type = Regexp.last_match[:v_type]
179
+ {}.tap do |hash|
180
+ value.each do |k, v|
181
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
182
+ end
183
+ end
184
+ else # model
185
+ # models (e.g. Pet) or oneOf
186
+ klass = FuseClient.const_get(type)
187
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
188
+ end
189
+ end
190
+
191
+ # Returns the string representation of the object
192
+ # @return [String] String presentation of the object
193
+ def to_s
194
+ to_hash.to_s
195
+ end
196
+
197
+ # to_body is an alias to to_hash (backward compatibility)
198
+ # @return [Hash] Returns the object in the form of hash
199
+ def to_body
200
+ to_hash
201
+ end
202
+
203
+ # Returns the object in the form of hash
204
+ # @return [Hash] Returns the object in the form of hash
205
+ def to_hash
206
+ hash = {}
207
+ self.class.attribute_map.each_pair do |attr, param|
208
+ value = self.send(attr)
209
+ if value.nil?
210
+ is_nullable = self.class.openapi_nullable.include?(attr)
211
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
212
+ end
213
+
214
+ hash[param] = _to_hash(value)
215
+ end
216
+ hash
217
+ end
218
+
219
+ # Outputs non-array value in the form of hash
220
+ # For object, use to_hash. Otherwise, just return the value
221
+ # @param [Object] value Any valid value
222
+ # @return [Hash] Returns the value in the form of hash
223
+ def _to_hash(value)
224
+ if value.is_a?(Array)
225
+ value.compact.map { |v| _to_hash(v) }
226
+ elsif value.is_a?(Hash)
227
+ {}.tap do |hash|
228
+ value.each { |k, v| hash[k] = _to_hash(v) }
229
+ end
230
+ elsif value.respond_to? :to_hash
231
+ value.to_hash
232
+ else
233
+ value
234
+ end
235
+ end
236
+
237
+ end
238
+
239
+ end