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,320 @@
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
+ module SparteraApiSdk
14
+ class Configuration
15
+ # Defines url scheme
16
+ attr_accessor :scheme
17
+
18
+ # Defines url host
19
+ attr_accessor :host
20
+
21
+ # Defines url base path
22
+ attr_accessor :base_path
23
+
24
+ # Define server configuration index
25
+ attr_accessor :server_index
26
+
27
+ # Define server operation configuration index
28
+ attr_accessor :server_operation_index
29
+
30
+ # Default server variables
31
+ attr_accessor :server_variables
32
+
33
+ # Default server operation variables
34
+ attr_accessor :server_operation_variables
35
+
36
+ # Defines API keys used with API Key authentications.
37
+ #
38
+ # @return [Hash] key: parameter name, value: parameter value (API key)
39
+ #
40
+ # @example parameter name is "api_key", API key is "xxx" (e.g. "api_key=xxx" in query string)
41
+ # config.api_key['api_key'] = 'xxx'
42
+ attr_accessor :api_key
43
+
44
+ # Defines API key prefixes used with API Key authentications.
45
+ #
46
+ # @return [Hash] key: parameter name, value: API key prefix
47
+ #
48
+ # @example parameter name is "Authorization", API key prefix is "Token" (e.g. "Authorization: Token xxx" in headers)
49
+ # config.api_key_prefix['api_key'] = 'Token'
50
+ attr_accessor :api_key_prefix
51
+
52
+ # Defines the username used with HTTP basic authentication.
53
+ #
54
+ # @return [String]
55
+ attr_accessor :username
56
+
57
+ # Defines the password used with HTTP basic authentication.
58
+ #
59
+ # @return [String]
60
+ attr_accessor :password
61
+
62
+ # Defines the access token (Bearer) used with OAuth2.
63
+ attr_accessor :access_token
64
+
65
+ # Defines a Proc used to fetch or refresh access tokens (Bearer) used with OAuth2.
66
+ # Overrides the access_token if set
67
+ # @return [Proc]
68
+ attr_accessor :access_token_getter
69
+
70
+ # Set this to return data as binary instead of downloading a temp file. When enabled (set to true)
71
+ # HTTP responses with return type `File` will be returned as a stream of binary data.
72
+ # Default to false.
73
+ attr_accessor :return_binary_data
74
+
75
+ # Set this to enable/disable debugging. When enabled (set to true), HTTP request/response
76
+ # details will be logged with `logger.debug` (see the `logger` attribute).
77
+ # Default to false.
78
+ #
79
+ # @return [true, false]
80
+ attr_accessor :debugging
81
+
82
+ # Set this to ignore operation servers for the API client. This is useful when you need to
83
+ # send requests to a different server than the one specified in the OpenAPI document.
84
+ # Will default to the base url defined in the spec but can be overridden by setting
85
+ # `scheme`, `host`, `base_path` directly.
86
+ # Default to false.
87
+ # @return [true, false]
88
+ attr_accessor :ignore_operation_servers
89
+
90
+ # Defines the logger used for debugging.
91
+ # Default to `Rails.logger` (when in Rails) or logging to STDOUT.
92
+ #
93
+ # @return [#debug]
94
+ attr_accessor :logger
95
+
96
+ # Defines the temporary folder to store downloaded files
97
+ # (for API endpoints that have file response).
98
+ # Default to use `Tempfile`.
99
+ #
100
+ # @return [String]
101
+ attr_accessor :temp_folder_path
102
+
103
+ # The time limit for HTTP request in seconds.
104
+ # Default to 0 (never times out).
105
+ attr_accessor :timeout
106
+
107
+ # Set this to false to skip client side validation in the operation.
108
+ # Default to true.
109
+ # @return [true, false]
110
+ attr_accessor :client_side_validation
111
+
112
+ ### TLS/SSL setting
113
+ # Set this to false to skip verifying SSL certificate when calling API from https server.
114
+ # Default to true.
115
+ #
116
+ # @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
117
+ #
118
+ # @return [true, false]
119
+ attr_accessor :verify_ssl
120
+
121
+ ### TLS/SSL setting
122
+ # Set this to false to skip verifying SSL host name
123
+ # Default to true.
124
+ #
125
+ # @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
126
+ #
127
+ # @return [true, false]
128
+ attr_accessor :verify_ssl_host
129
+
130
+ ### TLS/SSL setting
131
+ # Set this to customize the certificate file to verify the peer.
132
+ #
133
+ # @return [String] the path to the certificate file
134
+ #
135
+ # @see The `cainfo` option of Typhoeus, `--cert` option of libcurl. Related source code:
136
+ # https://github.com/typhoeus/typhoeus/blob/master/lib/typhoeus/easy_factory.rb#L145
137
+ attr_accessor :ssl_ca_cert
138
+
139
+ ### TLS/SSL setting
140
+ # Client certificate file (for client certificate)
141
+ attr_accessor :cert_file
142
+
143
+ ### TLS/SSL setting
144
+ # Client private key file (for client certificate)
145
+ attr_accessor :key_file
146
+
147
+ # Set this to customize parameters encoding of array parameter with multi collectionFormat.
148
+ # Default to nil.
149
+ #
150
+ # @see The params_encoding option of Ethon. Related source code:
151
+ # https://github.com/typhoeus/ethon/blob/master/lib/ethon/easy/queryable.rb#L96
152
+ attr_accessor :params_encoding
153
+
154
+
155
+ attr_accessor :inject_format
156
+
157
+ attr_accessor :force_ending_format
158
+
159
+ def initialize
160
+ @scheme = 'https'
161
+ @host = 'api.spartera.com'
162
+ @base_path = ''
163
+ @server_index = nil
164
+ @server_operation_index = {}
165
+ @server_variables = {}
166
+ @server_operation_variables = {}
167
+ @api_key = {}
168
+ @api_key_prefix = {}
169
+ @client_side_validation = true
170
+ @verify_ssl = true
171
+ @verify_ssl_host = true
172
+ @cert_file = nil
173
+ @key_file = nil
174
+ @timeout = 0
175
+ @params_encoding = nil
176
+ @debugging = false
177
+ @ignore_operation_servers = false
178
+ @inject_format = false
179
+ @force_ending_format = false
180
+ @logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
181
+
182
+ yield(self) if block_given?
183
+ end
184
+
185
+ # The default Configuration object.
186
+ def self.default
187
+ @@default ||= Configuration.new
188
+ end
189
+
190
+ def configure
191
+ yield(self) if block_given?
192
+ end
193
+
194
+ def scheme=(scheme)
195
+ # remove :// from scheme
196
+ @scheme = scheme.sub(/:\/\//, '')
197
+ end
198
+
199
+ def host=(host)
200
+ # remove http(s):// and anything after a slash
201
+ @host = host.sub(/https?:\/\//, '').split('/').first
202
+ end
203
+
204
+ def base_path=(base_path)
205
+ # Add leading and trailing slashes to base_path
206
+ @base_path = "/#{base_path}".gsub(/\/+/, '/')
207
+ @base_path = '' if @base_path == '/'
208
+ end
209
+
210
+ # Returns base URL for specified operation based on server settings
211
+ def base_url(operation = nil)
212
+ return "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '') if ignore_operation_servers
213
+ if operation_server_settings.key?(operation) then
214
+ index = server_operation_index.fetch(operation, server_index)
215
+ server_url(index.nil? ? 0 : index, server_operation_variables.fetch(operation, server_variables), operation_server_settings[operation])
216
+ else
217
+ server_index.nil? ? "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '') : server_url(server_index, server_variables, nil)
218
+ end
219
+ end
220
+
221
+ # Gets API key (with prefix if set).
222
+ # @param [String] param_name the parameter name of API key auth
223
+ def api_key_with_prefix(param_name, param_alias = nil)
224
+ key = @api_key[param_name]
225
+ key = @api_key.fetch(param_alias, key) unless param_alias.nil?
226
+ if @api_key_prefix[param_name]
227
+ "#{@api_key_prefix[param_name]} #{key}"
228
+ else
229
+ key
230
+ end
231
+ end
232
+
233
+ # Gets access_token using access_token_getter or uses the static access_token
234
+ def access_token_with_refresh
235
+ return access_token if access_token_getter.nil?
236
+ access_token_getter.call
237
+ end
238
+
239
+ # Gets Basic Auth token string
240
+ def basic_auth_token
241
+ 'Basic ' + ["#{username}:#{password}"].pack('m').delete("\r\n")
242
+ end
243
+
244
+ # Returns Auth Settings hash for api client.
245
+ def auth_settings
246
+ {
247
+ 'bearerAuth' =>
248
+ {
249
+ type: 'bearer',
250
+ in: 'header',
251
+ format: 'JWT',
252
+ key: 'Authorization',
253
+ value: "Bearer #{access_token_with_refresh}"
254
+ },
255
+ 'ApiKeyAuth' =>
256
+ {
257
+ type: 'api_key',
258
+ in: 'header',
259
+ key: 'X-API-Key',
260
+ value: api_key_with_prefix('X-API-Key')
261
+ },
262
+ }
263
+ end
264
+
265
+ # Returns an array of Server setting
266
+ def server_settings
267
+ [
268
+ {
269
+ url: "https://api.spartera.com",
270
+ description: "Production server",
271
+ },
272
+ {
273
+ url: "https://stage.api.spartera.com",
274
+ description: "Staging server",
275
+ }
276
+ ]
277
+ end
278
+
279
+ def operation_server_settings
280
+ {
281
+ }
282
+ end
283
+
284
+ # Returns URL based on server settings
285
+ #
286
+ # @param index array index of the server settings
287
+ # @param variables hash of variable and the corresponding value
288
+ def server_url(index, variables = {}, servers = nil)
289
+ servers = server_settings if servers == nil
290
+
291
+ # check array index out of bound
292
+ if (index.nil? || index < 0 || index >= servers.size)
293
+ fail ArgumentError, "Invalid index #{index} when selecting the server. Must not be nil and must be less than #{servers.size}"
294
+ end
295
+
296
+ server = servers[index]
297
+ url = server[:url]
298
+
299
+ return url unless server.key? :variables
300
+
301
+ # go through variable and assign a value
302
+ server[:variables].each do |name, variable|
303
+ if variables.key?(name)
304
+ if (!server[:variables][name].key?(:enum_values) || server[:variables][name][:enum_values].include?(variables[name]))
305
+ url.gsub! "{" + name.to_s + "}", variables[name]
306
+ else
307
+ fail ArgumentError, "The variable `#{name}` in the server URL has invalid value #{variables[name]}. Must be #{server[:variables][name][:enum_values]}."
308
+ end
309
+ else
310
+ # use default value
311
+ url.gsub! "{" + name.to_s + "}", server[:variables][name][:default_value]
312
+ end
313
+ end
314
+
315
+ url
316
+ end
317
+
318
+
319
+ end
320
+ end
@@ -0,0 +1,353 @@
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
+ # User alerts for when assets are updated
18
+ class Alert
19
+ attr_accessor :alert_id
20
+
21
+ attr_accessor :asset_id
22
+
23
+ attr_accessor :user_id
24
+
25
+ attr_accessor :company_id
26
+
27
+ attr_accessor :alert_type
28
+
29
+ attr_accessor :is_active
30
+
31
+ attr_accessor :last_triggered
32
+
33
+ attr_accessor :date_created
34
+
35
+ attr_accessor :last_updated
36
+
37
+ attr_accessor :active
38
+
39
+ # Attribute mapping from ruby-style variable name to JSON key.
40
+ def self.attribute_map
41
+ {
42
+ :'alert_id' => :'alert_id',
43
+ :'asset_id' => :'asset_id',
44
+ :'user_id' => :'user_id',
45
+ :'company_id' => :'company_id',
46
+ :'alert_type' => :'alert_type',
47
+ :'is_active' => :'is_active',
48
+ :'last_triggered' => :'last_triggered',
49
+ :'date_created' => :'date_created',
50
+ :'last_updated' => :'last_updated',
51
+ :'active' => :'active'
52
+ }
53
+ end
54
+
55
+ # Returns attribute mapping this model knows about
56
+ def self.acceptable_attribute_map
57
+ attribute_map
58
+ end
59
+
60
+ # Returns all the JSON keys this model knows about
61
+ def self.acceptable_attributes
62
+ acceptable_attribute_map.values
63
+ end
64
+
65
+ # Attribute type mapping.
66
+ def self.openapi_types
67
+ {
68
+ :'alert_id' => :'String',
69
+ :'asset_id' => :'String',
70
+ :'user_id' => :'String',
71
+ :'company_id' => :'String',
72
+ :'alert_type' => :'String',
73
+ :'is_active' => :'String',
74
+ :'last_triggered' => :'String',
75
+ :'date_created' => :'String',
76
+ :'last_updated' => :'String',
77
+ :'active' => :'String'
78
+ }
79
+ end
80
+
81
+ # List of attributes with nullable: true
82
+ def self.openapi_nullable
83
+ Set.new([
84
+ ])
85
+ end
86
+
87
+ # Initializes the object
88
+ # @param [Hash] attributes Model attributes in the form of hash
89
+ def initialize(attributes = {})
90
+ if (!attributes.is_a?(Hash))
91
+ fail ArgumentError, "The input argument (attributes) must be a hash in `SparteraApiSdk::Alert` initialize method"
92
+ end
93
+
94
+ # check to see if the attribute exists and convert string to symbol for hash key
95
+ acceptable_attribute_map = self.class.acceptable_attribute_map
96
+ attributes = attributes.each_with_object({}) { |(k, v), h|
97
+ if (!acceptable_attribute_map.key?(k.to_sym))
98
+ fail ArgumentError, "`#{k}` is not a valid attribute in `SparteraApiSdk::Alert`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
99
+ end
100
+ h[k.to_sym] = v
101
+ }
102
+
103
+ if attributes.key?(:'alert_id')
104
+ self.alert_id = attributes[:'alert_id']
105
+ end
106
+
107
+ if attributes.key?(:'asset_id')
108
+ self.asset_id = attributes[:'asset_id']
109
+ else
110
+ self.asset_id = nil
111
+ end
112
+
113
+ if attributes.key?(:'user_id')
114
+ self.user_id = attributes[:'user_id']
115
+ end
116
+
117
+ if attributes.key?(:'company_id')
118
+ self.company_id = attributes[:'company_id']
119
+ else
120
+ self.company_id = nil
121
+ end
122
+
123
+ if attributes.key?(:'alert_type')
124
+ self.alert_type = attributes[:'alert_type']
125
+ else
126
+ self.alert_type = nil
127
+ end
128
+
129
+ if attributes.key?(:'is_active')
130
+ self.is_active = attributes[:'is_active']
131
+ end
132
+
133
+ if attributes.key?(:'last_triggered')
134
+ self.last_triggered = attributes[:'last_triggered']
135
+ end
136
+
137
+ if attributes.key?(:'date_created')
138
+ self.date_created = attributes[:'date_created']
139
+ end
140
+
141
+ if attributes.key?(:'last_updated')
142
+ self.last_updated = attributes[:'last_updated']
143
+ end
144
+
145
+ if attributes.key?(:'active')
146
+ self.active = attributes[:'active']
147
+ end
148
+ end
149
+
150
+ # Show invalid properties with the reasons. Usually used together with valid?
151
+ # @return Array for valid properties with the reasons
152
+ def list_invalid_properties
153
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
154
+ invalid_properties = Array.new
155
+ if @asset_id.nil?
156
+ invalid_properties.push('invalid value for "asset_id", asset_id cannot be nil.')
157
+ end
158
+
159
+ if @company_id.nil?
160
+ invalid_properties.push('invalid value for "company_id", company_id cannot be nil.')
161
+ end
162
+
163
+ if @alert_type.nil?
164
+ invalid_properties.push('invalid value for "alert_type", alert_type cannot be nil.')
165
+ end
166
+
167
+ invalid_properties
168
+ end
169
+
170
+ # Check to see if the all the properties in the model are valid
171
+ # @return true if the model is valid
172
+ def valid?
173
+ warn '[DEPRECATED] the `valid?` method is obsolete'
174
+ return false if @asset_id.nil?
175
+ return false if @company_id.nil?
176
+ return false if @alert_type.nil?
177
+ true
178
+ end
179
+
180
+ # Custom attribute writer method with validation
181
+ # @param [Object] asset_id Value to be assigned
182
+ def asset_id=(asset_id)
183
+ if asset_id.nil?
184
+ fail ArgumentError, 'asset_id cannot be nil'
185
+ end
186
+
187
+ @asset_id = asset_id
188
+ end
189
+
190
+ # Custom attribute writer method with validation
191
+ # @param [Object] company_id Value to be assigned
192
+ def company_id=(company_id)
193
+ if company_id.nil?
194
+ fail ArgumentError, 'company_id cannot be nil'
195
+ end
196
+
197
+ @company_id = company_id
198
+ end
199
+
200
+ # Custom attribute writer method with validation
201
+ # @param [Object] alert_type Value to be assigned
202
+ def alert_type=(alert_type)
203
+ if alert_type.nil?
204
+ fail ArgumentError, 'alert_type cannot be nil'
205
+ end
206
+
207
+ @alert_type = alert_type
208
+ end
209
+
210
+ # Checks equality by comparing each attribute.
211
+ # @param [Object] Object to be compared
212
+ def ==(o)
213
+ return true if self.equal?(o)
214
+ self.class == o.class &&
215
+ alert_id == o.alert_id &&
216
+ asset_id == o.asset_id &&
217
+ user_id == o.user_id &&
218
+ company_id == o.company_id &&
219
+ alert_type == o.alert_type &&
220
+ is_active == o.is_active &&
221
+ last_triggered == o.last_triggered &&
222
+ date_created == o.date_created &&
223
+ last_updated == o.last_updated &&
224
+ active == o.active
225
+ end
226
+
227
+ # @see the `==` method
228
+ # @param [Object] Object to be compared
229
+ def eql?(o)
230
+ self == o
231
+ end
232
+
233
+ # Calculates hash code according to all attributes.
234
+ # @return [Integer] Hash code
235
+ def hash
236
+ [alert_id, asset_id, user_id, company_id, alert_type, is_active, last_triggered, date_created, last_updated, active].hash
237
+ end
238
+
239
+ # Builds the object from hash
240
+ # @param [Hash] attributes Model attributes in the form of hash
241
+ # @return [Object] Returns the model itself
242
+ def self.build_from_hash(attributes)
243
+ return nil unless attributes.is_a?(Hash)
244
+ attributes = attributes.transform_keys(&:to_sym)
245
+ transformed_hash = {}
246
+ openapi_types.each_pair do |key, type|
247
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
248
+ transformed_hash["#{key}"] = nil
249
+ elsif type =~ /\AArray<(.*)>/i
250
+ # check to ensure the input is an array given that the attribute
251
+ # is documented as an array but the input is not
252
+ if attributes[attribute_map[key]].is_a?(Array)
253
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
254
+ end
255
+ elsif !attributes[attribute_map[key]].nil?
256
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
257
+ end
258
+ end
259
+ new(transformed_hash)
260
+ end
261
+
262
+ # Deserializes the data based on type
263
+ # @param string type Data type
264
+ # @param string value Value to be deserialized
265
+ # @return [Object] Deserialized data
266
+ def self._deserialize(type, value)
267
+ case type.to_sym
268
+ when :Time
269
+ Time.parse(value)
270
+ when :Date
271
+ Date.parse(value)
272
+ when :String
273
+ value.to_s
274
+ when :Integer
275
+ value.to_i
276
+ when :Float
277
+ value.to_f
278
+ when :Boolean
279
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
280
+ true
281
+ else
282
+ false
283
+ end
284
+ when :Object
285
+ # generic object (usually a Hash), return directly
286
+ value
287
+ when /\AArray<(?<inner_type>.+)>\z/
288
+ inner_type = Regexp.last_match[:inner_type]
289
+ value.map { |v| _deserialize(inner_type, v) }
290
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
291
+ k_type = Regexp.last_match[:k_type]
292
+ v_type = Regexp.last_match[:v_type]
293
+ {}.tap do |hash|
294
+ value.each do |k, v|
295
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
296
+ end
297
+ end
298
+ else # model
299
+ # models (e.g. Pet) or oneOf
300
+ klass = SparteraApiSdk.const_get(type)
301
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
302
+ end
303
+ end
304
+
305
+ # Returns the string representation of the object
306
+ # @return [String] String presentation of the object
307
+ def to_s
308
+ to_hash.to_s
309
+ end
310
+
311
+ # to_body is an alias to to_hash (backward compatibility)
312
+ # @return [Hash] Returns the object in the form of hash
313
+ def to_body
314
+ to_hash
315
+ end
316
+
317
+ # Returns the object in the form of hash
318
+ # @return [Hash] Returns the object in the form of hash
319
+ def to_hash
320
+ hash = {}
321
+ self.class.attribute_map.each_pair do |attr, param|
322
+ value = self.send(attr)
323
+ if value.nil?
324
+ is_nullable = self.class.openapi_nullable.include?(attr)
325
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
326
+ end
327
+
328
+ hash[param] = _to_hash(value)
329
+ end
330
+ hash
331
+ end
332
+
333
+ # Outputs non-array value in the form of hash
334
+ # For object, use to_hash. Otherwise, just return the value
335
+ # @param [Object] value Any valid value
336
+ # @return [Hash] Returns the value in the form of hash
337
+ def _to_hash(value)
338
+ if value.is_a?(Array)
339
+ value.compact.map { |v| _to_hash(v) }
340
+ elsif value.is_a?(Hash)
341
+ {}.tap do |hash|
342
+ value.each { |k, v| hash[k] = _to_hash(v) }
343
+ end
344
+ elsif value.respond_to? :to_hash
345
+ value.to_hash
346
+ else
347
+ value
348
+ end
349
+ end
350
+
351
+ end
352
+
353
+ end