spartera_api_sdk 1.0.58

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +11 -0
  3. data/Gemfile.lock +69 -0
  4. data/LICENSE +21 -0
  5. data/README.md +360 -0
  6. data/Rakefile +10 -0
  7. data/config.json +10 -0
  8. data/docs/APIKeysApi.md +353 -0
  9. data/docs/Alert.md +36 -0
  10. data/docs/AlertsApi.md +511 -0
  11. data/docs/Apikey.md +36 -0
  12. data/docs/Asset.md +110 -0
  13. data/docs/AssetPriceHistoryApi.md +573 -0
  14. data/docs/Assetpricehistory.md +38 -0
  15. data/docs/AssetsApi.md +1131 -0
  16. data/docs/CloudProvidersApi.md +341 -0
  17. data/docs/Cloudprovider.md +30 -0
  18. data/docs/CompaniesApi.md +619 -0
  19. data/docs/Company.md +44 -0
  20. data/docs/Connection.md +54 -0
  21. data/docs/ConnectionsApi.md +497 -0
  22. data/docs/Error.md +24 -0
  23. data/docs/Favorite.md +36 -0
  24. data/docs/FavoritesApi.md +581 -0
  25. data/docs/InlineObject.md +22 -0
  26. data/docs/InlineObject1.md +20 -0
  27. data/docs/InlineObject2.md +20 -0
  28. data/docs/InlineObject3.md +20 -0
  29. data/docs/User.md +34 -0
  30. data/docs/UsersApi.md +357 -0
  31. data/example.rb +51 -0
  32. data/git_push.sh +57 -0
  33. data/lib/spartera_api_sdk/api/alerts_api.rb +543 -0
  34. data/lib/spartera_api_sdk/api/api_keys_api.rb +345 -0
  35. data/lib/spartera_api_sdk/api/asset_price_history_api.rb +576 -0
  36. data/lib/spartera_api_sdk/api/assets_api.rb +1106 -0
  37. data/lib/spartera_api_sdk/api/cloud_providers_api.rb +315 -0
  38. data/lib/spartera_api_sdk/api/companies_api.rb +571 -0
  39. data/lib/spartera_api_sdk/api/connections_api.rb +501 -0
  40. data/lib/spartera_api_sdk/api/favorites_api.rb +610 -0
  41. data/lib/spartera_api_sdk/api/users_api.rb +367 -0
  42. data/lib/spartera_api_sdk/api_client.rb +393 -0
  43. data/lib/spartera_api_sdk/api_error.rb +58 -0
  44. data/lib/spartera_api_sdk/configuration.rb +320 -0
  45. data/lib/spartera_api_sdk/models/alert.rb +353 -0
  46. data/lib/spartera_api_sdk/models/apikey.rb +370 -0
  47. data/lib/spartera_api_sdk/models/asset.rb +686 -0
  48. data/lib/spartera_api_sdk/models/assetpricehistory.rb +345 -0
  49. data/lib/spartera_api_sdk/models/cloudprovider.rb +292 -0
  50. data/lib/spartera_api_sdk/models/company.rb +389 -0
  51. data/lib/spartera_api_sdk/models/connection.rb +434 -0
  52. data/lib/spartera_api_sdk/models/error.rb +285 -0
  53. data/lib/spartera_api_sdk/models/favorite.rb +353 -0
  54. data/lib/spartera_api_sdk/models/inline_object.rb +240 -0
  55. data/lib/spartera_api_sdk/models/inline_object1.rb +229 -0
  56. data/lib/spartera_api_sdk/models/inline_object2.rb +229 -0
  57. data/lib/spartera_api_sdk/models/inline_object3.rb +229 -0
  58. data/lib/spartera_api_sdk/models/user.rb +327 -0
  59. data/lib/spartera_api_sdk/version.rb +15 -0
  60. data/lib/spartera_api_sdk.rb +62 -0
  61. data/spartera_api_sdk.gemspec +28 -0
  62. data/spec/api/alerts_api_spec.rb +126 -0
  63. data/spec/api/api_keys_api_spec.rb +93 -0
  64. data/spec/api/asset_price_history_api_spec.rb +134 -0
  65. data/spec/api/assets_api_spec.rb +228 -0
  66. data/spec/api/cloud_providers_api_spec.rb +88 -0
  67. data/spec/api/companies_api_spec.rb +134 -0
  68. data/spec/api/connections_api_spec.rb +119 -0
  69. data/spec/api/favorites_api_spec.rb +138 -0
  70. data/spec/api/users_api_spec.rb +95 -0
  71. data/spec/models/alert_spec.rb +90 -0
  72. data/spec/models/apikey_spec.rb +90 -0
  73. data/spec/models/asset_spec.rb +312 -0
  74. data/spec/models/assetpricehistory_spec.rb +96 -0
  75. data/spec/models/cloudprovider_spec.rb +72 -0
  76. data/spec/models/company_spec.rb +114 -0
  77. data/spec/models/connection_spec.rb +144 -0
  78. data/spec/models/error_spec.rb +54 -0
  79. data/spec/models/favorite_spec.rb +90 -0
  80. data/spec/models/inline_object1_spec.rb +42 -0
  81. data/spec/models/inline_object2_spec.rb +42 -0
  82. data/spec/models/inline_object3_spec.rb +42 -0
  83. data/spec/models/inline_object_spec.rb +48 -0
  84. data/spec/models/user_spec.rb +84 -0
  85. data/spec/spec_helper.rb +111 -0
  86. data/test.sh +42 -0
  87. metadata +204 -0
@@ -0,0 +1,434 @@
1
+ =begin
2
+ #Spartera API Documentation
3
+
4
+ #Auto-generated API documentation for REST services of the Spartera platform
5
+
6
+ The version of the OpenAPI document: 0.0.0
7
+ Contact: support@spartera.com
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.13.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module SparteraApiSdk
17
+ # Model for every connection setup from our platform
18
+ class Connection
19
+ attr_accessor :connection_id
20
+
21
+ attr_accessor :user_id
22
+
23
+ attr_accessor :engine_id
24
+
25
+ attr_accessor :company_id
26
+
27
+ attr_accessor :credential_type
28
+
29
+ attr_accessor :api_provider
30
+
31
+ attr_accessor :api_endpoint
32
+
33
+ attr_accessor :api_key_location
34
+
35
+ attr_accessor :api_key_param
36
+
37
+ attr_accessor :api_key_value
38
+
39
+ attr_accessor :visibility
40
+
41
+ attr_accessor :name
42
+
43
+ attr_accessor :description
44
+
45
+ attr_accessor :gcp_secret_id
46
+
47
+ attr_accessor :provider_domain
48
+
49
+ attr_accessor :verified_usage_ability
50
+
51
+ attr_accessor :date_created
52
+
53
+ attr_accessor :last_updated
54
+
55
+ attr_accessor :active
56
+
57
+ # Attribute mapping from ruby-style variable name to JSON key.
58
+ def self.attribute_map
59
+ {
60
+ :'connection_id' => :'connection_id',
61
+ :'user_id' => :'user_id',
62
+ :'engine_id' => :'engine_id',
63
+ :'company_id' => :'company_id',
64
+ :'credential_type' => :'credential_type',
65
+ :'api_provider' => :'api_provider',
66
+ :'api_endpoint' => :'api_endpoint',
67
+ :'api_key_location' => :'api_key_location',
68
+ :'api_key_param' => :'api_key_param',
69
+ :'api_key_value' => :'api_key_value',
70
+ :'visibility' => :'visibility',
71
+ :'name' => :'name',
72
+ :'description' => :'description',
73
+ :'gcp_secret_id' => :'gcp_secret_id',
74
+ :'provider_domain' => :'provider_domain',
75
+ :'verified_usage_ability' => :'verified_usage_ability',
76
+ :'date_created' => :'date_created',
77
+ :'last_updated' => :'last_updated',
78
+ :'active' => :'active'
79
+ }
80
+ end
81
+
82
+ # Returns attribute mapping this model knows about
83
+ def self.acceptable_attribute_map
84
+ attribute_map
85
+ end
86
+
87
+ # Returns all the JSON keys this model knows about
88
+ def self.acceptable_attributes
89
+ acceptable_attribute_map.values
90
+ end
91
+
92
+ # Attribute type mapping.
93
+ def self.openapi_types
94
+ {
95
+ :'connection_id' => :'String',
96
+ :'user_id' => :'String',
97
+ :'engine_id' => :'String',
98
+ :'company_id' => :'String',
99
+ :'credential_type' => :'String',
100
+ :'api_provider' => :'String',
101
+ :'api_endpoint' => :'String',
102
+ :'api_key_location' => :'String',
103
+ :'api_key_param' => :'String',
104
+ :'api_key_value' => :'String',
105
+ :'visibility' => :'String',
106
+ :'name' => :'String',
107
+ :'description' => :'String',
108
+ :'gcp_secret_id' => :'String',
109
+ :'provider_domain' => :'String',
110
+ :'verified_usage_ability' => :'String',
111
+ :'date_created' => :'String',
112
+ :'last_updated' => :'String',
113
+ :'active' => :'String'
114
+ }
115
+ end
116
+
117
+ # List of attributes with nullable: true
118
+ def self.openapi_nullable
119
+ Set.new([
120
+ ])
121
+ end
122
+
123
+ # Initializes the object
124
+ # @param [Hash] attributes Model attributes in the form of hash
125
+ def initialize(attributes = {})
126
+ if (!attributes.is_a?(Hash))
127
+ fail ArgumentError, "The input argument (attributes) must be a hash in `SparteraApiSdk::Connection` initialize method"
128
+ end
129
+
130
+ # check to see if the attribute exists and convert string to symbol for hash key
131
+ acceptable_attribute_map = self.class.acceptable_attribute_map
132
+ attributes = attributes.each_with_object({}) { |(k, v), h|
133
+ if (!acceptable_attribute_map.key?(k.to_sym))
134
+ fail ArgumentError, "`#{k}` is not a valid attribute in `SparteraApiSdk::Connection`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
135
+ end
136
+ h[k.to_sym] = v
137
+ }
138
+
139
+ if attributes.key?(:'connection_id')
140
+ self.connection_id = attributes[:'connection_id']
141
+ end
142
+
143
+ if attributes.key?(:'user_id')
144
+ self.user_id = attributes[:'user_id']
145
+ end
146
+
147
+ if attributes.key?(:'engine_id')
148
+ self.engine_id = attributes[:'engine_id']
149
+ else
150
+ self.engine_id = nil
151
+ end
152
+
153
+ if attributes.key?(:'company_id')
154
+ self.company_id = attributes[:'company_id']
155
+ else
156
+ self.company_id = nil
157
+ end
158
+
159
+ if attributes.key?(:'credential_type')
160
+ self.credential_type = attributes[:'credential_type']
161
+ end
162
+
163
+ if attributes.key?(:'api_provider')
164
+ self.api_provider = attributes[:'api_provider']
165
+ end
166
+
167
+ if attributes.key?(:'api_endpoint')
168
+ self.api_endpoint = attributes[:'api_endpoint']
169
+ end
170
+
171
+ if attributes.key?(:'api_key_location')
172
+ self.api_key_location = attributes[:'api_key_location']
173
+ end
174
+
175
+ if attributes.key?(:'api_key_param')
176
+ self.api_key_param = attributes[:'api_key_param']
177
+ end
178
+
179
+ if attributes.key?(:'api_key_value')
180
+ self.api_key_value = attributes[:'api_key_value']
181
+ end
182
+
183
+ if attributes.key?(:'visibility')
184
+ self.visibility = attributes[:'visibility']
185
+ else
186
+ self.visibility = nil
187
+ end
188
+
189
+ if attributes.key?(:'name')
190
+ self.name = attributes[:'name']
191
+ end
192
+
193
+ if attributes.key?(:'description')
194
+ self.description = attributes[:'description']
195
+ end
196
+
197
+ if attributes.key?(:'gcp_secret_id')
198
+ self.gcp_secret_id = attributes[:'gcp_secret_id']
199
+ end
200
+
201
+ if attributes.key?(:'provider_domain')
202
+ self.provider_domain = attributes[:'provider_domain']
203
+ end
204
+
205
+ if attributes.key?(:'verified_usage_ability')
206
+ self.verified_usage_ability = attributes[:'verified_usage_ability']
207
+ end
208
+
209
+ if attributes.key?(:'date_created')
210
+ self.date_created = attributes[:'date_created']
211
+ end
212
+
213
+ if attributes.key?(:'last_updated')
214
+ self.last_updated = attributes[:'last_updated']
215
+ end
216
+
217
+ if attributes.key?(:'active')
218
+ self.active = attributes[:'active']
219
+ end
220
+ end
221
+
222
+ # Show invalid properties with the reasons. Usually used together with valid?
223
+ # @return Array for valid properties with the reasons
224
+ def list_invalid_properties
225
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
226
+ invalid_properties = Array.new
227
+ if @engine_id.nil?
228
+ invalid_properties.push('invalid value for "engine_id", engine_id cannot be nil.')
229
+ end
230
+
231
+ if @company_id.nil?
232
+ invalid_properties.push('invalid value for "company_id", company_id cannot be nil.')
233
+ end
234
+
235
+ if @visibility.nil?
236
+ invalid_properties.push('invalid value for "visibility", visibility cannot be nil.')
237
+ end
238
+
239
+ invalid_properties
240
+ end
241
+
242
+ # Check to see if the all the properties in the model are valid
243
+ # @return true if the model is valid
244
+ def valid?
245
+ warn '[DEPRECATED] the `valid?` method is obsolete'
246
+ return false if @engine_id.nil?
247
+ return false if @company_id.nil?
248
+ return false if @visibility.nil?
249
+ true
250
+ end
251
+
252
+ # Custom attribute writer method with validation
253
+ # @param [Object] engine_id Value to be assigned
254
+ def engine_id=(engine_id)
255
+ if engine_id.nil?
256
+ fail ArgumentError, 'engine_id cannot be nil'
257
+ end
258
+
259
+ @engine_id = engine_id
260
+ end
261
+
262
+ # Custom attribute writer method with validation
263
+ # @param [Object] company_id Value to be assigned
264
+ def company_id=(company_id)
265
+ if company_id.nil?
266
+ fail ArgumentError, 'company_id cannot be nil'
267
+ end
268
+
269
+ @company_id = company_id
270
+ end
271
+
272
+ # Custom attribute writer method with validation
273
+ # @param [Object] visibility Value to be assigned
274
+ def visibility=(visibility)
275
+ if visibility.nil?
276
+ fail ArgumentError, 'visibility cannot be nil'
277
+ end
278
+
279
+ @visibility = visibility
280
+ end
281
+
282
+ # Checks equality by comparing each attribute.
283
+ # @param [Object] Object to be compared
284
+ def ==(o)
285
+ return true if self.equal?(o)
286
+ self.class == o.class &&
287
+ connection_id == o.connection_id &&
288
+ user_id == o.user_id &&
289
+ engine_id == o.engine_id &&
290
+ company_id == o.company_id &&
291
+ credential_type == o.credential_type &&
292
+ api_provider == o.api_provider &&
293
+ api_endpoint == o.api_endpoint &&
294
+ api_key_location == o.api_key_location &&
295
+ api_key_param == o.api_key_param &&
296
+ api_key_value == o.api_key_value &&
297
+ visibility == o.visibility &&
298
+ name == o.name &&
299
+ description == o.description &&
300
+ gcp_secret_id == o.gcp_secret_id &&
301
+ provider_domain == o.provider_domain &&
302
+ verified_usage_ability == o.verified_usage_ability &&
303
+ date_created == o.date_created &&
304
+ last_updated == o.last_updated &&
305
+ active == o.active
306
+ end
307
+
308
+ # @see the `==` method
309
+ # @param [Object] Object to be compared
310
+ def eql?(o)
311
+ self == o
312
+ end
313
+
314
+ # Calculates hash code according to all attributes.
315
+ # @return [Integer] Hash code
316
+ def hash
317
+ [connection_id, user_id, engine_id, company_id, credential_type, api_provider, api_endpoint, api_key_location, api_key_param, api_key_value, visibility, name, description, gcp_secret_id, provider_domain, verified_usage_ability, date_created, last_updated, active].hash
318
+ end
319
+
320
+ # Builds the object from hash
321
+ # @param [Hash] attributes Model attributes in the form of hash
322
+ # @return [Object] Returns the model itself
323
+ def self.build_from_hash(attributes)
324
+ return nil unless attributes.is_a?(Hash)
325
+ attributes = attributes.transform_keys(&:to_sym)
326
+ transformed_hash = {}
327
+ openapi_types.each_pair do |key, type|
328
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
329
+ transformed_hash["#{key}"] = nil
330
+ elsif type =~ /\AArray<(.*)>/i
331
+ # check to ensure the input is an array given that the attribute
332
+ # is documented as an array but the input is not
333
+ if attributes[attribute_map[key]].is_a?(Array)
334
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
335
+ end
336
+ elsif !attributes[attribute_map[key]].nil?
337
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
338
+ end
339
+ end
340
+ new(transformed_hash)
341
+ end
342
+
343
+ # Deserializes the data based on type
344
+ # @param string type Data type
345
+ # @param string value Value to be deserialized
346
+ # @return [Object] Deserialized data
347
+ def self._deserialize(type, value)
348
+ case type.to_sym
349
+ when :Time
350
+ Time.parse(value)
351
+ when :Date
352
+ Date.parse(value)
353
+ when :String
354
+ value.to_s
355
+ when :Integer
356
+ value.to_i
357
+ when :Float
358
+ value.to_f
359
+ when :Boolean
360
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
361
+ true
362
+ else
363
+ false
364
+ end
365
+ when :Object
366
+ # generic object (usually a Hash), return directly
367
+ value
368
+ when /\AArray<(?<inner_type>.+)>\z/
369
+ inner_type = Regexp.last_match[:inner_type]
370
+ value.map { |v| _deserialize(inner_type, v) }
371
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
372
+ k_type = Regexp.last_match[:k_type]
373
+ v_type = Regexp.last_match[:v_type]
374
+ {}.tap do |hash|
375
+ value.each do |k, v|
376
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
377
+ end
378
+ end
379
+ else # model
380
+ # models (e.g. Pet) or oneOf
381
+ klass = SparteraApiSdk.const_get(type)
382
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
383
+ end
384
+ end
385
+
386
+ # Returns the string representation of the object
387
+ # @return [String] String presentation of the object
388
+ def to_s
389
+ to_hash.to_s
390
+ end
391
+
392
+ # to_body is an alias to to_hash (backward compatibility)
393
+ # @return [Hash] Returns the object in the form of hash
394
+ def to_body
395
+ to_hash
396
+ end
397
+
398
+ # Returns the object in the form of hash
399
+ # @return [Hash] Returns the object in the form of hash
400
+ def to_hash
401
+ hash = {}
402
+ self.class.attribute_map.each_pair do |attr, param|
403
+ value = self.send(attr)
404
+ if value.nil?
405
+ is_nullable = self.class.openapi_nullable.include?(attr)
406
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
407
+ end
408
+
409
+ hash[param] = _to_hash(value)
410
+ end
411
+ hash
412
+ end
413
+
414
+ # Outputs non-array value in the form of hash
415
+ # For object, use to_hash. Otherwise, just return the value
416
+ # @param [Object] value Any valid value
417
+ # @return [Hash] Returns the value in the form of hash
418
+ def _to_hash(value)
419
+ if value.is_a?(Array)
420
+ value.compact.map { |v| _to_hash(v) }
421
+ elsif value.is_a?(Hash)
422
+ {}.tap do |hash|
423
+ value.each { |k, v| hash[k] = _to_hash(v) }
424
+ end
425
+ elsif value.respond_to? :to_hash
426
+ value.to_hash
427
+ else
428
+ value
429
+ end
430
+ end
431
+
432
+ end
433
+
434
+ end
@@ -0,0 +1,285 @@
1
+ =begin
2
+ #Spartera API Documentation
3
+
4
+ #Auto-generated API documentation for REST services of the Spartera platform
5
+
6
+ The version of the OpenAPI document: 0.0.0
7
+ Contact: support@spartera.com
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.13.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module SparteraApiSdk
17
+ class Error
18
+ # Error code
19
+ attr_accessor :code
20
+
21
+ # Error message
22
+ attr_accessor :message
23
+
24
+ # Additional error details
25
+ attr_accessor :details
26
+
27
+ # When the error occurred
28
+ attr_accessor :timestamp
29
+
30
+ # Attribute mapping from ruby-style variable name to JSON key.
31
+ def self.attribute_map
32
+ {
33
+ :'code' => :'code',
34
+ :'message' => :'message',
35
+ :'details' => :'details',
36
+ :'timestamp' => :'timestamp'
37
+ }
38
+ end
39
+
40
+ # Returns attribute mapping this model knows about
41
+ def self.acceptable_attribute_map
42
+ attribute_map
43
+ end
44
+
45
+ # Returns all the JSON keys this model knows about
46
+ def self.acceptable_attributes
47
+ acceptable_attribute_map.values
48
+ end
49
+
50
+ # Attribute type mapping.
51
+ def self.openapi_types
52
+ {
53
+ :'code' => :'Integer',
54
+ :'message' => :'String',
55
+ :'details' => :'String',
56
+ :'timestamp' => :'Time'
57
+ }
58
+ end
59
+
60
+ # List of attributes with nullable: true
61
+ def self.openapi_nullable
62
+ Set.new([
63
+ ])
64
+ end
65
+
66
+ # Initializes the object
67
+ # @param [Hash] attributes Model attributes in the form of hash
68
+ def initialize(attributes = {})
69
+ if (!attributes.is_a?(Hash))
70
+ fail ArgumentError, "The input argument (attributes) must be a hash in `SparteraApiSdk::Error` initialize method"
71
+ end
72
+
73
+ # check to see if the attribute exists and convert string to symbol for hash key
74
+ acceptable_attribute_map = self.class.acceptable_attribute_map
75
+ attributes = attributes.each_with_object({}) { |(k, v), h|
76
+ if (!acceptable_attribute_map.key?(k.to_sym))
77
+ fail ArgumentError, "`#{k}` is not a valid attribute in `SparteraApiSdk::Error`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
78
+ end
79
+ h[k.to_sym] = v
80
+ }
81
+
82
+ if attributes.key?(:'code')
83
+ self.code = attributes[:'code']
84
+ else
85
+ self.code = nil
86
+ end
87
+
88
+ if attributes.key?(:'message')
89
+ self.message = attributes[:'message']
90
+ else
91
+ self.message = nil
92
+ end
93
+
94
+ if attributes.key?(:'details')
95
+ self.details = attributes[:'details']
96
+ end
97
+
98
+ if attributes.key?(:'timestamp')
99
+ self.timestamp = attributes[:'timestamp']
100
+ end
101
+ end
102
+
103
+ # Show invalid properties with the reasons. Usually used together with valid?
104
+ # @return Array for valid properties with the reasons
105
+ def list_invalid_properties
106
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
107
+ invalid_properties = Array.new
108
+ if @code.nil?
109
+ invalid_properties.push('invalid value for "code", code cannot be nil.')
110
+ end
111
+
112
+ if @message.nil?
113
+ invalid_properties.push('invalid value for "message", message cannot be nil.')
114
+ end
115
+
116
+ invalid_properties
117
+ end
118
+
119
+ # Check to see if the all the properties in the model are valid
120
+ # @return true if the model is valid
121
+ def valid?
122
+ warn '[DEPRECATED] the `valid?` method is obsolete'
123
+ return false if @code.nil?
124
+ return false if @message.nil?
125
+ true
126
+ end
127
+
128
+ # Custom attribute writer method with validation
129
+ # @param [Object] code Value to be assigned
130
+ def code=(code)
131
+ if code.nil?
132
+ fail ArgumentError, 'code cannot be nil'
133
+ end
134
+
135
+ @code = code
136
+ end
137
+
138
+ # Custom attribute writer method with validation
139
+ # @param [Object] message Value to be assigned
140
+ def message=(message)
141
+ if message.nil?
142
+ fail ArgumentError, 'message cannot be nil'
143
+ end
144
+
145
+ @message = message
146
+ end
147
+
148
+ # Checks equality by comparing each attribute.
149
+ # @param [Object] Object to be compared
150
+ def ==(o)
151
+ return true if self.equal?(o)
152
+ self.class == o.class &&
153
+ code == o.code &&
154
+ message == o.message &&
155
+ details == o.details &&
156
+ timestamp == o.timestamp
157
+ end
158
+
159
+ # @see the `==` method
160
+ # @param [Object] Object to be compared
161
+ def eql?(o)
162
+ self == o
163
+ end
164
+
165
+ # Calculates hash code according to all attributes.
166
+ # @return [Integer] Hash code
167
+ def hash
168
+ [code, message, details, timestamp].hash
169
+ end
170
+
171
+ # Builds the object from hash
172
+ # @param [Hash] attributes Model attributes in the form of hash
173
+ # @return [Object] Returns the model itself
174
+ def self.build_from_hash(attributes)
175
+ return nil unless attributes.is_a?(Hash)
176
+ attributes = attributes.transform_keys(&:to_sym)
177
+ transformed_hash = {}
178
+ openapi_types.each_pair do |key, type|
179
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
180
+ transformed_hash["#{key}"] = nil
181
+ elsif type =~ /\AArray<(.*)>/i
182
+ # check to ensure the input is an array given that the attribute
183
+ # is documented as an array but the input is not
184
+ if attributes[attribute_map[key]].is_a?(Array)
185
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
186
+ end
187
+ elsif !attributes[attribute_map[key]].nil?
188
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
189
+ end
190
+ end
191
+ new(transformed_hash)
192
+ end
193
+
194
+ # Deserializes the data based on type
195
+ # @param string type Data type
196
+ # @param string value Value to be deserialized
197
+ # @return [Object] Deserialized data
198
+ def self._deserialize(type, value)
199
+ case type.to_sym
200
+ when :Time
201
+ Time.parse(value)
202
+ when :Date
203
+ Date.parse(value)
204
+ when :String
205
+ value.to_s
206
+ when :Integer
207
+ value.to_i
208
+ when :Float
209
+ value.to_f
210
+ when :Boolean
211
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
212
+ true
213
+ else
214
+ false
215
+ end
216
+ when :Object
217
+ # generic object (usually a Hash), return directly
218
+ value
219
+ when /\AArray<(?<inner_type>.+)>\z/
220
+ inner_type = Regexp.last_match[:inner_type]
221
+ value.map { |v| _deserialize(inner_type, v) }
222
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
223
+ k_type = Regexp.last_match[:k_type]
224
+ v_type = Regexp.last_match[:v_type]
225
+ {}.tap do |hash|
226
+ value.each do |k, v|
227
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
228
+ end
229
+ end
230
+ else # model
231
+ # models (e.g. Pet) or oneOf
232
+ klass = SparteraApiSdk.const_get(type)
233
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
234
+ end
235
+ end
236
+
237
+ # Returns the string representation of the object
238
+ # @return [String] String presentation of the object
239
+ def to_s
240
+ to_hash.to_s
241
+ end
242
+
243
+ # to_body is an alias to to_hash (backward compatibility)
244
+ # @return [Hash] Returns the object in the form of hash
245
+ def to_body
246
+ to_hash
247
+ end
248
+
249
+ # Returns the object in the form of hash
250
+ # @return [Hash] Returns the object in the form of hash
251
+ def to_hash
252
+ hash = {}
253
+ self.class.attribute_map.each_pair do |attr, param|
254
+ value = self.send(attr)
255
+ if value.nil?
256
+ is_nullable = self.class.openapi_nullable.include?(attr)
257
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
258
+ end
259
+
260
+ hash[param] = _to_hash(value)
261
+ end
262
+ hash
263
+ end
264
+
265
+ # Outputs non-array value in the form of hash
266
+ # For object, use to_hash. Otherwise, just return the value
267
+ # @param [Object] value Any valid value
268
+ # @return [Hash] Returns the value in the form of hash
269
+ def _to_hash(value)
270
+ if value.is_a?(Array)
271
+ value.compact.map { |v| _to_hash(v) }
272
+ elsif value.is_a?(Hash)
273
+ {}.tap do |hash|
274
+ value.each { |k, v| hash[k] = _to_hash(v) }
275
+ end
276
+ elsif value.respond_to? :to_hash
277
+ value.to_hash
278
+ else
279
+ value
280
+ end
281
+ end
282
+
283
+ end
284
+
285
+ end