svix 1.45.1 → 1.57.0

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 (98) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +1 -1
  3. data/lib/svix/api/application_api.rb +115 -10
  4. data/lib/svix/api/authentication_api.rb +101 -16
  5. data/lib/svix/api/background_tasks_api.rb +43 -17
  6. data/lib/svix/api/endpoint_api.rb +312 -96
  7. data/lib/svix/api/inbound_api.rb +4 -4
  8. data/lib/svix/api/integration_api.rb +102 -24
  9. data/lib/svix/api/message_api.rb +142 -39
  10. data/lib/svix/api/message_attempt_api.rb +135 -372
  11. data/lib/svix/api/statistics_api.rb +6 -6
  12. data/lib/svix/api/stream_api.rb +203 -142
  13. data/lib/svix/api/transformation_template_api.rb +88 -23
  14. data/lib/svix/api/webhook_endpoint_api.rb +253 -77
  15. data/lib/svix/background_tasks_api.rb +2 -2
  16. data/lib/svix/message_attempt_api.rb +7 -3
  17. data/lib/svix/models/active_application_out.rb +373 -0
  18. data/lib/svix/models/active_endpoint_out.rb +355 -0
  19. data/lib/svix/models/aggregate_event_types_out.rb +40 -0
  20. data/lib/svix/models/aggregated_event_types.rb +305 -0
  21. data/lib/svix/models/app_portal_access_in.rb +18 -0
  22. data/lib/svix/models/app_usage_stats_out.rb +40 -0
  23. data/lib/svix/models/application_message_failure.rb +277 -0
  24. data/lib/svix/models/application_message_id_pair.rb +317 -0
  25. data/lib/svix/models/application_out.rb +41 -2
  26. data/lib/svix/models/application_patch.rb +1 -1
  27. data/lib/svix/models/application_stats.rb +41 -2
  28. data/lib/svix/models/application_stats_out.rb +324 -0
  29. data/lib/svix/models/auth_token_out.rb +40 -1
  30. data/lib/svix/models/background_task_finished_event.rb +272 -0
  31. data/lib/svix/models/background_task_finished_event2.rb +331 -0
  32. data/lib/svix/models/background_task_out.rb +40 -0
  33. data/lib/svix/models/background_task_type.rb +2 -1
  34. data/lib/svix/models/{template_in.rb → connector_in.rb} +4 -4
  35. data/lib/svix/models/{transformation_template_kind.rb → connector_kind.rb} +3 -3
  36. data/lib/svix/models/create_stream_in.rb +12 -12
  37. data/lib/svix/models/data.rb +108 -0
  38. data/lib/svix/models/data_any_of.rb +240 -0
  39. data/lib/svix/models/data_any_of1.rb +223 -0
  40. data/lib/svix/models/data_any_of2.rb +241 -0
  41. data/lib/svix/models/data_any_of3.rb +223 -0
  42. data/lib/svix/models/data_any_of4.rb +240 -0
  43. data/lib/svix/models/endpoint_created_event_data.rb +82 -4
  44. data/lib/svix/models/endpoint_deleted_event_data.rb +82 -4
  45. data/lib/svix/models/endpoint_disabled_event.rb +1 -1
  46. data/lib/svix/models/endpoint_disabled_event_data.rb +119 -16
  47. data/lib/svix/models/endpoint_disabled_trigger.rb +40 -0
  48. data/lib/svix/models/endpoint_enabled_event.rb +272 -0
  49. data/lib/svix/models/endpoint_enabled_event_data.rb +410 -0
  50. data/lib/svix/models/endpoint_message_out.rb +40 -1
  51. data/lib/svix/models/endpoint_mtls_config_out.rb +215 -0
  52. data/lib/svix/models/endpoint_oauth_config_in.rb +2 -2
  53. data/lib/svix/models/endpoint_oauth_config_out.rb +315 -0
  54. data/lib/svix/models/endpoint_out.rb +40 -1
  55. data/lib/svix/models/endpoint_patch.rb +1 -1
  56. data/lib/svix/models/endpoint_updated_event_data.rb +82 -4
  57. data/lib/svix/models/environment_in.rb +17 -19
  58. data/lib/svix/models/environment_settings_out.rb +23 -1
  59. data/lib/svix/models/event_type_import_open_api_in.rb +14 -2
  60. data/lib/svix/models/export_event_type_out.rb +40 -0
  61. data/lib/svix/models/expung_all_contents_out.rb +315 -0
  62. data/lib/svix/models/inbound_path_params.rb +1 -1
  63. data/lib/svix/models/integration_in.rb +41 -1
  64. data/lib/svix/models/integration_out.rb +81 -2
  65. data/lib/svix/models/integration_update.rb +41 -1
  66. data/lib/svix/models/list_response_active_application_out.rb +261 -0
  67. data/lib/svix/models/message_attempt_endpoint_out.rb +120 -3
  68. data/lib/svix/models/message_attempt_exhausted_event_data.rb +122 -5
  69. data/lib/svix/models/message_attempt_failed_data.rb +40 -1
  70. data/lib/svix/models/message_attempt_failing_event_data.rb +122 -5
  71. data/lib/svix/models/message_attempt_out.rb +120 -3
  72. data/lib/svix/models/message_attempt_recovered_event_data.rb +122 -5
  73. data/lib/svix/models/message_broadcast_out.rb +40 -0
  74. data/lib/svix/models/message_endpoint_out.rb +40 -1
  75. data/lib/svix/models/message_out.rb +40 -1
  76. data/lib/svix/models/message_precheck_in.rb +288 -0
  77. data/lib/svix/models/message_precheck_out.rb +221 -0
  78. data/lib/svix/models/{oauth2_auth_method_in.rb → oauth2_auth_method_in_out.rb} +3 -3
  79. data/lib/svix/models/{oauth2_grant_type_in.rb → oauth2_grant_type_in_out.rb} +3 -3
  80. data/lib/svix/models/operational_webhook_endpoint_headers_in.rb +223 -0
  81. data/lib/svix/models/operational_webhook_endpoint_headers_out.rb +251 -0
  82. data/lib/svix/models/operational_webhook_endpoint_out.rb +40 -1
  83. data/lib/svix/models/polling_endpoint_message_out.rb +454 -0
  84. data/lib/svix/models/polling_endpoint_out.rb +255 -0
  85. data/lib/svix/models/recover_out.rb +40 -0
  86. data/lib/svix/models/replay_out.rb +40 -0
  87. data/lib/svix/models/rotate_poller_token_in.rb +1 -1
  88. data/lib/svix/models/sink_secret_out.rb +233 -0
  89. data/lib/svix/models/stream_in.rb +6 -7
  90. data/lib/svix/models/stream_out.rb +46 -7
  91. data/lib/svix/models/stream_patch.rb +6 -7
  92. data/lib/svix/models/stream_portal_access_in.rb +293 -0
  93. data/lib/svix/models/template_out.rb +81 -1
  94. data/lib/svix/models/template_patch.rb +1 -1
  95. data/lib/svix/models/template_update.rb +1 -1
  96. data/lib/svix/version.rb +1 -1
  97. metadata +35 -7
  98. data/lib/svix/operational_webhook_endpoint_api.rb +0 -37
@@ -0,0 +1,454 @@
1
+ =begin
2
+ #Svix API
3
+
4
+ #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5
+
6
+ The version of the OpenAPI document: 1.1.1
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.9.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Svix
17
+ # The MessageOut equivalent of polling endpoint
18
+ class PollingEndpointMessageOut
19
+ # List of free-form identifiers that endpoints can filter by
20
+ attr_accessor :channels
21
+
22
+ # Optional unique identifier for the message
23
+ attr_accessor :event_id
24
+
25
+ # The event type's name
26
+ attr_accessor :event_type
27
+
28
+ attr_accessor :headers
29
+
30
+ # The Message's ID.
31
+ attr_accessor :id
32
+
33
+ attr_accessor :payload
34
+
35
+ attr_accessor :tags
36
+
37
+ attr_accessor :timestamp
38
+
39
+ # Attribute mapping from ruby-style variable name to JSON key.
40
+ def self.attribute_map
41
+ {
42
+ :'channels' => :'channels',
43
+ :'event_id' => :'eventId',
44
+ :'event_type' => :'eventType',
45
+ :'headers' => :'headers',
46
+ :'id' => :'id',
47
+ :'payload' => :'payload',
48
+ :'tags' => :'tags',
49
+ :'timestamp' => :'timestamp'
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
+ :'channels' => :'Array<String>',
62
+ :'event_id' => :'String',
63
+ :'event_type' => :'String',
64
+ :'headers' => :'Hash<String, String>',
65
+ :'id' => :'String',
66
+ :'payload' => :'Object',
67
+ :'tags' => :'Array<String>',
68
+ :'timestamp' => :'Time'
69
+ }
70
+ end
71
+
72
+ # List of attributes with nullable: true
73
+ def self.openapi_nullable
74
+ Set.new([
75
+ :'channels',
76
+ :'event_id',
77
+ :'headers',
78
+ :'tags',
79
+ ])
80
+ end
81
+
82
+ # Initializes the object
83
+ # @param [Hash] attributes Model attributes in the form of hash
84
+ def initialize(attributes = {})
85
+ if (!attributes.is_a?(Hash))
86
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Svix::PollingEndpointMessageOut` initialize method"
87
+ end
88
+
89
+ # check to see if the attribute exists and convert string to symbol for hash key
90
+ attributes = attributes.each_with_object({}) { |(k, v), h|
91
+ if (!self.class.attribute_map.key?(k.to_sym))
92
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Svix::PollingEndpointMessageOut`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
93
+ end
94
+ h[k.to_sym] = v
95
+ }
96
+
97
+ if attributes.key?(:'channels')
98
+ if (value = attributes[:'channels']).is_a?(Array)
99
+ self.channels = value
100
+ end
101
+ end
102
+
103
+ if attributes.key?(:'event_id')
104
+ self.event_id = attributes[:'event_id']
105
+ end
106
+
107
+ if attributes.key?(:'event_type')
108
+ self.event_type = attributes[:'event_type']
109
+ else
110
+ self.event_type = nil
111
+ end
112
+
113
+ if attributes.key?(:'headers')
114
+ if (value = attributes[:'headers']).is_a?(Hash)
115
+ self.headers = value
116
+ end
117
+ end
118
+
119
+ if attributes.key?(:'id')
120
+ self.id = attributes[:'id']
121
+ else
122
+ self.id = nil
123
+ end
124
+
125
+ if attributes.key?(:'payload')
126
+ self.payload = attributes[:'payload']
127
+ else
128
+ self.payload = nil
129
+ end
130
+
131
+ if attributes.key?(:'tags')
132
+ if (value = attributes[:'tags']).is_a?(Array)
133
+ self.tags = value
134
+ end
135
+ end
136
+
137
+ if attributes.key?(:'timestamp')
138
+ self.timestamp = attributes[:'timestamp']
139
+ else
140
+ self.timestamp = nil
141
+ end
142
+ end
143
+
144
+ # Show invalid properties with the reasons. Usually used together with valid?
145
+ # @return Array for valid properties with the reasons
146
+ def list_invalid_properties
147
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
148
+ invalid_properties = Array.new
149
+ if !@channels.nil? && @channels.length > 10
150
+ invalid_properties.push('invalid value for "channels", number of items must be less than or equal to 10.')
151
+ end
152
+
153
+ if !@channels.nil? && @channels.length < 1
154
+ invalid_properties.push('invalid value for "channels", number of items must be greater than or equal to 1.')
155
+ end
156
+
157
+ if !@event_id.nil? && @event_id.to_s.length > 256
158
+ invalid_properties.push('invalid value for "event_id", the character length must be smaller than or equal to 256.')
159
+ end
160
+
161
+ if !@event_id.nil? && @event_id.to_s.length < 1
162
+ invalid_properties.push('invalid value for "event_id", the character length must be great than or equal to 1.')
163
+ end
164
+
165
+ pattern = Regexp.new(/^[a-zA-Z0-9\-_.]+$/)
166
+ if !@event_id.nil? && @event_id !~ pattern
167
+ invalid_properties.push("invalid value for \"event_id\", must conform to the pattern #{pattern}.")
168
+ end
169
+
170
+ if @event_type.nil?
171
+ invalid_properties.push('invalid value for "event_type", event_type cannot be nil.')
172
+ end
173
+
174
+ if @event_type.to_s.length > 256
175
+ invalid_properties.push('invalid value for "event_type", the character length must be smaller than or equal to 256.')
176
+ end
177
+
178
+ pattern = Regexp.new(/^[a-zA-Z0-9\-_.]+$/)
179
+ if @event_type !~ pattern
180
+ invalid_properties.push("invalid value for \"event_type\", must conform to the pattern #{pattern}.")
181
+ end
182
+
183
+ if @id.nil?
184
+ invalid_properties.push('invalid value for "id", id cannot be nil.')
185
+ end
186
+
187
+ if @id.to_s.length > 31
188
+ invalid_properties.push('invalid value for "id", the character length must be smaller than or equal to 31.')
189
+ end
190
+
191
+ if @id.to_s.length < 31
192
+ invalid_properties.push('invalid value for "id", the character length must be great than or equal to 31.')
193
+ end
194
+
195
+ pattern = Regexp.new(/^msg_[A-Za-z0-9]{27}$/)
196
+ if @id !~ pattern
197
+ invalid_properties.push("invalid value for \"id\", must conform to the pattern #{pattern}.")
198
+ end
199
+
200
+ if @payload.nil?
201
+ invalid_properties.push('invalid value for "payload", payload cannot be nil.')
202
+ end
203
+
204
+ if @timestamp.nil?
205
+ invalid_properties.push('invalid value for "timestamp", timestamp cannot be nil.')
206
+ end
207
+
208
+ invalid_properties
209
+ end
210
+
211
+ # Check to see if the all the properties in the model are valid
212
+ # @return true if the model is valid
213
+ def valid?
214
+ warn '[DEPRECATED] the `valid?` method is obsolete'
215
+ return false if !@channels.nil? && @channels.length > 10
216
+ return false if !@channels.nil? && @channels.length < 1
217
+ return false if !@event_id.nil? && @event_id.to_s.length > 256
218
+ return false if !@event_id.nil? && @event_id.to_s.length < 1
219
+ return false if !@event_id.nil? && @event_id !~ Regexp.new(/^[a-zA-Z0-9\-_.]+$/)
220
+ return false if @event_type.nil?
221
+ return false if @event_type.to_s.length > 256
222
+ return false if @event_type !~ Regexp.new(/^[a-zA-Z0-9\-_.]+$/)
223
+ return false if @id.nil?
224
+ return false if @id.to_s.length > 31
225
+ return false if @id.to_s.length < 31
226
+ return false if @id !~ Regexp.new(/^msg_[A-Za-z0-9]{27}$/)
227
+ return false if @payload.nil?
228
+ return false if @timestamp.nil?
229
+ true
230
+ end
231
+
232
+ # Custom attribute writer method with validation
233
+ # @param [Object] channels Value to be assigned
234
+ def channels=(channels)
235
+ if !channels.nil? && channels.length > 10
236
+ fail ArgumentError, 'invalid value for "channels", number of items must be less than or equal to 10.'
237
+ end
238
+
239
+ if !channels.nil? && channels.length < 1
240
+ fail ArgumentError, 'invalid value for "channels", number of items must be greater than or equal to 1.'
241
+ end
242
+
243
+ @channels = channels
244
+ end
245
+
246
+ # Custom attribute writer method with validation
247
+ # @param [Object] event_id Value to be assigned
248
+ def event_id=(event_id)
249
+ if !event_id.nil? && event_id.to_s.length > 256
250
+ fail ArgumentError, 'invalid value for "event_id", the character length must be smaller than or equal to 256.'
251
+ end
252
+
253
+ if !event_id.nil? && event_id.to_s.length < 1
254
+ fail ArgumentError, 'invalid value for "event_id", the character length must be great than or equal to 1.'
255
+ end
256
+
257
+ pattern = Regexp.new(/^[a-zA-Z0-9\-_.]+$/)
258
+ if !event_id.nil? && event_id !~ pattern
259
+ fail ArgumentError, "invalid value for \"event_id\", must conform to the pattern #{pattern}."
260
+ end
261
+
262
+ @event_id = event_id
263
+ end
264
+
265
+ # Custom attribute writer method with validation
266
+ # @param [Object] event_type Value to be assigned
267
+ def event_type=(event_type)
268
+ if event_type.nil?
269
+ fail ArgumentError, 'event_type cannot be nil'
270
+ end
271
+
272
+ if event_type.to_s.length > 256
273
+ fail ArgumentError, 'invalid value for "event_type", the character length must be smaller than or equal to 256.'
274
+ end
275
+
276
+ pattern = Regexp.new(/^[a-zA-Z0-9\-_.]+$/)
277
+ if event_type !~ pattern
278
+ fail ArgumentError, "invalid value for \"event_type\", must conform to the pattern #{pattern}."
279
+ end
280
+
281
+ @event_type = event_type
282
+ end
283
+
284
+ # Custom attribute writer method with validation
285
+ # @param [Object] id Value to be assigned
286
+ def id=(id)
287
+ if id.nil?
288
+ fail ArgumentError, 'id cannot be nil'
289
+ end
290
+
291
+ if id.to_s.length > 31
292
+ fail ArgumentError, 'invalid value for "id", the character length must be smaller than or equal to 31.'
293
+ end
294
+
295
+ if id.to_s.length < 31
296
+ fail ArgumentError, 'invalid value for "id", the character length must be great than or equal to 31.'
297
+ end
298
+
299
+ pattern = Regexp.new(/^msg_[A-Za-z0-9]{27}$/)
300
+ if id !~ pattern
301
+ fail ArgumentError, "invalid value for \"id\", must conform to the pattern #{pattern}."
302
+ end
303
+
304
+ @id = id
305
+ end
306
+
307
+ # Custom attribute writer method with validation
308
+ # @param [Object] tags Value to be assigned
309
+ def tags=(tags)
310
+ @tags = tags
311
+ end
312
+
313
+ # Checks equality by comparing each attribute.
314
+ # @param [Object] Object to be compared
315
+ def ==(o)
316
+ return true if self.equal?(o)
317
+ self.class == o.class &&
318
+ channels == o.channels &&
319
+ event_id == o.event_id &&
320
+ event_type == o.event_type &&
321
+ headers == o.headers &&
322
+ id == o.id &&
323
+ payload == o.payload &&
324
+ tags == o.tags &&
325
+ timestamp == o.timestamp
326
+ end
327
+
328
+ # @see the `==` method
329
+ # @param [Object] Object to be compared
330
+ def eql?(o)
331
+ self == o
332
+ end
333
+
334
+ # Calculates hash code according to all attributes.
335
+ # @return [Integer] Hash code
336
+ def hash
337
+ [channels, event_id, event_type, headers, id, payload, tags, timestamp].hash
338
+ end
339
+
340
+ # Builds the object from hash
341
+ # @param [Hash] attributes Model attributes in the form of hash
342
+ # @return [Object] Returns the model itself
343
+ def self.build_from_hash(attributes)
344
+ return nil unless attributes.is_a?(Hash)
345
+ attributes = attributes.transform_keys(&:to_sym)
346
+ transformed_hash = {}
347
+ openapi_types.each_pair do |key, type|
348
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
349
+ transformed_hash["#{key}"] = nil
350
+ elsif type =~ /\AArray<(.*)>/i
351
+ # check to ensure the input is an array given that the attribute
352
+ # is documented as an array but the input is not
353
+ if attributes[attribute_map[key]].is_a?(Array)
354
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
355
+ end
356
+ elsif !attributes[attribute_map[key]].nil?
357
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
358
+ end
359
+ end
360
+ new(transformed_hash)
361
+ end
362
+
363
+ # Deserializes the data based on type
364
+ # @param string type Data type
365
+ # @param string value Value to be deserialized
366
+ # @return [Object] Deserialized data
367
+ def self._deserialize(type, value)
368
+ case type.to_sym
369
+ when :Time
370
+ Time.parse(value)
371
+ when :Date
372
+ Date.parse(value)
373
+ when :String
374
+ value.to_s
375
+ when :Integer
376
+ value.to_i
377
+ when :Float
378
+ value.to_f
379
+ when :Boolean
380
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
381
+ true
382
+ else
383
+ false
384
+ end
385
+ when :Object
386
+ # generic object (usually a Hash), return directly
387
+ value
388
+ when /\AArray<(?<inner_type>.+)>\z/
389
+ inner_type = Regexp.last_match[:inner_type]
390
+ value.map { |v| _deserialize(inner_type, v) }
391
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
392
+ k_type = Regexp.last_match[:k_type]
393
+ v_type = Regexp.last_match[:v_type]
394
+ {}.tap do |hash|
395
+ value.each do |k, v|
396
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
397
+ end
398
+ end
399
+ else # model
400
+ # models (e.g. Pet) or oneOf
401
+ klass = Svix.const_get(type)
402
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
403
+ end
404
+ end
405
+
406
+ # Returns the string representation of the object
407
+ # @return [String] String presentation of the object
408
+ def to_s
409
+ to_hash.to_s
410
+ end
411
+
412
+ # to_body is an alias to to_hash (backward compatibility)
413
+ # @return [Hash] Returns the object in the form of hash
414
+ def to_body
415
+ to_hash
416
+ end
417
+
418
+ # Returns the object in the form of hash
419
+ # @return [Hash] Returns the object in the form of hash
420
+ def to_hash
421
+ hash = {}
422
+ self.class.attribute_map.each_pair do |attr, param|
423
+ value = self.send(attr)
424
+ if value.nil?
425
+ is_nullable = self.class.openapi_nullable.include?(attr)
426
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
427
+ end
428
+
429
+ hash[param] = _to_hash(value)
430
+ end
431
+ hash
432
+ end
433
+
434
+ # Outputs non-array value in the form of hash
435
+ # For object, use to_hash. Otherwise, just return the value
436
+ # @param [Object] value Any valid value
437
+ # @return [Hash] Returns the value in the form of hash
438
+ def _to_hash(value)
439
+ if value.is_a?(Array)
440
+ value.compact.map { |v| _to_hash(v) }
441
+ elsif value.is_a?(Hash)
442
+ {}.tap do |hash|
443
+ value.each { |k, v| hash[k] = _to_hash(v) }
444
+ end
445
+ elsif value.respond_to? :to_hash
446
+ value.to_hash
447
+ else
448
+ value
449
+ end
450
+ end
451
+
452
+ end
453
+
454
+ end
@@ -0,0 +1,255 @@
1
+ =begin
2
+ #Svix API
3
+
4
+ #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5
+
6
+ The version of the OpenAPI document: 1.1.1
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.9.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Svix
17
+ class PollingEndpointOut
18
+ attr_accessor :data
19
+
20
+ attr_accessor :done
21
+
22
+ attr_accessor :iterator
23
+
24
+ # Attribute mapping from ruby-style variable name to JSON key.
25
+ def self.attribute_map
26
+ {
27
+ :'data' => :'data',
28
+ :'done' => :'done',
29
+ :'iterator' => :'iterator'
30
+ }
31
+ end
32
+
33
+ # Returns all the JSON keys this model knows about
34
+ def self.acceptable_attributes
35
+ attribute_map.values
36
+ end
37
+
38
+ # Attribute type mapping.
39
+ def self.openapi_types
40
+ {
41
+ :'data' => :'Array<PollingEndpointMessageOut>',
42
+ :'done' => :'Boolean',
43
+ :'iterator' => :'String'
44
+ }
45
+ end
46
+
47
+ # List of attributes with nullable: true
48
+ def self.openapi_nullable
49
+ Set.new([
50
+ ])
51
+ end
52
+
53
+ # Initializes the object
54
+ # @param [Hash] attributes Model attributes in the form of hash
55
+ def initialize(attributes = {})
56
+ if (!attributes.is_a?(Hash))
57
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Svix::PollingEndpointOut` initialize method"
58
+ end
59
+
60
+ # check to see if the attribute exists and convert string to symbol for hash key
61
+ attributes = attributes.each_with_object({}) { |(k, v), h|
62
+ if (!self.class.attribute_map.key?(k.to_sym))
63
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Svix::PollingEndpointOut`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
64
+ end
65
+ h[k.to_sym] = v
66
+ }
67
+
68
+ if attributes.key?(:'data')
69
+ if (value = attributes[:'data']).is_a?(Array)
70
+ self.data = value
71
+ end
72
+ else
73
+ self.data = nil
74
+ end
75
+
76
+ if attributes.key?(:'done')
77
+ self.done = attributes[:'done']
78
+ else
79
+ self.done = nil
80
+ end
81
+
82
+ if attributes.key?(:'iterator')
83
+ self.iterator = attributes[:'iterator']
84
+ else
85
+ self.iterator = nil
86
+ end
87
+ end
88
+
89
+ # Show invalid properties with the reasons. Usually used together with valid?
90
+ # @return Array for valid properties with the reasons
91
+ def list_invalid_properties
92
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
93
+ invalid_properties = Array.new
94
+ if @data.nil?
95
+ invalid_properties.push('invalid value for "data", data cannot be nil.')
96
+ end
97
+
98
+ if @done.nil?
99
+ invalid_properties.push('invalid value for "done", done cannot be nil.')
100
+ end
101
+
102
+ if @iterator.nil?
103
+ invalid_properties.push('invalid value for "iterator", iterator 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
+ warn '[DEPRECATED] the `valid?` method is obsolete'
113
+ return false if @data.nil?
114
+ return false if @done.nil?
115
+ return false if @iterator.nil?
116
+ true
117
+ end
118
+
119
+ # Checks equality by comparing each attribute.
120
+ # @param [Object] Object to be compared
121
+ def ==(o)
122
+ return true if self.equal?(o)
123
+ self.class == o.class &&
124
+ data == o.data &&
125
+ done == o.done &&
126
+ iterator == o.iterator
127
+ end
128
+
129
+ # @see the `==` method
130
+ # @param [Object] Object to be compared
131
+ def eql?(o)
132
+ self == o
133
+ end
134
+
135
+ # Calculates hash code according to all attributes.
136
+ # @return [Integer] Hash code
137
+ def hash
138
+ [data, done, iterator].hash
139
+ end
140
+
141
+ # Builds the object from hash
142
+ # @param [Hash] attributes Model attributes in the form of hash
143
+ # @return [Object] Returns the model itself
144
+ def self.build_from_hash(attributes)
145
+ return nil unless attributes.is_a?(Hash)
146
+ attributes = attributes.transform_keys(&:to_sym)
147
+ transformed_hash = {}
148
+ openapi_types.each_pair do |key, type|
149
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
150
+ transformed_hash["#{key}"] = nil
151
+ elsif type =~ /\AArray<(.*)>/i
152
+ # check to ensure the input is an array given that the attribute
153
+ # is documented as an array but the input is not
154
+ if attributes[attribute_map[key]].is_a?(Array)
155
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
156
+ end
157
+ elsif !attributes[attribute_map[key]].nil?
158
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
159
+ end
160
+ end
161
+ new(transformed_hash)
162
+ end
163
+
164
+ # Deserializes the data based on type
165
+ # @param string type Data type
166
+ # @param string value Value to be deserialized
167
+ # @return [Object] Deserialized data
168
+ def self._deserialize(type, value)
169
+ case type.to_sym
170
+ when :Time
171
+ Time.parse(value)
172
+ when :Date
173
+ Date.parse(value)
174
+ when :String
175
+ value.to_s
176
+ when :Integer
177
+ value.to_i
178
+ when :Float
179
+ value.to_f
180
+ when :Boolean
181
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
182
+ true
183
+ else
184
+ false
185
+ end
186
+ when :Object
187
+ # generic object (usually a Hash), return directly
188
+ value
189
+ when /\AArray<(?<inner_type>.+)>\z/
190
+ inner_type = Regexp.last_match[:inner_type]
191
+ value.map { |v| _deserialize(inner_type, v) }
192
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
193
+ k_type = Regexp.last_match[:k_type]
194
+ v_type = Regexp.last_match[:v_type]
195
+ {}.tap do |hash|
196
+ value.each do |k, v|
197
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
198
+ end
199
+ end
200
+ else # model
201
+ # models (e.g. Pet) or oneOf
202
+ klass = Svix.const_get(type)
203
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
204
+ end
205
+ end
206
+
207
+ # Returns the string representation of the object
208
+ # @return [String] String presentation of the object
209
+ def to_s
210
+ to_hash.to_s
211
+ end
212
+
213
+ # to_body is an alias to to_hash (backward compatibility)
214
+ # @return [Hash] Returns the object in the form of hash
215
+ def to_body
216
+ to_hash
217
+ end
218
+
219
+ # Returns the object in the form of hash
220
+ # @return [Hash] Returns the object in the form of hash
221
+ def to_hash
222
+ hash = {}
223
+ self.class.attribute_map.each_pair do |attr, param|
224
+ value = self.send(attr)
225
+ if value.nil?
226
+ is_nullable = self.class.openapi_nullable.include?(attr)
227
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
228
+ end
229
+
230
+ hash[param] = _to_hash(value)
231
+ end
232
+ hash
233
+ end
234
+
235
+ # Outputs non-array value in the form of hash
236
+ # For object, use to_hash. Otherwise, just return the value
237
+ # @param [Object] value Any valid value
238
+ # @return [Hash] Returns the value in the form of hash
239
+ def _to_hash(value)
240
+ if value.is_a?(Array)
241
+ value.compact.map { |v| _to_hash(v) }
242
+ elsif value.is_a?(Hash)
243
+ {}.tap do |hash|
244
+ value.each { |k, v| hash[k] = _to_hash(v) }
245
+ end
246
+ elsif value.respond_to? :to_hash
247
+ value.to_hash
248
+ else
249
+ value
250
+ end
251
+ end
252
+
253
+ end
254
+
255
+ end