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,244 @@
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 MonitoringLocations
36
+ # List of monitoring locations
37
+ attr_accessor :data
38
+
39
+ # Attribute mapping from ruby-style variable name to JSON key.
40
+ def self.attribute_map
41
+ {
42
+ :'data' => :'data',
43
+ }
44
+ end
45
+
46
+ # Returns all the JSON keys this model knows about
47
+ def self.acceptable_attributes
48
+ attribute_map.values
49
+ end
50
+
51
+ # Attribute type mapping.
52
+ def self.openapi_types
53
+ {
54
+ :'data' => :'Array<MonitoringLocation>',
55
+ }
56
+ end
57
+
58
+ # List of attributes with nullable: true
59
+ def self.openapi_nullable
60
+ Set.new([])
61
+ end
62
+
63
+ # Initializes the object
64
+ # @param [Hash] attributes Model attributes in the form of hash
65
+ def initialize(attributes = {})
66
+ unless attributes.is_a?(Hash)
67
+ raise ArgumentError, "The input argument (attributes) must be a hash in `StatusCake::MonitoringLocations` initialize method"
68
+ end
69
+
70
+ # check to see if the attribute exists and convert string to symbol for hash key
71
+ attributes = attributes.each_with_object({}) { |(k, v), h|
72
+ unless self.class.attribute_map.key?(k.to_sym)
73
+ raise ArgumentError, "`#{k}` is not a valid attribute in `StatusCake::MonitoringLocations`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
74
+ end
75
+ h[k.to_sym] = v
76
+ }
77
+
78
+ if attributes.key?(:'data')
79
+ if (value = attributes[:'data']).is_a?(Array)
80
+ self.data = value
81
+ end
82
+ end
83
+ end
84
+
85
+ # Show invalid properties with the reasons. Usually used together with valid?
86
+ # @return Array for valid properties with the reasons
87
+ def list_invalid_properties
88
+ invalid_properties = []
89
+ if @data.nil?
90
+ invalid_properties.push('invalid value for "data", data cannot be nil.')
91
+ end
92
+
93
+ invalid_properties
94
+ end
95
+
96
+ # Check to see if the all the properties in the model are valid
97
+ # @return true if the model is valid
98
+ def valid?
99
+ return false if @data.nil?
100
+ true
101
+ end
102
+
103
+ # Checks equality by comparing each attribute.
104
+ # @param [Object] Object to be compared
105
+ def ==(other)
106
+ return true if equal?(other)
107
+ self.class == other.class &&
108
+ data == other.data
109
+ end
110
+
111
+ # @see the `==` method
112
+ # @param [Object] Object to be compared
113
+ def eql?(other)
114
+ self == other
115
+ end
116
+
117
+ # Calculates hash code according to all attributes.
118
+ # @return [Integer] Hash code
119
+ def hash
120
+ [data].hash
121
+ end
122
+
123
+ # Builds the object from hash
124
+ # @param [Hash] attributes Model attributes in the form of hash
125
+ # @return [Object] Returns the model itself
126
+ def self.build_from_hash(attributes)
127
+ new.build_from_hash(attributes)
128
+ end
129
+
130
+ # Builds the object from hash
131
+ # @param [Hash] attributes Model attributes in the form of hash
132
+ # @return [Object] Returns the model itself
133
+ def build_from_hash(attributes)
134
+ return nil unless attributes.is_a?(Hash)
135
+ attributes = attributes.transform_keys(&:to_sym)
136
+ self.class.openapi_types.each_pair do |key, type|
137
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
138
+ send("#{key}=", nil)
139
+ elsif type =~ /\AArray<(.*)>/i
140
+ # check to ensure the input is an array given that the attribute
141
+ # is documented as an array but the input is not
142
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
143
+ send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize(Regexp.last_match(1), v) })
144
+ end
145
+ elsif !attributes[self.class.attribute_map[key]].nil?
146
+ send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
147
+ end
148
+ end
149
+
150
+ self
151
+ end
152
+
153
+ # Deserializes the data based on type
154
+ # @param string type Data type
155
+ # @param string value Value to be deserialized
156
+ # @return [Object] Deserialized data
157
+ def _deserialize(type, value)
158
+ case type.to_sym
159
+ when :Time
160
+ Time.parse(value)
161
+ when :Date
162
+ Date.parse(value)
163
+ when :String
164
+ value.to_s
165
+ when :Integer
166
+ value.to_i
167
+ when :Float
168
+ value.to_f
169
+ when :Boolean
170
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
171
+ true
172
+ else
173
+ false
174
+ end
175
+ when :Object
176
+ # generic object (usually a Hash), return directly
177
+ value
178
+ when /\AArray<(?<inner_type>.+)>\z/
179
+ inner_type = Regexp.last_match[:inner_type]
180
+ value.map { |v| _deserialize(inner_type, v) }
181
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
182
+ k_type = Regexp.last_match[:k_type]
183
+ v_type = Regexp.last_match[:v_type]
184
+ {}.tap do |hash|
185
+ value.each do |k, v|
186
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
187
+ end
188
+ end
189
+ else # model
190
+ # models (e.g. Pet) or oneOf
191
+ klass = StatusCake.const_get(type)
192
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
193
+ end
194
+ end
195
+
196
+ # Returns the string representation of the object
197
+ # @return [String] String presentation of the object
198
+ def to_s
199
+ to_hash.to_s
200
+ end
201
+
202
+ # to_body is an alias to to_hash (backward compatibility)
203
+ # @return [Hash] Returns the object in the form of hash
204
+ def to_body
205
+ to_hash
206
+ end
207
+
208
+ # Returns the object in the form of hash
209
+ # @return [Hash] Returns the object in the form of hash
210
+ def to_hash
211
+ hash = {}
212
+ self.class.attribute_map.each_pair do |attr, param|
213
+ value = send(attr)
214
+ if value.nil?
215
+ is_nullable = self.class.openapi_nullable.include?(attr)
216
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
217
+ end
218
+
219
+ hash[param] = _to_hash(value)
220
+ end
221
+ hash
222
+ end
223
+
224
+ # Outputs non-array value in the form of hash
225
+ # For object, use to_hash. Otherwise, just return the value
226
+ # @param [Object] value Any valid value
227
+ # @return [Hash] Returns the value in the form of hash
228
+ def _to_hash(value)
229
+ if value.is_a?(Array)
230
+ value.compact.map { |v| _to_hash(v) }
231
+ elsif value.is_a?(Hash)
232
+ {}.tap do |hash|
233
+ value.each { |k, v| hash[k] = _to_hash(v) }
234
+ end
235
+ elsif value.respond_to? :to_hash
236
+ value.to_hash
237
+ else
238
+ value
239
+ end
240
+ end
241
+
242
+ end
243
+
244
+ end
@@ -0,0 +1,444 @@
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 PagespeedTest
36
+ # Pagespeed check ID
37
+ attr_accessor :id
38
+
39
+ # Name of the check
40
+ attr_accessor :name
41
+
42
+ # URL, FQDN, or IP address of the website under test
43
+ attr_accessor :website_url
44
+
45
+ attr_accessor :check_rate
46
+
47
+ # An alert will be sent if the size of the page is larger than this value (kb). A value of 0 prevents alerts being sent.
48
+ attr_accessor :alert_bigger
49
+
50
+ # An alert will be sent if the load time of the page exceeds this value (ms). A value of 0 prevents alerts being sent
51
+ attr_accessor :alert_slower
52
+
53
+ # An alert will be sent if the size of the page is smaller than this value (kb). A value of 0 prevents alerts being sent
54
+ attr_accessor :alert_smaller
55
+
56
+ # List of contact group IDs
57
+ attr_accessor :contact_groups
58
+
59
+ attr_accessor :latest_stats
60
+
61
+ # Assigned monitoring location on which checks will be run
62
+ attr_accessor :location
63
+
64
+ # Whether the check should be run
65
+ attr_accessor :paused
66
+
67
+ # Attribute mapping from ruby-style variable name to JSON key.
68
+ def self.attribute_map
69
+ {
70
+ :'id' => :'id',
71
+ :'name' => :'name',
72
+ :'website_url' => :'website_url',
73
+ :'check_rate' => :'check_rate',
74
+ :'alert_bigger' => :'alert_bigger',
75
+ :'alert_slower' => :'alert_slower',
76
+ :'alert_smaller' => :'alert_smaller',
77
+ :'contact_groups' => :'contact_groups',
78
+ :'latest_stats' => :'latest_stats',
79
+ :'location' => :'location',
80
+ :'paused' => :'paused',
81
+ }
82
+ end
83
+
84
+ # Returns all the JSON keys this model knows about
85
+ def self.acceptable_attributes
86
+ attribute_map.values
87
+ end
88
+
89
+ # Attribute type mapping.
90
+ def self.openapi_types
91
+ {
92
+ :'id' => :'String',
93
+ :'name' => :'String',
94
+ :'website_url' => :'String',
95
+ :'check_rate' => :'PagespeedTestCheckRate',
96
+ :'alert_bigger' => :'Integer',
97
+ :'alert_slower' => :'Integer',
98
+ :'alert_smaller' => :'Integer',
99
+ :'contact_groups' => :'Array<String>',
100
+ :'latest_stats' => :'PagespeedTestStats',
101
+ :'location' => :'String',
102
+ :'paused' => :'Boolean',
103
+ }
104
+ end
105
+
106
+ # List of attributes with nullable: true
107
+ def self.openapi_nullable
108
+ Set.new([])
109
+ end
110
+
111
+ # Initializes the object
112
+ # @param [Hash] attributes Model attributes in the form of hash
113
+ def initialize(attributes = {})
114
+ unless attributes.is_a?(Hash)
115
+ raise ArgumentError, "The input argument (attributes) must be a hash in `StatusCake::PagespeedTest` initialize method"
116
+ end
117
+
118
+ # check to see if the attribute exists and convert string to symbol for hash key
119
+ attributes = attributes.each_with_object({}) { |(k, v), h|
120
+ unless self.class.attribute_map.key?(k.to_sym)
121
+ raise ArgumentError, "`#{k}` is not a valid attribute in `StatusCake::PagespeedTest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
122
+ end
123
+ h[k.to_sym] = v
124
+ }
125
+
126
+ if attributes.key?(:'id')
127
+ self.id = attributes[:'id']
128
+ end
129
+
130
+ if attributes.key?(:'name')
131
+ self.name = attributes[:'name']
132
+ end
133
+
134
+ if attributes.key?(:'website_url')
135
+ self.website_url = attributes[:'website_url']
136
+ end
137
+
138
+ if attributes.key?(:'check_rate')
139
+ self.check_rate = attributes[:'check_rate']
140
+ end
141
+
142
+ if attributes.key?(:'alert_bigger')
143
+ self.alert_bigger = attributes[:'alert_bigger']
144
+ end
145
+
146
+ if attributes.key?(:'alert_slower')
147
+ self.alert_slower = attributes[:'alert_slower']
148
+ end
149
+
150
+ if attributes.key?(:'alert_smaller')
151
+ self.alert_smaller = attributes[:'alert_smaller']
152
+ end
153
+
154
+ if attributes.key?(:'contact_groups')
155
+ if (value = attributes[:'contact_groups']).is_a?(Array)
156
+ self.contact_groups = value
157
+ end
158
+ end
159
+
160
+ if attributes.key?(:'latest_stats')
161
+ self.latest_stats = attributes[:'latest_stats']
162
+ end
163
+
164
+ if attributes.key?(:'location')
165
+ self.location = attributes[:'location']
166
+ end
167
+
168
+ if attributes.key?(:'paused')
169
+ self.paused = attributes[:'paused']
170
+ end
171
+ end
172
+
173
+ # Show invalid properties with the reasons. Usually used together with valid?
174
+ # @return Array for valid properties with the reasons
175
+ def list_invalid_properties
176
+ invalid_properties = []
177
+ if @id.nil?
178
+ invalid_properties.push('invalid value for "id", id cannot be nil.')
179
+ end
180
+
181
+ if @name.nil?
182
+ invalid_properties.push('invalid value for "name", name cannot be nil.')
183
+ end
184
+
185
+ if @website_url.nil?
186
+ invalid_properties.push('invalid value for "website_url", website_url cannot be nil.')
187
+ end
188
+
189
+ if @check_rate.nil?
190
+ invalid_properties.push('invalid value for "check_rate", check_rate cannot be nil.')
191
+ end
192
+
193
+ if @alert_bigger.nil?
194
+ invalid_properties.push('invalid value for "alert_bigger", alert_bigger cannot be nil.')
195
+ end
196
+
197
+ if @alert_bigger < 0
198
+ invalid_properties.push('invalid value for "alert_bigger", must be greater than or equal to 0.')
199
+ end
200
+
201
+ if @alert_slower.nil?
202
+ invalid_properties.push('invalid value for "alert_slower", alert_slower cannot be nil.')
203
+ end
204
+
205
+ if @alert_slower < 0
206
+ invalid_properties.push('invalid value for "alert_slower", must be greater than or equal to 0.')
207
+ end
208
+
209
+ if @alert_smaller.nil?
210
+ invalid_properties.push('invalid value for "alert_smaller", alert_smaller cannot be nil.')
211
+ end
212
+
213
+ if @alert_smaller < 0
214
+ invalid_properties.push('invalid value for "alert_smaller", must be greater than or equal to 0.')
215
+ end
216
+
217
+ if @contact_groups.nil?
218
+ invalid_properties.push('invalid value for "contact_groups", contact_groups cannot be nil.')
219
+ end
220
+
221
+ if @location.nil?
222
+ invalid_properties.push('invalid value for "location", location cannot be nil.')
223
+ end
224
+
225
+ if @paused.nil?
226
+ invalid_properties.push('invalid value for "paused", paused cannot be nil.')
227
+ end
228
+
229
+ invalid_properties
230
+ end
231
+
232
+ # Check to see if the all the properties in the model are valid
233
+ # @return true if the model is valid
234
+ def valid?
235
+ return false if @id.nil?
236
+ return false if @name.nil?
237
+ return false if @website_url.nil?
238
+ return false if @check_rate.nil?
239
+ return false if @alert_bigger.nil?
240
+ return false if @alert_bigger < 0
241
+ return false if @alert_slower.nil?
242
+ return false if @alert_slower < 0
243
+ return false if @alert_smaller.nil?
244
+ return false if @alert_smaller < 0
245
+ return false if @contact_groups.nil?
246
+ return false if @location.nil?
247
+ return false if @paused.nil?
248
+ true
249
+ end
250
+
251
+ # Custom attribute writer method with validation
252
+ # @param [Object] alert_bigger Value to be assigned
253
+ def alert_bigger=(alert_bigger)
254
+ if alert_bigger.nil?
255
+ raise ArgumentError, 'alert_bigger cannot be nil'
256
+ end
257
+
258
+ if alert_bigger < 0
259
+ raise ArgumentError, 'invalid value for "alert_bigger", must be greater than or equal to 0.'
260
+ end
261
+
262
+ @alert_bigger = alert_bigger
263
+ end
264
+
265
+ # Custom attribute writer method with validation
266
+ # @param [Object] alert_slower Value to be assigned
267
+ def alert_slower=(alert_slower)
268
+ if alert_slower.nil?
269
+ raise ArgumentError, 'alert_slower cannot be nil'
270
+ end
271
+
272
+ if alert_slower < 0
273
+ raise ArgumentError, 'invalid value for "alert_slower", must be greater than or equal to 0.'
274
+ end
275
+
276
+ @alert_slower = alert_slower
277
+ end
278
+
279
+ # Custom attribute writer method with validation
280
+ # @param [Object] alert_smaller Value to be assigned
281
+ def alert_smaller=(alert_smaller)
282
+ if alert_smaller.nil?
283
+ raise ArgumentError, 'alert_smaller cannot be nil'
284
+ end
285
+
286
+ if alert_smaller < 0
287
+ raise ArgumentError, 'invalid value for "alert_smaller", must be greater than or equal to 0.'
288
+ end
289
+
290
+ @alert_smaller = alert_smaller
291
+ end
292
+
293
+ # Checks equality by comparing each attribute.
294
+ # @param [Object] Object to be compared
295
+ def ==(other)
296
+ return true if equal?(other)
297
+ self.class == other.class &&
298
+ id == other.id &&
299
+ name == other.name &&
300
+ website_url == other.website_url &&
301
+ check_rate == other.check_rate &&
302
+ alert_bigger == other.alert_bigger &&
303
+ alert_slower == other.alert_slower &&
304
+ alert_smaller == other.alert_smaller &&
305
+ contact_groups == other.contact_groups &&
306
+ latest_stats == other.latest_stats &&
307
+ location == other.location &&
308
+ paused == other.paused
309
+ end
310
+
311
+ # @see the `==` method
312
+ # @param [Object] Object to be compared
313
+ def eql?(other)
314
+ self == other
315
+ end
316
+
317
+ # Calculates hash code according to all attributes.
318
+ # @return [Integer] Hash code
319
+ def hash
320
+ [id, name, website_url, check_rate, alert_bigger, alert_slower, alert_smaller, contact_groups, latest_stats, location, paused].hash
321
+ end
322
+
323
+ # Builds the object from hash
324
+ # @param [Hash] attributes Model attributes in the form of hash
325
+ # @return [Object] Returns the model itself
326
+ def self.build_from_hash(attributes)
327
+ new.build_from_hash(attributes)
328
+ end
329
+
330
+ # Builds the object from hash
331
+ # @param [Hash] attributes Model attributes in the form of hash
332
+ # @return [Object] Returns the model itself
333
+ def build_from_hash(attributes)
334
+ return nil unless attributes.is_a?(Hash)
335
+ attributes = attributes.transform_keys(&:to_sym)
336
+ self.class.openapi_types.each_pair do |key, type|
337
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
338
+ send("#{key}=", nil)
339
+ elsif type =~ /\AArray<(.*)>/i
340
+ # check to ensure the input is an array given that the attribute
341
+ # is documented as an array but the input is not
342
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
343
+ send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize(Regexp.last_match(1), v) })
344
+ end
345
+ elsif !attributes[self.class.attribute_map[key]].nil?
346
+ send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
347
+ end
348
+ end
349
+
350
+ self
351
+ end
352
+
353
+ # Deserializes the data based on type
354
+ # @param string type Data type
355
+ # @param string value Value to be deserialized
356
+ # @return [Object] Deserialized data
357
+ def _deserialize(type, value)
358
+ case type.to_sym
359
+ when :Time
360
+ Time.parse(value)
361
+ when :Date
362
+ Date.parse(value)
363
+ when :String
364
+ value.to_s
365
+ when :Integer
366
+ value.to_i
367
+ when :Float
368
+ value.to_f
369
+ when :Boolean
370
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
371
+ true
372
+ else
373
+ false
374
+ end
375
+ when :Object
376
+ # generic object (usually a Hash), return directly
377
+ value
378
+ when /\AArray<(?<inner_type>.+)>\z/
379
+ inner_type = Regexp.last_match[:inner_type]
380
+ value.map { |v| _deserialize(inner_type, v) }
381
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
382
+ k_type = Regexp.last_match[:k_type]
383
+ v_type = Regexp.last_match[:v_type]
384
+ {}.tap do |hash|
385
+ value.each do |k, v|
386
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
387
+ end
388
+ end
389
+ else # model
390
+ # models (e.g. Pet) or oneOf
391
+ klass = StatusCake.const_get(type)
392
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
393
+ end
394
+ end
395
+
396
+ # Returns the string representation of the object
397
+ # @return [String] String presentation of the object
398
+ def to_s
399
+ to_hash.to_s
400
+ end
401
+
402
+ # to_body is an alias to to_hash (backward compatibility)
403
+ # @return [Hash] Returns the object in the form of hash
404
+ def to_body
405
+ to_hash
406
+ end
407
+
408
+ # Returns the object in the form of hash
409
+ # @return [Hash] Returns the object in the form of hash
410
+ def to_hash
411
+ hash = {}
412
+ self.class.attribute_map.each_pair do |attr, param|
413
+ value = send(attr)
414
+ if value.nil?
415
+ is_nullable = self.class.openapi_nullable.include?(attr)
416
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
417
+ end
418
+
419
+ hash[param] = _to_hash(value)
420
+ end
421
+ hash
422
+ end
423
+
424
+ # Outputs non-array value in the form of hash
425
+ # For object, use to_hash. Otherwise, just return the value
426
+ # @param [Object] value Any valid value
427
+ # @return [Hash] Returns the value in the form of hash
428
+ def _to_hash(value)
429
+ if value.is_a?(Array)
430
+ value.compact.map { |v| _to_hash(v) }
431
+ elsif value.is_a?(Hash)
432
+ {}.tap do |hash|
433
+ value.each { |k, v| hash[k] = _to_hash(v) }
434
+ end
435
+ elsif value.respond_to? :to_hash
436
+ value.to_hash
437
+ else
438
+ value
439
+ end
440
+ end
441
+
442
+ end
443
+
444
+ end