svix 0.16.0 → 0.34.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (79) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +9 -3
  3. data/README.md +16 -3
  4. data/lib/svix/api/application_api.rb +386 -0
  5. data/lib/svix/api/authentication_api.rb +155 -0
  6. data/lib/svix/api/endpoint_api.rb +877 -0
  7. data/lib/svix/api/event_type_api.rb +454 -0
  8. data/lib/svix/api/health_api.rb +77 -0
  9. data/lib/svix/api/message_api.rb +289 -0
  10. data/lib/svix/api/message_attempt_api.rb +678 -0
  11. data/lib/svix/api_client.rb +399 -0
  12. data/lib/svix/api_error.rb +57 -0
  13. data/lib/svix/application_api.rb +29 -0
  14. data/lib/svix/authentication_api.rb +17 -0
  15. data/lib/svix/configuration.rb +277 -0
  16. data/lib/svix/endpoint_api.rb +38 -0
  17. data/{src → lib}/svix/errors.rb +4 -1
  18. data/lib/svix/event_type_api.rb +25 -0
  19. data/lib/svix/internal.rb +16 -0
  20. data/lib/svix/message_api.rb +21 -0
  21. data/lib/svix/message_attempt_api.rb +33 -0
  22. data/lib/svix/models/application_in.rb +277 -0
  23. data/lib/svix/models/application_out.rb +305 -0
  24. data/lib/svix/models/dashboard_access_out.rb +265 -0
  25. data/lib/svix/models/endpoint_created_event.rb +269 -0
  26. data/lib/svix/models/endpoint_created_event_data.rb +282 -0
  27. data/lib/svix/models/endpoint_deleted_event.rb +269 -0
  28. data/lib/svix/models/endpoint_deleted_event_data.rb +282 -0
  29. data/lib/svix/models/endpoint_disabled_event.rb +269 -0
  30. data/lib/svix/models/endpoint_disabled_event_data.rb +296 -0
  31. data/lib/svix/models/endpoint_in.rb +394 -0
  32. data/lib/svix/models/endpoint_message_out.rb +363 -0
  33. data/lib/svix/models/endpoint_out.rb +395 -0
  34. data/lib/svix/models/endpoint_secret_out.rb +245 -0
  35. data/lib/svix/models/endpoint_secret_rotate_in.rb +236 -0
  36. data/lib/svix/models/endpoint_stats.rb +265 -0
  37. data/lib/svix/models/endpoint_update.rb +367 -0
  38. data/lib/svix/models/endpoint_updated_event.rb +269 -0
  39. data/lib/svix/models/endpoint_updated_event_data.rb +282 -0
  40. data/lib/svix/models/endpointd_updated_event.rb +269 -0
  41. data/lib/svix/models/event_example_in.rb +253 -0
  42. data/lib/svix/models/event_type_example_out.rb +223 -0
  43. data/lib/svix/models/event_type_in.rb +290 -0
  44. data/lib/svix/models/event_type_out.rb +290 -0
  45. data/lib/svix/models/event_type_schema_in.rb +224 -0
  46. data/lib/svix/models/event_type_update.rb +246 -0
  47. data/lib/svix/models/http_error_out.rb +237 -0
  48. data/lib/svix/models/http_validation_error.rb +220 -0
  49. data/lib/svix/models/list_response_application_out.rb +248 -0
  50. data/lib/svix/models/list_response_endpoint_message_out.rb +248 -0
  51. data/lib/svix/models/list_response_endpoint_out.rb +248 -0
  52. data/lib/svix/models/list_response_event_type_out.rb +248 -0
  53. data/lib/svix/models/list_response_message_attempt_endpoint_out.rb +248 -0
  54. data/lib/svix/models/list_response_message_attempt_out.rb +248 -0
  55. data/lib/svix/models/list_response_message_endpoint_out.rb +248 -0
  56. data/lib/svix/models/list_response_message_out.rb +248 -0
  57. data/lib/svix/models/message_attempt_endpoint_out.rb +293 -0
  58. data/lib/svix/models/message_attempt_exhausted_event.rb +269 -0
  59. data/lib/svix/models/message_attempt_exhausted_event_data.rb +310 -0
  60. data/lib/svix/models/message_attempt_failed_event.rb +251 -0
  61. data/lib/svix/models/message_attempt_out.rb +307 -0
  62. data/lib/svix/models/message_attempt_trigger_type.rb +37 -0
  63. data/lib/svix/models/message_endpoint_out.rb +418 -0
  64. data/lib/svix/models/message_in.rb +312 -0
  65. data/lib/svix/models/message_out.rb +340 -0
  66. data/lib/svix/models/message_status.rb +39 -0
  67. data/lib/svix/models/validation_error.rb +253 -0
  68. data/lib/svix/models/webhook_types.rb +280 -0
  69. data/lib/svix/svix.rb +43 -0
  70. data/{src → lib}/svix/util.rb +1 -1
  71. data/lib/svix/version.rb +5 -0
  72. data/lib/svix/webhook.rb +75 -0
  73. data/lib/svix.rb +77 -0
  74. data/svix.gemspec +19 -9
  75. metadata +97 -13
  76. data/.gitignore +0 -9
  77. data/src/svix/version.rb +0 -3
  78. data/src/svix/webhook.rb +0 -33
  79. data/src/svix.rb +0 -8
@@ -0,0 +1,367 @@
1
+ =begin
2
+ #Svix API
3
+
4
+ #Welcome to the Svix API documentation! Useful links: [Homepage](https://www.svix.com) | [Support email](mailto:support+docs@svix.com) | [Blog](https://www.svix.com/blog/) | [Slack Community](https://www.svix.com/slack/) # Introduction This is the reference documentation and schemas for the [Svix webhook service](https://www.svix.com) API. For tutorials and other documentation please refer to [the documentation](https://docs.svix.com). ## Main concepts In Svix you have four important entities you will be interacting with: - `messages`: these are the webhooks being sent. They can have contents and a few other properties. - `application`: this is where `messages` are sent to. Usually you want to create one application for each of your users. - `endpoint`: endpoints are the URLs messages will be sent to. Each application can have multiple `endpoints` and each message sent to that application will be sent to all of them (unless they are not subscribed to the sent event type). - `event-type`: event types are identifiers denoting the type of the message being sent. Event types are primarily used to decide which events are sent to which endpoint. ## Authentication Get your authentication token (`AUTH_TOKEN`) from the [Svix dashboard](https://dashboard.svix.com) and use it as part of the `Authorization` header as such: `Authorization: Bearer ${AUTH_TOKEN}`. <SecurityDefinitions /> ## Code samples The code samples assume you already have the respective libraries installed and you know how to use them. For the latest information on how to do that, please refer to [the documentation](https://docs.svix.com/). ## Cross-Origin Resource Sharing This API features Cross-Origin Resource Sharing (CORS) implemented in compliance with [W3C spec](https://www.w3.org/TR/cors/). And that allows cross-domain communication from the browser. All responses have a wildcard same-origin which makes them completely public and accessible to everyone, including any code on any site.
5
+
6
+ The version of the OpenAPI document: 1.4
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 5.2.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Svix
17
+ class EndpointUpdate
18
+ attr_accessor :description
19
+
20
+ attr_accessor :disabled
21
+
22
+ attr_accessor :filter_types
23
+
24
+ attr_accessor :rate_limit
25
+
26
+ # Optional unique identifier for the endpoint
27
+ attr_accessor :uid
28
+
29
+ attr_accessor :url
30
+
31
+ attr_accessor :version
32
+
33
+ # Attribute mapping from ruby-style variable name to JSON key.
34
+ def self.attribute_map
35
+ {
36
+ :'description' => :'description',
37
+ :'disabled' => :'disabled',
38
+ :'filter_types' => :'filterTypes',
39
+ :'rate_limit' => :'rateLimit',
40
+ :'uid' => :'uid',
41
+ :'url' => :'url',
42
+ :'version' => :'version'
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
+ :'description' => :'String',
55
+ :'disabled' => :'Boolean',
56
+ :'filter_types' => :'Array<String>',
57
+ :'rate_limit' => :'Integer',
58
+ :'uid' => :'String',
59
+ :'url' => :'String',
60
+ :'version' => :'Integer'
61
+ }
62
+ end
63
+
64
+ # List of attributes with nullable: true
65
+ def self.openapi_nullable
66
+ Set.new([
67
+ ])
68
+ end
69
+
70
+ # Initializes the object
71
+ # @param [Hash] attributes Model attributes in the form of hash
72
+ def initialize(attributes = {})
73
+ if (!attributes.is_a?(Hash))
74
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Svix::EndpointUpdate` initialize method"
75
+ end
76
+
77
+ # check to see if the attribute exists and convert string to symbol for hash key
78
+ attributes = attributes.each_with_object({}) { |(k, v), h|
79
+ if (!self.class.attribute_map.key?(k.to_sym))
80
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Svix::EndpointUpdate`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
81
+ end
82
+ h[k.to_sym] = v
83
+ }
84
+
85
+ if attributes.key?(:'description')
86
+ self.description = attributes[:'description']
87
+ else
88
+ self.description = ''
89
+ end
90
+
91
+ if attributes.key?(:'disabled')
92
+ self.disabled = attributes[:'disabled']
93
+ else
94
+ self.disabled = false
95
+ end
96
+
97
+ if attributes.key?(:'filter_types')
98
+ if (value = attributes[:'filter_types']).is_a?(Array)
99
+ self.filter_types = value
100
+ end
101
+ end
102
+
103
+ if attributes.key?(:'rate_limit')
104
+ self.rate_limit = attributes[:'rate_limit']
105
+ end
106
+
107
+ if attributes.key?(:'uid')
108
+ self.uid = attributes[:'uid']
109
+ end
110
+
111
+ if attributes.key?(:'url')
112
+ self.url = attributes[:'url']
113
+ end
114
+
115
+ if attributes.key?(:'version')
116
+ self.version = attributes[:'version']
117
+ end
118
+ end
119
+
120
+ # Show invalid properties with the reasons. Usually used together with valid?
121
+ # @return Array for valid properties with the reasons
122
+ def list_invalid_properties
123
+ invalid_properties = Array.new
124
+ if !@filter_types.nil? && @filter_types.length < 1
125
+ invalid_properties.push('invalid value for "filter_types", number of items must be greater than or equal to 1.')
126
+ end
127
+
128
+ if !@uid.nil? && @uid.to_s.length > 256
129
+ invalid_properties.push('invalid value for "uid", the character length must be smaller than or equal to 256.')
130
+ end
131
+
132
+ if !@uid.nil? && @uid.to_s.length < 1
133
+ invalid_properties.push('invalid value for "uid", the character length must be great than or equal to 1.')
134
+ end
135
+
136
+ pattern = Regexp.new(/^[a-zA-Z0-9\-_.]+$/)
137
+ if !@uid.nil? && @uid !~ pattern
138
+ invalid_properties.push("invalid value for \"uid\", must conform to the pattern #{pattern}.")
139
+ end
140
+
141
+ if @url.nil?
142
+ invalid_properties.push('invalid value for "url", url cannot be nil.')
143
+ end
144
+
145
+ if @url.to_s.length > 65536
146
+ invalid_properties.push('invalid value for "url", the character length must be smaller than or equal to 65536.')
147
+ end
148
+
149
+ if @url.to_s.length < 1
150
+ invalid_properties.push('invalid value for "url", the character length must be great than or equal to 1.')
151
+ end
152
+
153
+ if @version.nil?
154
+ invalid_properties.push('invalid value for "version", version cannot be nil.')
155
+ end
156
+
157
+ invalid_properties
158
+ end
159
+
160
+ # Check to see if the all the properties in the model are valid
161
+ # @return true if the model is valid
162
+ def valid?
163
+ return false if !@filter_types.nil? && @filter_types.length < 1
164
+ return false if !@uid.nil? && @uid.to_s.length > 256
165
+ return false if !@uid.nil? && @uid.to_s.length < 1
166
+ return false if !@uid.nil? && @uid !~ Regexp.new(/^[a-zA-Z0-9\-_.]+$/)
167
+ return false if @url.nil?
168
+ return false if @url.to_s.length > 65536
169
+ return false if @url.to_s.length < 1
170
+ return false if @version.nil?
171
+ true
172
+ end
173
+
174
+ # Custom attribute writer method with validation
175
+ # @param [Object] filter_types Value to be assigned
176
+ def filter_types=(filter_types)
177
+ if !filter_types.nil? && filter_types.length < 1
178
+ fail ArgumentError, 'invalid value for "filter_types", number of items must be greater than or equal to 1.'
179
+ end
180
+
181
+ @filter_types = filter_types
182
+ end
183
+
184
+ # Custom attribute writer method with validation
185
+ # @param [Object] uid Value to be assigned
186
+ def uid=(uid)
187
+ if !uid.nil? && uid.to_s.length > 256
188
+ fail ArgumentError, 'invalid value for "uid", the character length must be smaller than or equal to 256.'
189
+ end
190
+
191
+ if !uid.nil? && uid.to_s.length < 1
192
+ fail ArgumentError, 'invalid value for "uid", the character length must be great than or equal to 1.'
193
+ end
194
+
195
+ pattern = Regexp.new(/^[a-zA-Z0-9\-_.]+$/)
196
+ if !uid.nil? && uid !~ pattern
197
+ fail ArgumentError, "invalid value for \"uid\", must conform to the pattern #{pattern}."
198
+ end
199
+
200
+ @uid = uid
201
+ end
202
+
203
+ # Custom attribute writer method with validation
204
+ # @param [Object] url Value to be assigned
205
+ def url=(url)
206
+ if url.nil?
207
+ fail ArgumentError, 'url cannot be nil'
208
+ end
209
+
210
+ if url.to_s.length > 65536
211
+ fail ArgumentError, 'invalid value for "url", the character length must be smaller than or equal to 65536.'
212
+ end
213
+
214
+ if url.to_s.length < 1
215
+ fail ArgumentError, 'invalid value for "url", the character length must be great than or equal to 1.'
216
+ end
217
+
218
+ @url = url
219
+ end
220
+
221
+ # Checks equality by comparing each attribute.
222
+ # @param [Object] Object to be compared
223
+ def ==(o)
224
+ return true if self.equal?(o)
225
+ self.class == o.class &&
226
+ description == o.description &&
227
+ disabled == o.disabled &&
228
+ filter_types == o.filter_types &&
229
+ rate_limit == o.rate_limit &&
230
+ uid == o.uid &&
231
+ url == o.url &&
232
+ version == o.version
233
+ end
234
+
235
+ # @see the `==` method
236
+ # @param [Object] Object to be compared
237
+ def eql?(o)
238
+ self == o
239
+ end
240
+
241
+ # Calculates hash code according to all attributes.
242
+ # @return [Integer] Hash code
243
+ def hash
244
+ [description, disabled, filter_types, rate_limit, uid, url, version].hash
245
+ end
246
+
247
+ # Builds the object from hash
248
+ # @param [Hash] attributes Model attributes in the form of hash
249
+ # @return [Object] Returns the model itself
250
+ def self.build_from_hash(attributes)
251
+ new.build_from_hash(attributes)
252
+ end
253
+
254
+ # Builds the object from hash
255
+ # @param [Hash] attributes Model attributes in the form of hash
256
+ # @return [Object] Returns the model itself
257
+ def build_from_hash(attributes)
258
+ return nil unless attributes.is_a?(Hash)
259
+ self.class.openapi_types.each_pair do |key, type|
260
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
261
+ self.send("#{key}=", nil)
262
+ elsif type =~ /\AArray<(.*)>/i
263
+ # check to ensure the input is an array given that the attribute
264
+ # is documented as an array but the input is not
265
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
266
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
267
+ end
268
+ elsif !attributes[self.class.attribute_map[key]].nil?
269
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
270
+ end
271
+ end
272
+
273
+ self
274
+ end
275
+
276
+ # Deserializes the data based on type
277
+ # @param string type Data type
278
+ # @param string value Value to be deserialized
279
+ # @return [Object] Deserialized data
280
+ def _deserialize(type, value)
281
+ case type.to_sym
282
+ when :Time
283
+ Time.parse(value)
284
+ when :Date
285
+ Date.parse(value)
286
+ when :String
287
+ value.to_s
288
+ when :Integer
289
+ value.to_i
290
+ when :Float
291
+ value.to_f
292
+ when :Boolean
293
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
294
+ true
295
+ else
296
+ false
297
+ end
298
+ when :Object
299
+ # generic object (usually a Hash), return directly
300
+ value
301
+ when /\AArray<(?<inner_type>.+)>\z/
302
+ inner_type = Regexp.last_match[:inner_type]
303
+ value.map { |v| _deserialize(inner_type, v) }
304
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
305
+ k_type = Regexp.last_match[:k_type]
306
+ v_type = Regexp.last_match[:v_type]
307
+ {}.tap do |hash|
308
+ value.each do |k, v|
309
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
310
+ end
311
+ end
312
+ else # model
313
+ # models (e.g. Pet) or oneOf
314
+ klass = Svix.const_get(type)
315
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
316
+ end
317
+ end
318
+
319
+ # Returns the string representation of the object
320
+ # @return [String] String presentation of the object
321
+ def to_s
322
+ to_hash.to_s
323
+ end
324
+
325
+ # to_body is an alias to to_hash (backward compatibility)
326
+ # @return [Hash] Returns the object in the form of hash
327
+ def to_body
328
+ to_hash
329
+ end
330
+
331
+ # Returns the object in the form of hash
332
+ # @return [Hash] Returns the object in the form of hash
333
+ def to_hash
334
+ hash = {}
335
+ self.class.attribute_map.each_pair do |attr, param|
336
+ value = self.send(attr)
337
+ if value.nil?
338
+ is_nullable = self.class.openapi_nullable.include?(attr)
339
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
340
+ end
341
+
342
+ hash[param] = _to_hash(value)
343
+ end
344
+ hash
345
+ end
346
+
347
+ # Outputs non-array value in the form of hash
348
+ # For object, use to_hash. Otherwise, just return the value
349
+ # @param [Object] value Any valid value
350
+ # @return [Hash] Returns the value in the form of hash
351
+ def _to_hash(value)
352
+ if value.is_a?(Array)
353
+ value.compact.map { |v| _to_hash(v) }
354
+ elsif value.is_a?(Hash)
355
+ {}.tap do |hash|
356
+ value.each { |k, v| hash[k] = _to_hash(v) }
357
+ end
358
+ elsif value.respond_to? :to_hash
359
+ value.to_hash
360
+ else
361
+ value
362
+ end
363
+ end
364
+
365
+ end
366
+
367
+ end
@@ -0,0 +1,269 @@
1
+ =begin
2
+ #Svix API
3
+
4
+ #Welcome to the Svix API documentation! Useful links: [Homepage](https://www.svix.com) | [Support email](mailto:support+docs@svix.com) | [Blog](https://www.svix.com/blog/) | [Slack Community](https://www.svix.com/slack/) # Introduction This is the reference documentation and schemas for the [Svix webhook service](https://www.svix.com) API. For tutorials and other documentation please refer to [the documentation](https://docs.svix.com). ## Main concepts In Svix you have four important entities you will be interacting with: - `messages`: these are the webhooks being sent. They can have contents and a few other properties. - `application`: this is where `messages` are sent to. Usually you want to create one application for each of your users. - `endpoint`: endpoints are the URLs messages will be sent to. Each application can have multiple `endpoints` and each message sent to that application will be sent to all of them (unless they are not subscribed to the sent event type). - `event-type`: event types are identifiers denoting the type of the message being sent. Event types are primarily used to decide which events are sent to which endpoint. ## Authentication Get your authentication token (`AUTH_TOKEN`) from the [Svix dashboard](https://dashboard.svix.com) and use it as part of the `Authorization` header as such: `Authorization: Bearer ${AUTH_TOKEN}`. <SecurityDefinitions /> ## Code samples The code samples assume you already have the respective libraries installed and you know how to use them. For the latest information on how to do that, please refer to [the documentation](https://docs.svix.com/). ## Cross-Origin Resource Sharing This API features Cross-Origin Resource Sharing (CORS) implemented in compliance with [W3C spec](https://www.w3.org/TR/cors/). And that allows cross-domain communication from the browser. All responses have a wildcard same-origin which makes them completely public and accessible to everyone, including any code on any site.
5
+
6
+ The version of the OpenAPI document: 1.4
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 5.2.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Svix
17
+ # Sent when an endpoint is updated.
18
+ class EndpointUpdatedEvent
19
+ attr_accessor :data
20
+
21
+ attr_accessor :type
22
+
23
+ class EnumAttributeValidator
24
+ attr_reader :datatype
25
+ attr_reader :allowable_values
26
+
27
+ def initialize(datatype, allowable_values)
28
+ @allowable_values = allowable_values.map do |value|
29
+ case datatype.to_s
30
+ when /Integer/i
31
+ value.to_i
32
+ when /Float/i
33
+ value.to_f
34
+ else
35
+ value
36
+ end
37
+ end
38
+ end
39
+
40
+ def valid?(value)
41
+ !value || allowable_values.include?(value)
42
+ end
43
+ end
44
+
45
+ # Attribute mapping from ruby-style variable name to JSON key.
46
+ def self.attribute_map
47
+ {
48
+ :'data' => :'data',
49
+ :'type' => :'type'
50
+ }
51
+ end
52
+
53
+ # Returns all the JSON keys this model knows about
54
+ def self.acceptable_attributes
55
+ attribute_map.values
56
+ end
57
+
58
+ # Attribute type mapping.
59
+ def self.openapi_types
60
+ {
61
+ :'data' => :'EndpointUpdatedEventData',
62
+ :'type' => :'String'
63
+ }
64
+ end
65
+
66
+ # List of attributes with nullable: true
67
+ def self.openapi_nullable
68
+ Set.new([
69
+ ])
70
+ end
71
+
72
+ # Initializes the object
73
+ # @param [Hash] attributes Model attributes in the form of hash
74
+ def initialize(attributes = {})
75
+ if (!attributes.is_a?(Hash))
76
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Svix::EndpointUpdatedEvent` initialize method"
77
+ end
78
+
79
+ # check to see if the attribute exists and convert string to symbol for hash key
80
+ attributes = attributes.each_with_object({}) { |(k, v), h|
81
+ if (!self.class.attribute_map.key?(k.to_sym))
82
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Svix::EndpointUpdatedEvent`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
83
+ end
84
+ h[k.to_sym] = v
85
+ }
86
+
87
+ if attributes.key?(:'data')
88
+ self.data = attributes[:'data']
89
+ end
90
+
91
+ if attributes.key?(:'type')
92
+ self.type = attributes[:'type']
93
+ else
94
+ self.type = 'endpoint.updated'
95
+ end
96
+ end
97
+
98
+ # Show invalid properties with the reasons. Usually used together with valid?
99
+ # @return Array for valid properties with the reasons
100
+ def list_invalid_properties
101
+ invalid_properties = Array.new
102
+ if @data.nil?
103
+ invalid_properties.push('invalid value for "data", data cannot be nil.')
104
+ end
105
+
106
+ invalid_properties
107
+ end
108
+
109
+ # Check to see if the all the properties in the model are valid
110
+ # @return true if the model is valid
111
+ def valid?
112
+ return false if @data.nil?
113
+ type_validator = EnumAttributeValidator.new('String', ["endpoint.updated"])
114
+ return false unless type_validator.valid?(@type)
115
+ true
116
+ end
117
+
118
+ # Custom attribute writer method checking allowed values (enum).
119
+ # @param [Object] type Object to be assigned
120
+ def type=(type)
121
+ validator = EnumAttributeValidator.new('String', ["endpoint.updated"])
122
+ unless validator.valid?(type)
123
+ fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}."
124
+ end
125
+ @type = type
126
+ end
127
+
128
+ # Checks equality by comparing each attribute.
129
+ # @param [Object] Object to be compared
130
+ def ==(o)
131
+ return true if self.equal?(o)
132
+ self.class == o.class &&
133
+ data == o.data &&
134
+ type == o.type
135
+ end
136
+
137
+ # @see the `==` method
138
+ # @param [Object] Object to be compared
139
+ def eql?(o)
140
+ self == o
141
+ end
142
+
143
+ # Calculates hash code according to all attributes.
144
+ # @return [Integer] Hash code
145
+ def hash
146
+ [data, type].hash
147
+ end
148
+
149
+ # Builds the object from hash
150
+ # @param [Hash] attributes Model attributes in the form of hash
151
+ # @return [Object] Returns the model itself
152
+ def self.build_from_hash(attributes)
153
+ new.build_from_hash(attributes)
154
+ end
155
+
156
+ # Builds the object from hash
157
+ # @param [Hash] attributes Model attributes in the form of hash
158
+ # @return [Object] Returns the model itself
159
+ def build_from_hash(attributes)
160
+ return nil unless attributes.is_a?(Hash)
161
+ self.class.openapi_types.each_pair do |key, type|
162
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
163
+ self.send("#{key}=", nil)
164
+ elsif type =~ /\AArray<(.*)>/i
165
+ # check to ensure the input is an array given that the attribute
166
+ # is documented as an array but the input is not
167
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
168
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
169
+ end
170
+ elsif !attributes[self.class.attribute_map[key]].nil?
171
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
172
+ end
173
+ end
174
+
175
+ self
176
+ end
177
+
178
+ # Deserializes the data based on type
179
+ # @param string type Data type
180
+ # @param string value Value to be deserialized
181
+ # @return [Object] Deserialized data
182
+ def _deserialize(type, value)
183
+ case type.to_sym
184
+ when :Time
185
+ Time.parse(value)
186
+ when :Date
187
+ Date.parse(value)
188
+ when :String
189
+ value.to_s
190
+ when :Integer
191
+ value.to_i
192
+ when :Float
193
+ value.to_f
194
+ when :Boolean
195
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
196
+ true
197
+ else
198
+ false
199
+ end
200
+ when :Object
201
+ # generic object (usually a Hash), return directly
202
+ value
203
+ when /\AArray<(?<inner_type>.+)>\z/
204
+ inner_type = Regexp.last_match[:inner_type]
205
+ value.map { |v| _deserialize(inner_type, v) }
206
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
207
+ k_type = Regexp.last_match[:k_type]
208
+ v_type = Regexp.last_match[:v_type]
209
+ {}.tap do |hash|
210
+ value.each do |k, v|
211
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
212
+ end
213
+ end
214
+ else # model
215
+ # models (e.g. Pet) or oneOf
216
+ klass = Svix.const_get(type)
217
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
218
+ end
219
+ end
220
+
221
+ # Returns the string representation of the object
222
+ # @return [String] String presentation of the object
223
+ def to_s
224
+ to_hash.to_s
225
+ end
226
+
227
+ # to_body is an alias to to_hash (backward compatibility)
228
+ # @return [Hash] Returns the object in the form of hash
229
+ def to_body
230
+ to_hash
231
+ end
232
+
233
+ # Returns the object in the form of hash
234
+ # @return [Hash] Returns the object in the form of hash
235
+ def to_hash
236
+ hash = {}
237
+ self.class.attribute_map.each_pair do |attr, param|
238
+ value = self.send(attr)
239
+ if value.nil?
240
+ is_nullable = self.class.openapi_nullable.include?(attr)
241
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
242
+ end
243
+
244
+ hash[param] = _to_hash(value)
245
+ end
246
+ hash
247
+ end
248
+
249
+ # Outputs non-array value in the form of hash
250
+ # For object, use to_hash. Otherwise, just return the value
251
+ # @param [Object] value Any valid value
252
+ # @return [Hash] Returns the value in the form of hash
253
+ def _to_hash(value)
254
+ if value.is_a?(Array)
255
+ value.compact.map { |v| _to_hash(v) }
256
+ elsif value.is_a?(Hash)
257
+ {}.tap do |hash|
258
+ value.each { |k, v| hash[k] = _to_hash(v) }
259
+ end
260
+ elsif value.respond_to? :to_hash
261
+ value.to_hash
262
+ else
263
+ value
264
+ end
265
+ end
266
+
267
+ end
268
+
269
+ end