svix 0.28.0 → 0.37.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (84) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +7 -1
  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 +1281 -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/statistics_api.rb +205 -0
  12. data/lib/svix/api_client.rb +399 -0
  13. data/lib/svix/api_error.rb +57 -0
  14. data/lib/svix/application_api.rb +29 -0
  15. data/lib/svix/authentication_api.rb +17 -0
  16. data/lib/svix/configuration.rb +277 -0
  17. data/lib/svix/endpoint_api.rb +55 -0
  18. data/{src → lib}/svix/errors.rb +0 -0
  19. data/lib/svix/event_type_api.rb +25 -0
  20. data/lib/svix/internal.rb +16 -0
  21. data/lib/svix/message_api.rb +21 -0
  22. data/lib/svix/message_attempt_api.rb +33 -0
  23. data/lib/svix/models/application_in.rb +277 -0
  24. data/lib/svix/models/application_out.rb +319 -0
  25. data/lib/svix/models/attempt_statistics_data.rb +231 -0
  26. data/lib/svix/models/attempt_statistics_response.rb +265 -0
  27. data/lib/svix/models/dashboard_access_out.rb +265 -0
  28. data/lib/svix/models/endpoint_created_event.rb +269 -0
  29. data/lib/svix/models/endpoint_created_event_data.rb +282 -0
  30. data/lib/svix/models/endpoint_deleted_event.rb +269 -0
  31. data/lib/svix/models/endpoint_deleted_event_data.rb +282 -0
  32. data/lib/svix/models/endpoint_disabled_event.rb +269 -0
  33. data/lib/svix/models/endpoint_disabled_event_data.rb +296 -0
  34. data/lib/svix/models/endpoint_headers_in.rb +225 -0
  35. data/lib/svix/models/endpoint_headers_out.rb +252 -0
  36. data/lib/svix/models/endpoint_in.rb +394 -0
  37. data/lib/svix/models/endpoint_message_out.rb +363 -0
  38. data/lib/svix/models/endpoint_out.rb +409 -0
  39. data/lib/svix/models/endpoint_secret_out.rb +245 -0
  40. data/lib/svix/models/endpoint_secret_rotate_in.rb +236 -0
  41. data/lib/svix/models/endpoint_stats.rb +265 -0
  42. data/lib/svix/models/endpoint_update.rb +367 -0
  43. data/lib/svix/models/endpoint_updated_event.rb +269 -0
  44. data/lib/svix/models/endpoint_updated_event_data.rb +282 -0
  45. data/lib/svix/models/endpointd_updated_event.rb +269 -0
  46. data/lib/svix/models/event_example_in.rb +253 -0
  47. data/lib/svix/models/event_type_example_out.rb +223 -0
  48. data/lib/svix/models/event_type_in.rb +290 -0
  49. data/lib/svix/models/event_type_out.rb +318 -0
  50. data/lib/svix/models/event_type_schema_in.rb +224 -0
  51. data/lib/svix/models/event_type_update.rb +246 -0
  52. data/lib/svix/models/http_error_out.rb +237 -0
  53. data/lib/svix/models/http_validation_error.rb +220 -0
  54. data/lib/svix/models/list_response_application_out.rb +248 -0
  55. data/lib/svix/models/list_response_endpoint_message_out.rb +248 -0
  56. data/lib/svix/models/list_response_endpoint_out.rb +248 -0
  57. data/lib/svix/models/list_response_event_type_out.rb +248 -0
  58. data/lib/svix/models/list_response_message_attempt_endpoint_out.rb +248 -0
  59. data/lib/svix/models/list_response_message_attempt_out.rb +248 -0
  60. data/lib/svix/models/list_response_message_endpoint_out.rb +248 -0
  61. data/lib/svix/models/list_response_message_out.rb +248 -0
  62. data/lib/svix/models/message_attempt_endpoint_out.rb +293 -0
  63. data/lib/svix/models/message_attempt_exhausted_event.rb +269 -0
  64. data/lib/svix/models/message_attempt_exhausted_event_data.rb +310 -0
  65. data/lib/svix/models/message_attempt_failed_event.rb +251 -0
  66. data/lib/svix/models/message_attempt_out.rb +307 -0
  67. data/lib/svix/models/message_attempt_trigger_type.rb +37 -0
  68. data/lib/svix/models/message_endpoint_out.rb +418 -0
  69. data/lib/svix/models/message_in.rb +312 -0
  70. data/lib/svix/models/message_out.rb +340 -0
  71. data/lib/svix/models/message_status.rb +39 -0
  72. data/lib/svix/models/recover_in.rb +223 -0
  73. data/lib/svix/models/statistics_period.rb +37 -0
  74. data/lib/svix/models/validation_error.rb +253 -0
  75. data/lib/svix/models/webhook_types.rb +280 -0
  76. data/lib/svix/svix.rb +43 -0
  77. data/{src → lib}/svix/util.rb +1 -1
  78. data/{src → lib}/svix/version.rb +1 -1
  79. data/{src → lib}/svix/webhook.rb +1 -1
  80. data/lib/svix.rb +80 -0
  81. data/svix.gemspec +16 -6
  82. metadata +100 -9
  83. data/.gitignore +0 -9
  84. data/src/svix.rb +0 -8
@@ -0,0 +1,418 @@
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 MessageEndpointOut
18
+ attr_accessor :created_at
19
+
20
+ attr_accessor :description
21
+
22
+ attr_accessor :disabled
23
+
24
+ attr_accessor :filter_types
25
+
26
+ attr_accessor :id
27
+
28
+ attr_accessor :next_attempt
29
+
30
+ attr_accessor :rate_limit
31
+
32
+ attr_accessor :status
33
+
34
+ # Optional unique identifier for the endpoint
35
+ attr_accessor :uid
36
+
37
+ attr_accessor :url
38
+
39
+ attr_accessor :version
40
+
41
+ # Attribute mapping from ruby-style variable name to JSON key.
42
+ def self.attribute_map
43
+ {
44
+ :'created_at' => :'createdAt',
45
+ :'description' => :'description',
46
+ :'disabled' => :'disabled',
47
+ :'filter_types' => :'filterTypes',
48
+ :'id' => :'id',
49
+ :'next_attempt' => :'nextAttempt',
50
+ :'rate_limit' => :'rateLimit',
51
+ :'status' => :'status',
52
+ :'uid' => :'uid',
53
+ :'url' => :'url',
54
+ :'version' => :'version'
55
+ }
56
+ end
57
+
58
+ # Returns all the JSON keys this model knows about
59
+ def self.acceptable_attributes
60
+ attribute_map.values
61
+ end
62
+
63
+ # Attribute type mapping.
64
+ def self.openapi_types
65
+ {
66
+ :'created_at' => :'Time',
67
+ :'description' => :'String',
68
+ :'disabled' => :'Boolean',
69
+ :'filter_types' => :'Array<String>',
70
+ :'id' => :'String',
71
+ :'next_attempt' => :'Time',
72
+ :'rate_limit' => :'Integer',
73
+ :'status' => :'MessageStatus',
74
+ :'uid' => :'String',
75
+ :'url' => :'String',
76
+ :'version' => :'Integer'
77
+ }
78
+ end
79
+
80
+ # List of attributes with nullable: true
81
+ def self.openapi_nullable
82
+ Set.new([
83
+ ])
84
+ end
85
+
86
+ # Initializes the object
87
+ # @param [Hash] attributes Model attributes in the form of hash
88
+ def initialize(attributes = {})
89
+ if (!attributes.is_a?(Hash))
90
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Svix::MessageEndpointOut` initialize method"
91
+ end
92
+
93
+ # check to see if the attribute exists and convert string to symbol for hash key
94
+ attributes = attributes.each_with_object({}) { |(k, v), h|
95
+ if (!self.class.attribute_map.key?(k.to_sym))
96
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Svix::MessageEndpointOut`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
97
+ end
98
+ h[k.to_sym] = v
99
+ }
100
+
101
+ if attributes.key?(:'created_at')
102
+ self.created_at = attributes[:'created_at']
103
+ end
104
+
105
+ if attributes.key?(:'description')
106
+ self.description = attributes[:'description']
107
+ else
108
+ self.description = ''
109
+ end
110
+
111
+ if attributes.key?(:'disabled')
112
+ self.disabled = attributes[:'disabled']
113
+ else
114
+ self.disabled = false
115
+ end
116
+
117
+ if attributes.key?(:'filter_types')
118
+ if (value = attributes[:'filter_types']).is_a?(Array)
119
+ self.filter_types = value
120
+ end
121
+ end
122
+
123
+ if attributes.key?(:'id')
124
+ self.id = attributes[:'id']
125
+ end
126
+
127
+ if attributes.key?(:'next_attempt')
128
+ self.next_attempt = attributes[:'next_attempt']
129
+ end
130
+
131
+ if attributes.key?(:'rate_limit')
132
+ self.rate_limit = attributes[:'rate_limit']
133
+ end
134
+
135
+ if attributes.key?(:'status')
136
+ self.status = attributes[:'status']
137
+ end
138
+
139
+ if attributes.key?(:'uid')
140
+ self.uid = attributes[:'uid']
141
+ end
142
+
143
+ if attributes.key?(:'url')
144
+ self.url = attributes[:'url']
145
+ end
146
+
147
+ if attributes.key?(:'version')
148
+ self.version = attributes[:'version']
149
+ end
150
+ end
151
+
152
+ # Show invalid properties with the reasons. Usually used together with valid?
153
+ # @return Array for valid properties with the reasons
154
+ def list_invalid_properties
155
+ invalid_properties = Array.new
156
+ if @created_at.nil?
157
+ invalid_properties.push('invalid value for "created_at", created_at cannot be nil.')
158
+ end
159
+
160
+ if !@filter_types.nil? && @filter_types.length < 1
161
+ invalid_properties.push('invalid value for "filter_types", number of items must be greater than or equal to 1.')
162
+ end
163
+
164
+ if @id.nil?
165
+ invalid_properties.push('invalid value for "id", id cannot be nil.')
166
+ end
167
+
168
+ if @status.nil?
169
+ invalid_properties.push('invalid value for "status", status cannot be nil.')
170
+ end
171
+
172
+ if !@uid.nil? && @uid.to_s.length > 256
173
+ invalid_properties.push('invalid value for "uid", the character length must be smaller than or equal to 256.')
174
+ end
175
+
176
+ if !@uid.nil? && @uid.to_s.length < 1
177
+ invalid_properties.push('invalid value for "uid", the character length must be great than or equal to 1.')
178
+ end
179
+
180
+ pattern = Regexp.new(/^[a-zA-Z0-9\-_.]+$/)
181
+ if !@uid.nil? && @uid !~ pattern
182
+ invalid_properties.push("invalid value for \"uid\", must conform to the pattern #{pattern}.")
183
+ end
184
+
185
+ if @url.nil?
186
+ invalid_properties.push('invalid value for "url", url cannot be nil.')
187
+ end
188
+
189
+ if @url.to_s.length > 65536
190
+ invalid_properties.push('invalid value for "url", the character length must be smaller than or equal to 65536.')
191
+ end
192
+
193
+ if @url.to_s.length < 1
194
+ invalid_properties.push('invalid value for "url", the character length must be great than or equal to 1.')
195
+ end
196
+
197
+ if @version.nil?
198
+ invalid_properties.push('invalid value for "version", version cannot be nil.')
199
+ end
200
+
201
+ invalid_properties
202
+ end
203
+
204
+ # Check to see if the all the properties in the model are valid
205
+ # @return true if the model is valid
206
+ def valid?
207
+ return false if @created_at.nil?
208
+ return false if !@filter_types.nil? && @filter_types.length < 1
209
+ return false if @id.nil?
210
+ return false if @status.nil?
211
+ return false if !@uid.nil? && @uid.to_s.length > 256
212
+ return false if !@uid.nil? && @uid.to_s.length < 1
213
+ return false if !@uid.nil? && @uid !~ Regexp.new(/^[a-zA-Z0-9\-_.]+$/)
214
+ return false if @url.nil?
215
+ return false if @url.to_s.length > 65536
216
+ return false if @url.to_s.length < 1
217
+ return false if @version.nil?
218
+ true
219
+ end
220
+
221
+ # Custom attribute writer method with validation
222
+ # @param [Object] filter_types Value to be assigned
223
+ def filter_types=(filter_types)
224
+ if !filter_types.nil? && filter_types.length < 1
225
+ fail ArgumentError, 'invalid value for "filter_types", number of items must be greater than or equal to 1.'
226
+ end
227
+
228
+ @filter_types = filter_types
229
+ end
230
+
231
+ # Custom attribute writer method with validation
232
+ # @param [Object] uid Value to be assigned
233
+ def uid=(uid)
234
+ if !uid.nil? && uid.to_s.length > 256
235
+ fail ArgumentError, 'invalid value for "uid", the character length must be smaller than or equal to 256.'
236
+ end
237
+
238
+ if !uid.nil? && uid.to_s.length < 1
239
+ fail ArgumentError, 'invalid value for "uid", the character length must be great than or equal to 1.'
240
+ end
241
+
242
+ pattern = Regexp.new(/^[a-zA-Z0-9\-_.]+$/)
243
+ if !uid.nil? && uid !~ pattern
244
+ fail ArgumentError, "invalid value for \"uid\", must conform to the pattern #{pattern}."
245
+ end
246
+
247
+ @uid = uid
248
+ end
249
+
250
+ # Custom attribute writer method with validation
251
+ # @param [Object] url Value to be assigned
252
+ def url=(url)
253
+ if url.nil?
254
+ fail ArgumentError, 'url cannot be nil'
255
+ end
256
+
257
+ if url.to_s.length > 65536
258
+ fail ArgumentError, 'invalid value for "url", the character length must be smaller than or equal to 65536.'
259
+ end
260
+
261
+ if url.to_s.length < 1
262
+ fail ArgumentError, 'invalid value for "url", the character length must be great than or equal to 1.'
263
+ end
264
+
265
+ @url = url
266
+ end
267
+
268
+ # Checks equality by comparing each attribute.
269
+ # @param [Object] Object to be compared
270
+ def ==(o)
271
+ return true if self.equal?(o)
272
+ self.class == o.class &&
273
+ created_at == o.created_at &&
274
+ description == o.description &&
275
+ disabled == o.disabled &&
276
+ filter_types == o.filter_types &&
277
+ id == o.id &&
278
+ next_attempt == o.next_attempt &&
279
+ rate_limit == o.rate_limit &&
280
+ status == o.status &&
281
+ uid == o.uid &&
282
+ url == o.url &&
283
+ version == o.version
284
+ end
285
+
286
+ # @see the `==` method
287
+ # @param [Object] Object to be compared
288
+ def eql?(o)
289
+ self == o
290
+ end
291
+
292
+ # Calculates hash code according to all attributes.
293
+ # @return [Integer] Hash code
294
+ def hash
295
+ [created_at, description, disabled, filter_types, id, next_attempt, rate_limit, status, uid, url, version].hash
296
+ end
297
+
298
+ # Builds the object from hash
299
+ # @param [Hash] attributes Model attributes in the form of hash
300
+ # @return [Object] Returns the model itself
301
+ def self.build_from_hash(attributes)
302
+ new.build_from_hash(attributes)
303
+ end
304
+
305
+ # Builds the object from hash
306
+ # @param [Hash] attributes Model attributes in the form of hash
307
+ # @return [Object] Returns the model itself
308
+ def build_from_hash(attributes)
309
+ return nil unless attributes.is_a?(Hash)
310
+ self.class.openapi_types.each_pair do |key, type|
311
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
312
+ self.send("#{key}=", nil)
313
+ elsif type =~ /\AArray<(.*)>/i
314
+ # check to ensure the input is an array given that the attribute
315
+ # is documented as an array but the input is not
316
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
317
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
318
+ end
319
+ elsif !attributes[self.class.attribute_map[key]].nil?
320
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
321
+ end
322
+ end
323
+
324
+ self
325
+ end
326
+
327
+ # Deserializes the data based on type
328
+ # @param string type Data type
329
+ # @param string value Value to be deserialized
330
+ # @return [Object] Deserialized data
331
+ def _deserialize(type, value)
332
+ case type.to_sym
333
+ when :Time
334
+ Time.parse(value)
335
+ when :Date
336
+ Date.parse(value)
337
+ when :String
338
+ value.to_s
339
+ when :Integer
340
+ value.to_i
341
+ when :Float
342
+ value.to_f
343
+ when :Boolean
344
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
345
+ true
346
+ else
347
+ false
348
+ end
349
+ when :Object
350
+ # generic object (usually a Hash), return directly
351
+ value
352
+ when /\AArray<(?<inner_type>.+)>\z/
353
+ inner_type = Regexp.last_match[:inner_type]
354
+ value.map { |v| _deserialize(inner_type, v) }
355
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
356
+ k_type = Regexp.last_match[:k_type]
357
+ v_type = Regexp.last_match[:v_type]
358
+ {}.tap do |hash|
359
+ value.each do |k, v|
360
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
361
+ end
362
+ end
363
+ else # model
364
+ # models (e.g. Pet) or oneOf
365
+ klass = Svix.const_get(type)
366
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
367
+ end
368
+ end
369
+
370
+ # Returns the string representation of the object
371
+ # @return [String] String presentation of the object
372
+ def to_s
373
+ to_hash.to_s
374
+ end
375
+
376
+ # to_body is an alias to to_hash (backward compatibility)
377
+ # @return [Hash] Returns the object in the form of hash
378
+ def to_body
379
+ to_hash
380
+ end
381
+
382
+ # Returns the object in the form of hash
383
+ # @return [Hash] Returns the object in the form of hash
384
+ def to_hash
385
+ hash = {}
386
+ self.class.attribute_map.each_pair do |attr, param|
387
+ value = self.send(attr)
388
+ if value.nil?
389
+ is_nullable = self.class.openapi_nullable.include?(attr)
390
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
391
+ end
392
+
393
+ hash[param] = _to_hash(value)
394
+ end
395
+ hash
396
+ end
397
+
398
+ # Outputs non-array value in the form of hash
399
+ # For object, use to_hash. Otherwise, just return the value
400
+ # @param [Object] value Any valid value
401
+ # @return [Hash] Returns the value in the form of hash
402
+ def _to_hash(value)
403
+ if value.is_a?(Array)
404
+ value.compact.map { |v| _to_hash(v) }
405
+ elsif value.is_a?(Hash)
406
+ {}.tap do |hash|
407
+ value.each { |k, v| hash[k] = _to_hash(v) }
408
+ end
409
+ elsif value.respond_to? :to_hash
410
+ value.to_hash
411
+ else
412
+ value
413
+ end
414
+ end
415
+
416
+ end
417
+
418
+ end