statuscake-rb 1.0.0.pre.beta.4

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 (58) hide show
  1. checksums.yaml +7 -0
  2. data/lib/statuscake/api/contact_groups_api.rb +411 -0
  3. data/lib/statuscake/api/locations_api.rb +166 -0
  4. data/lib/statuscake/api/maintenance_windows_api.rb +444 -0
  5. data/lib/statuscake/api/pagespeed_api.rb +550 -0
  6. data/lib/statuscake/api/ssl_api.rb +458 -0
  7. data/lib/statuscake/api/uptime_api.rb +881 -0
  8. data/lib/statuscake/api_client.rb +407 -0
  9. data/lib/statuscake/api_error.rb +75 -0
  10. data/lib/statuscake/configuration.rb +296 -0
  11. data/lib/statuscake/models/api_error.rb +249 -0
  12. data/lib/statuscake/models/api_response.rb +241 -0
  13. data/lib/statuscake/models/api_response_data.rb +243 -0
  14. data/lib/statuscake/models/contact_group.rb +318 -0
  15. data/lib/statuscake/models/contact_group_response.rb +241 -0
  16. data/lib/statuscake/models/contact_groups.rb +258 -0
  17. data/lib/statuscake/models/links.rb +242 -0
  18. data/lib/statuscake/models/maintenance_window.rb +364 -0
  19. data/lib/statuscake/models/maintenance_window_repeat_interval.rb +59 -0
  20. data/lib/statuscake/models/maintenance_window_response.rb +241 -0
  21. data/lib/statuscake/models/maintenance_window_state.rb +57 -0
  22. data/lib/statuscake/models/maintenance_windows.rb +258 -0
  23. data/lib/statuscake/models/monitoring_location.rb +306 -0
  24. data/lib/statuscake/models/monitoring_location_status.rb +56 -0
  25. data/lib/statuscake/models/monitoring_locations.rb +244 -0
  26. data/lib/statuscake/models/pagespeed_test.rb +444 -0
  27. data/lib/statuscake/models/pagespeed_test_check_rate.rb +61 -0
  28. data/lib/statuscake/models/pagespeed_test_history.rb +269 -0
  29. data/lib/statuscake/models/pagespeed_test_history_result.rb +373 -0
  30. data/lib/statuscake/models/pagespeed_test_region.rb +64 -0
  31. data/lib/statuscake/models/pagespeed_test_response.rb +241 -0
  32. data/lib/statuscake/models/pagespeed_test_stats.rb +354 -0
  33. data/lib/statuscake/models/pagespeed_test_throttling.rb +60 -0
  34. data/lib/statuscake/models/pagespeed_tests.rb +258 -0
  35. data/lib/statuscake/models/pagination.rb +363 -0
  36. data/lib/statuscake/models/ssl_test.rb +594 -0
  37. data/lib/statuscake/models/ssl_test_check_rate.rb +60 -0
  38. data/lib/statuscake/models/ssl_test_flags.rb +347 -0
  39. data/lib/statuscake/models/ssl_test_mixed_content.rb +257 -0
  40. data/lib/statuscake/models/ssl_test_response.rb +241 -0
  41. data/lib/statuscake/models/ssl_tests.rb +258 -0
  42. data/lib/statuscake/models/uptime_test.rb +811 -0
  43. data/lib/statuscake/models/uptime_test_alert.rb +300 -0
  44. data/lib/statuscake/models/uptime_test_alerts.rb +269 -0
  45. data/lib/statuscake/models/uptime_test_check_rate.rb +62 -0
  46. data/lib/statuscake/models/uptime_test_history.rb +269 -0
  47. data/lib/statuscake/models/uptime_test_history_result.rb +302 -0
  48. data/lib/statuscake/models/uptime_test_overview.rb +388 -0
  49. data/lib/statuscake/models/uptime_test_period.rb +291 -0
  50. data/lib/statuscake/models/uptime_test_periods.rb +269 -0
  51. data/lib/statuscake/models/uptime_test_processing_state.rb +58 -0
  52. data/lib/statuscake/models/uptime_test_response.rb +241 -0
  53. data/lib/statuscake/models/uptime_test_status.rb +56 -0
  54. data/lib/statuscake/models/uptime_test_type.rb +61 -0
  55. data/lib/statuscake/models/uptime_tests.rb +258 -0
  56. data/lib/statuscake/version.rb +32 -0
  57. data/lib/statuscake.rb +107 -0
  58. metadata +221 -0
@@ -0,0 +1,388 @@
1
+ # frozen_string_literal: true
2
+
3
+ # StatusCake API
4
+ #
5
+ # Copyright (c) 2022
6
+ #
7
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ # of this software and associated documentation files (the "Software"), to
9
+ # deal in the Software without restriction, including without limitation the
10
+ # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
11
+ # sell copies of the Software, and to permit persons to whom the Software is
12
+ # furnished to do so, subject to the following conditions:
13
+ #
14
+ # The above copyright notice and this permission notice shall be included in
15
+ # all copies or substantial portions of the Software.
16
+ #
17
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22
+ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
23
+ # IN THE SOFTWARE.
24
+ #
25
+ # API version: 1.0.0
26
+ # Contact: support@statuscake.com
27
+ #
28
+ # Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
29
+
30
+ require 'date'
31
+ require 'time'
32
+
33
+ module StatusCake
34
+ # :nodoc
35
+ class UptimeTestOverview
36
+ # Uptime check ID
37
+ attr_accessor :id
38
+
39
+ # Name of the check
40
+ attr_accessor :name
41
+
42
+ # URL or IP address of the server under test
43
+ attr_accessor :website_url
44
+
45
+ attr_accessor :test_type
46
+
47
+ attr_accessor :check_rate
48
+
49
+ # List of contact group IDs
50
+ attr_accessor :contact_groups
51
+
52
+ # Whether the check should be run
53
+ attr_accessor :paused
54
+
55
+ attr_accessor :status
56
+
57
+ # List of tags
58
+ attr_accessor :tags
59
+
60
+ # Uptime percentage for a check
61
+ attr_accessor :uptime
62
+
63
+ # Attribute mapping from ruby-style variable name to JSON key.
64
+ def self.attribute_map
65
+ {
66
+ :'id' => :'id',
67
+ :'name' => :'name',
68
+ :'website_url' => :'website_url',
69
+ :'test_type' => :'test_type',
70
+ :'check_rate' => :'check_rate',
71
+ :'contact_groups' => :'contact_groups',
72
+ :'paused' => :'paused',
73
+ :'status' => :'status',
74
+ :'tags' => :'tags',
75
+ :'uptime' => :'uptime',
76
+ }
77
+ end
78
+
79
+ # Returns all the JSON keys this model knows about
80
+ def self.acceptable_attributes
81
+ attribute_map.values
82
+ end
83
+
84
+ # Attribute type mapping.
85
+ def self.openapi_types
86
+ {
87
+ :'id' => :'String',
88
+ :'name' => :'String',
89
+ :'website_url' => :'String',
90
+ :'test_type' => :'UptimeTestType',
91
+ :'check_rate' => :'UptimeTestCheckRate',
92
+ :'contact_groups' => :'Array<String>',
93
+ :'paused' => :'Boolean',
94
+ :'status' => :'UptimeTestStatus',
95
+ :'tags' => :'Array<String>',
96
+ :'uptime' => :'Float',
97
+ }
98
+ end
99
+
100
+ # List of attributes with nullable: true
101
+ def self.openapi_nullable
102
+ Set.new([])
103
+ end
104
+
105
+ # Initializes the object
106
+ # @param [Hash] attributes Model attributes in the form of hash
107
+ def initialize(attributes = {})
108
+ unless attributes.is_a?(Hash)
109
+ raise ArgumentError, "The input argument (attributes) must be a hash in `StatusCake::UptimeTestOverview` initialize method"
110
+ end
111
+
112
+ # check to see if the attribute exists and convert string to symbol for hash key
113
+ attributes = attributes.each_with_object({}) { |(k, v), h|
114
+ unless self.class.attribute_map.key?(k.to_sym)
115
+ raise ArgumentError, "`#{k}` is not a valid attribute in `StatusCake::UptimeTestOverview`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
116
+ end
117
+ h[k.to_sym] = v
118
+ }
119
+
120
+ if attributes.key?(:'id')
121
+ self.id = attributes[:'id']
122
+ end
123
+
124
+ if attributes.key?(:'name')
125
+ self.name = attributes[:'name']
126
+ end
127
+
128
+ if attributes.key?(:'website_url')
129
+ self.website_url = attributes[:'website_url']
130
+ end
131
+
132
+ if attributes.key?(:'test_type')
133
+ self.test_type = attributes[:'test_type']
134
+ end
135
+
136
+ if attributes.key?(:'check_rate')
137
+ self.check_rate = attributes[:'check_rate']
138
+ end
139
+
140
+ if attributes.key?(:'contact_groups')
141
+ if (value = attributes[:'contact_groups']).is_a?(Array)
142
+ self.contact_groups = value
143
+ end
144
+ end
145
+
146
+ if attributes.key?(:'paused')
147
+ self.paused = attributes[:'paused']
148
+ end
149
+
150
+ if attributes.key?(:'status')
151
+ self.status = attributes[:'status']
152
+ end
153
+
154
+ if attributes.key?(:'tags')
155
+ if (value = attributes[:'tags']).is_a?(Array)
156
+ self.tags = value
157
+ end
158
+ end
159
+
160
+ if attributes.key?(:'uptime')
161
+ self.uptime = attributes[:'uptime']
162
+ end
163
+ end
164
+
165
+ # Show invalid properties with the reasons. Usually used together with valid?
166
+ # @return Array for valid properties with the reasons
167
+ def list_invalid_properties
168
+ invalid_properties = []
169
+ if @id.nil?
170
+ invalid_properties.push('invalid value for "id", id cannot be nil.')
171
+ end
172
+
173
+ if @name.nil?
174
+ invalid_properties.push('invalid value for "name", name cannot be nil.')
175
+ end
176
+
177
+ if @website_url.nil?
178
+ invalid_properties.push('invalid value for "website_url", website_url cannot be nil.')
179
+ end
180
+
181
+ if @test_type.nil?
182
+ invalid_properties.push('invalid value for "test_type", test_type cannot be nil.')
183
+ end
184
+
185
+ if @check_rate.nil?
186
+ invalid_properties.push('invalid value for "check_rate", check_rate cannot be nil.')
187
+ end
188
+
189
+ if @contact_groups.nil?
190
+ invalid_properties.push('invalid value for "contact_groups", contact_groups cannot be nil.')
191
+ end
192
+
193
+ if @paused.nil?
194
+ invalid_properties.push('invalid value for "paused", paused cannot be nil.')
195
+ end
196
+
197
+ if @status.nil?
198
+ invalid_properties.push('invalid value for "status", status cannot be nil.')
199
+ end
200
+
201
+ if @tags.nil?
202
+ invalid_properties.push('invalid value for "tags", tags cannot be nil.')
203
+ end
204
+
205
+ if !@uptime.nil? && @uptime < 0
206
+ invalid_properties.push('invalid value for "uptime", must be greater than or equal to 0.')
207
+ end
208
+
209
+ invalid_properties
210
+ end
211
+
212
+ # Check to see if the all the properties in the model are valid
213
+ # @return true if the model is valid
214
+ def valid?
215
+ return false if @id.nil?
216
+ return false if @name.nil?
217
+ return false if @website_url.nil?
218
+ return false if @test_type.nil?
219
+ return false if @check_rate.nil?
220
+ return false if @contact_groups.nil?
221
+ return false if @paused.nil?
222
+ return false if @status.nil?
223
+ return false if @tags.nil?
224
+ return false if !@uptime.nil? && @uptime < 0
225
+ true
226
+ end
227
+
228
+ # Custom attribute writer method with validation
229
+ # @param [Object] uptime Value to be assigned
230
+ def uptime=(uptime)
231
+ if !uptime.nil? && uptime < 0
232
+ raise ArgumentError, 'invalid value for "uptime", must be greater than or equal to 0.'
233
+ end
234
+
235
+ @uptime = uptime
236
+ end
237
+
238
+ # Checks equality by comparing each attribute.
239
+ # @param [Object] Object to be compared
240
+ def ==(other)
241
+ return true if equal?(other)
242
+ self.class == other.class &&
243
+ id == other.id &&
244
+ name == other.name &&
245
+ website_url == other.website_url &&
246
+ test_type == other.test_type &&
247
+ check_rate == other.check_rate &&
248
+ contact_groups == other.contact_groups &&
249
+ paused == other.paused &&
250
+ status == other.status &&
251
+ tags == other.tags &&
252
+ uptime == other.uptime
253
+ end
254
+
255
+ # @see the `==` method
256
+ # @param [Object] Object to be compared
257
+ def eql?(other)
258
+ self == other
259
+ end
260
+
261
+ # Calculates hash code according to all attributes.
262
+ # @return [Integer] Hash code
263
+ def hash
264
+ [id, name, website_url, test_type, check_rate, contact_groups, paused, status, tags, uptime].hash
265
+ end
266
+
267
+ # Builds the object from hash
268
+ # @param [Hash] attributes Model attributes in the form of hash
269
+ # @return [Object] Returns the model itself
270
+ def self.build_from_hash(attributes)
271
+ new.build_from_hash(attributes)
272
+ end
273
+
274
+ # Builds the object from hash
275
+ # @param [Hash] attributes Model attributes in the form of hash
276
+ # @return [Object] Returns the model itself
277
+ def build_from_hash(attributes)
278
+ return nil unless attributes.is_a?(Hash)
279
+ attributes = attributes.transform_keys(&:to_sym)
280
+ self.class.openapi_types.each_pair do |key, type|
281
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
282
+ send("#{key}=", nil)
283
+ elsif type =~ /\AArray<(.*)>/i
284
+ # check to ensure the input is an array given that the attribute
285
+ # is documented as an array but the input is not
286
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
287
+ send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize(Regexp.last_match(1), v) })
288
+ end
289
+ elsif !attributes[self.class.attribute_map[key]].nil?
290
+ send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
291
+ end
292
+ end
293
+
294
+ self
295
+ end
296
+
297
+ # Deserializes the data based on type
298
+ # @param string type Data type
299
+ # @param string value Value to be deserialized
300
+ # @return [Object] Deserialized data
301
+ def _deserialize(type, value)
302
+ case type.to_sym
303
+ when :Time
304
+ Time.parse(value)
305
+ when :Date
306
+ Date.parse(value)
307
+ when :String
308
+ value.to_s
309
+ when :Integer
310
+ value.to_i
311
+ when :Float
312
+ value.to_f
313
+ when :Boolean
314
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
315
+ true
316
+ else
317
+ false
318
+ end
319
+ when :Object
320
+ # generic object (usually a Hash), return directly
321
+ value
322
+ when /\AArray<(?<inner_type>.+)>\z/
323
+ inner_type = Regexp.last_match[:inner_type]
324
+ value.map { |v| _deserialize(inner_type, v) }
325
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
326
+ k_type = Regexp.last_match[:k_type]
327
+ v_type = Regexp.last_match[:v_type]
328
+ {}.tap do |hash|
329
+ value.each do |k, v|
330
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
331
+ end
332
+ end
333
+ else # model
334
+ # models (e.g. Pet) or oneOf
335
+ klass = StatusCake.const_get(type)
336
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
337
+ end
338
+ end
339
+
340
+ # Returns the string representation of the object
341
+ # @return [String] String presentation of the object
342
+ def to_s
343
+ to_hash.to_s
344
+ end
345
+
346
+ # to_body is an alias to to_hash (backward compatibility)
347
+ # @return [Hash] Returns the object in the form of hash
348
+ def to_body
349
+ to_hash
350
+ end
351
+
352
+ # Returns the object in the form of hash
353
+ # @return [Hash] Returns the object in the form of hash
354
+ def to_hash
355
+ hash = {}
356
+ self.class.attribute_map.each_pair do |attr, param|
357
+ value = send(attr)
358
+ if value.nil?
359
+ is_nullable = self.class.openapi_nullable.include?(attr)
360
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
361
+ end
362
+
363
+ hash[param] = _to_hash(value)
364
+ end
365
+ hash
366
+ end
367
+
368
+ # Outputs non-array value in the form of hash
369
+ # For object, use to_hash. Otherwise, just return the value
370
+ # @param [Object] value Any valid value
371
+ # @return [Hash] Returns the value in the form of hash
372
+ def _to_hash(value)
373
+ if value.is_a?(Array)
374
+ value.compact.map { |v| _to_hash(v) }
375
+ elsif value.is_a?(Hash)
376
+ {}.tap do |hash|
377
+ value.each { |k, v| hash[k] = _to_hash(v) }
378
+ end
379
+ elsif value.respond_to? :to_hash
380
+ value.to_hash
381
+ else
382
+ value
383
+ end
384
+ end
385
+
386
+ end
387
+
388
+ end
@@ -0,0 +1,291 @@
1
+ # frozen_string_literal: true
2
+
3
+ # StatusCake API
4
+ #
5
+ # Copyright (c) 2022
6
+ #
7
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ # of this software and associated documentation files (the "Software"), to
9
+ # deal in the Software without restriction, including without limitation the
10
+ # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
11
+ # sell copies of the Software, and to permit persons to whom the Software is
12
+ # furnished to do so, subject to the following conditions:
13
+ #
14
+ # The above copyright notice and this permission notice shall be included in
15
+ # all copies or substantial portions of the Software.
16
+ #
17
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22
+ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
23
+ # IN THE SOFTWARE.
24
+ #
25
+ # API version: 1.0.0
26
+ # Contact: support@statuscake.com
27
+ #
28
+ # Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
29
+
30
+ require 'date'
31
+ require 'time'
32
+
33
+ module StatusCake
34
+ # :nodoc
35
+ class UptimeTestPeriod
36
+ # When the status period was created (RFC3339 format)
37
+ attr_accessor :created_at
38
+
39
+ # Status period duration (ms)
40
+ attr_accessor :duration
41
+
42
+ # When the status period ended (RFC3339 format)
43
+ attr_accessor :ended_at
44
+
45
+ attr_accessor :status
46
+
47
+ # Attribute mapping from ruby-style variable name to JSON key.
48
+ def self.attribute_map
49
+ {
50
+ :'created_at' => :'created_at',
51
+ :'duration' => :'duration',
52
+ :'ended_at' => :'ended_at',
53
+ :'status' => :'status',
54
+ }
55
+ end
56
+
57
+ # Returns all the JSON keys this model knows about
58
+ def self.acceptable_attributes
59
+ attribute_map.values
60
+ end
61
+
62
+ # Attribute type mapping.
63
+ def self.openapi_types
64
+ {
65
+ :'created_at' => :'Time',
66
+ :'duration' => :'Integer',
67
+ :'ended_at' => :'Time',
68
+ :'status' => :'UptimeTestStatus',
69
+ }
70
+ end
71
+
72
+ # List of attributes with nullable: true
73
+ def self.openapi_nullable
74
+ Set.new([])
75
+ end
76
+
77
+ # Initializes the object
78
+ # @param [Hash] attributes Model attributes in the form of hash
79
+ def initialize(attributes = {})
80
+ unless attributes.is_a?(Hash)
81
+ raise ArgumentError, "The input argument (attributes) must be a hash in `StatusCake::UptimeTestPeriod` initialize method"
82
+ end
83
+
84
+ # check to see if the attribute exists and convert string to symbol for hash key
85
+ attributes = attributes.each_with_object({}) { |(k, v), h|
86
+ unless self.class.attribute_map.key?(k.to_sym)
87
+ raise ArgumentError, "`#{k}` is not a valid attribute in `StatusCake::UptimeTestPeriod`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
88
+ end
89
+ h[k.to_sym] = v
90
+ }
91
+
92
+ if attributes.key?(:'created_at')
93
+ self.created_at = attributes[:'created_at']
94
+ end
95
+
96
+ if attributes.key?(:'duration')
97
+ self.duration = attributes[:'duration']
98
+ end
99
+
100
+ if attributes.key?(:'ended_at')
101
+ self.ended_at = attributes[:'ended_at']
102
+ end
103
+
104
+ if attributes.key?(:'status')
105
+ self.status = attributes[:'status']
106
+ end
107
+ end
108
+
109
+ # Show invalid properties with the reasons. Usually used together with valid?
110
+ # @return Array for valid properties with the reasons
111
+ def list_invalid_properties
112
+ invalid_properties = []
113
+ if @created_at.nil?
114
+ invalid_properties.push('invalid value for "created_at", created_at cannot be nil.')
115
+ end
116
+
117
+ if !@duration.nil? && @duration < 0
118
+ invalid_properties.push('invalid value for "duration", must be greater than or equal to 0.')
119
+ end
120
+
121
+ if @status.nil?
122
+ invalid_properties.push('invalid value for "status", status cannot be nil.')
123
+ end
124
+
125
+ invalid_properties
126
+ end
127
+
128
+ # Check to see if the all the properties in the model are valid
129
+ # @return true if the model is valid
130
+ def valid?
131
+ return false if @created_at.nil?
132
+ return false if !@duration.nil? && @duration < 0
133
+ return false if @status.nil?
134
+ true
135
+ end
136
+
137
+ # Custom attribute writer method with validation
138
+ # @param [Object] duration Value to be assigned
139
+ def duration=(duration)
140
+ if !duration.nil? && duration < 0
141
+ raise ArgumentError, 'invalid value for "duration", must be greater than or equal to 0.'
142
+ end
143
+
144
+ @duration = duration
145
+ end
146
+
147
+ # Checks equality by comparing each attribute.
148
+ # @param [Object] Object to be compared
149
+ def ==(other)
150
+ return true if equal?(other)
151
+ self.class == other.class &&
152
+ created_at == other.created_at &&
153
+ duration == other.duration &&
154
+ ended_at == other.ended_at &&
155
+ status == other.status
156
+ end
157
+
158
+ # @see the `==` method
159
+ # @param [Object] Object to be compared
160
+ def eql?(other)
161
+ self == other
162
+ end
163
+
164
+ # Calculates hash code according to all attributes.
165
+ # @return [Integer] Hash code
166
+ def hash
167
+ [created_at, duration, ended_at, status].hash
168
+ end
169
+
170
+ # Builds the object from hash
171
+ # @param [Hash] attributes Model attributes in the form of hash
172
+ # @return [Object] Returns the model itself
173
+ def self.build_from_hash(attributes)
174
+ new.build_from_hash(attributes)
175
+ end
176
+
177
+ # Builds the object from hash
178
+ # @param [Hash] attributes Model attributes in the form of hash
179
+ # @return [Object] Returns the model itself
180
+ def build_from_hash(attributes)
181
+ return nil unless attributes.is_a?(Hash)
182
+ attributes = attributes.transform_keys(&:to_sym)
183
+ self.class.openapi_types.each_pair do |key, type|
184
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
185
+ send("#{key}=", nil)
186
+ elsif type =~ /\AArray<(.*)>/i
187
+ # check to ensure the input is an array given that the attribute
188
+ # is documented as an array but the input is not
189
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
190
+ send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize(Regexp.last_match(1), v) })
191
+ end
192
+ elsif !attributes[self.class.attribute_map[key]].nil?
193
+ send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
194
+ end
195
+ end
196
+
197
+ self
198
+ end
199
+
200
+ # Deserializes the data based on type
201
+ # @param string type Data type
202
+ # @param string value Value to be deserialized
203
+ # @return [Object] Deserialized data
204
+ def _deserialize(type, value)
205
+ case type.to_sym
206
+ when :Time
207
+ Time.parse(value)
208
+ when :Date
209
+ Date.parse(value)
210
+ when :String
211
+ value.to_s
212
+ when :Integer
213
+ value.to_i
214
+ when :Float
215
+ value.to_f
216
+ when :Boolean
217
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
218
+ true
219
+ else
220
+ false
221
+ end
222
+ when :Object
223
+ # generic object (usually a Hash), return directly
224
+ value
225
+ when /\AArray<(?<inner_type>.+)>\z/
226
+ inner_type = Regexp.last_match[:inner_type]
227
+ value.map { |v| _deserialize(inner_type, v) }
228
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
229
+ k_type = Regexp.last_match[:k_type]
230
+ v_type = Regexp.last_match[:v_type]
231
+ {}.tap do |hash|
232
+ value.each do |k, v|
233
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
234
+ end
235
+ end
236
+ else # model
237
+ # models (e.g. Pet) or oneOf
238
+ klass = StatusCake.const_get(type)
239
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
240
+ end
241
+ end
242
+
243
+ # Returns the string representation of the object
244
+ # @return [String] String presentation of the object
245
+ def to_s
246
+ to_hash.to_s
247
+ end
248
+
249
+ # to_body is an alias to to_hash (backward compatibility)
250
+ # @return [Hash] Returns the object in the form of hash
251
+ def to_body
252
+ to_hash
253
+ end
254
+
255
+ # Returns the object in the form of hash
256
+ # @return [Hash] Returns the object in the form of hash
257
+ def to_hash
258
+ hash = {}
259
+ self.class.attribute_map.each_pair do |attr, param|
260
+ value = send(attr)
261
+ if value.nil?
262
+ is_nullable = self.class.openapi_nullable.include?(attr)
263
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
264
+ end
265
+
266
+ hash[param] = _to_hash(value)
267
+ end
268
+ hash
269
+ end
270
+
271
+ # Outputs non-array value in the form of hash
272
+ # For object, use to_hash. Otherwise, just return the value
273
+ # @param [Object] value Any valid value
274
+ # @return [Hash] Returns the value in the form of hash
275
+ def _to_hash(value)
276
+ if value.is_a?(Array)
277
+ value.compact.map { |v| _to_hash(v) }
278
+ elsif value.is_a?(Hash)
279
+ {}.tap do |hash|
280
+ value.each { |k, v| hash[k] = _to_hash(v) }
281
+ end
282
+ elsif value.respond_to? :to_hash
283
+ value.to_hash
284
+ else
285
+ value
286
+ end
287
+ end
288
+
289
+ end
290
+
291
+ end