svix 0.15.0 → 0.32.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) 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 +774 -0
  7. data/lib/svix/api/event_type_api.rb +377 -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 +34 -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 +246 -0
  27. data/lib/svix/models/endpoint_deleted_event.rb +269 -0
  28. data/lib/svix/models/endpoint_deleted_event_data.rb +246 -0
  29. data/lib/svix/models/endpoint_disabled_event.rb +269 -0
  30. data/lib/svix/models/endpoint_disabled_event_data.rb +260 -0
  31. data/lib/svix/models/endpoint_in.rb +368 -0
  32. data/lib/svix/models/endpoint_message_out.rb +363 -0
  33. data/lib/svix/models/endpoint_out.rb +386 -0
  34. data/lib/svix/models/endpoint_secret_out.rb +224 -0
  35. data/lib/svix/models/endpoint_stats.rb +265 -0
  36. data/lib/svix/models/endpoint_update.rb +358 -0
  37. data/lib/svix/models/endpoint_updated_event_data.rb +246 -0
  38. data/lib/svix/models/endpointd_updated_event.rb +269 -0
  39. data/lib/svix/models/event_example_in.rb +253 -0
  40. data/lib/svix/models/event_type_in.rb +279 -0
  41. data/lib/svix/models/event_type_out.rb +279 -0
  42. data/lib/svix/models/event_type_update.rb +235 -0
  43. data/lib/svix/models/http_error_out.rb +237 -0
  44. data/lib/svix/models/http_validation_error.rb +220 -0
  45. data/lib/svix/models/list_response_application_out.rb +248 -0
  46. data/lib/svix/models/list_response_endpoint_message_out.rb +248 -0
  47. data/lib/svix/models/list_response_endpoint_out.rb +248 -0
  48. data/lib/svix/models/list_response_event_type_out.rb +248 -0
  49. data/lib/svix/models/list_response_message_attempt_endpoint_out.rb +248 -0
  50. data/lib/svix/models/list_response_message_attempt_out.rb +248 -0
  51. data/lib/svix/models/list_response_message_endpoint_out.rb +248 -0
  52. data/lib/svix/models/list_response_message_out.rb +248 -0
  53. data/lib/svix/models/message_attempt_endpoint_out.rb +293 -0
  54. data/lib/svix/models/message_attempt_exhausted_event.rb +269 -0
  55. data/lib/svix/models/message_attempt_exhausted_event_data.rb +274 -0
  56. data/lib/svix/models/message_attempt_failed_event.rb +251 -0
  57. data/lib/svix/models/message_attempt_out.rb +307 -0
  58. data/lib/svix/models/message_attempt_trigger_type.rb +37 -0
  59. data/lib/svix/models/message_endpoint_out.rb +409 -0
  60. data/lib/svix/models/message_in.rb +312 -0
  61. data/lib/svix/models/message_out.rb +340 -0
  62. data/lib/svix/models/message_status.rb +39 -0
  63. data/lib/svix/models/validation_error.rb +253 -0
  64. data/lib/svix/models/webhook_types.rb +280 -0
  65. data/lib/svix/svix.rb +43 -0
  66. data/{src → lib}/svix/util.rb +1 -1
  67. data/lib/svix/version.rb +5 -0
  68. data/lib/svix/webhook.rb +75 -0
  69. data/lib/svix.rb +76 -0
  70. data/svix.gemspec +19 -9
  71. metadata +93 -13
  72. data/.gitignore +0 -9
  73. data/src/svix/version.rb +0 -3
  74. data/src/svix/webhook.rb +0 -33
  75. data/src/svix.rb +0 -8
@@ -0,0 +1,409 @@
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 @id.nil?
161
+ invalid_properties.push('invalid value for "id", id cannot be nil.')
162
+ end
163
+
164
+ if @status.nil?
165
+ invalid_properties.push('invalid value for "status", status cannot be nil.')
166
+ end
167
+
168
+ if !@uid.nil? && @uid.to_s.length > 256
169
+ invalid_properties.push('invalid value for "uid", the character length must be smaller than or equal to 256.')
170
+ end
171
+
172
+ if !@uid.nil? && @uid.to_s.length < 1
173
+ invalid_properties.push('invalid value for "uid", the character length must be great than or equal to 1.')
174
+ end
175
+
176
+ pattern = Regexp.new(/^[a-zA-Z0-9\-_.]+$/)
177
+ if !@uid.nil? && @uid !~ pattern
178
+ invalid_properties.push("invalid value for \"uid\", must conform to the pattern #{pattern}.")
179
+ end
180
+
181
+ if @url.nil?
182
+ invalid_properties.push('invalid value for "url", url cannot be nil.')
183
+ end
184
+
185
+ if @url.to_s.length > 65536
186
+ invalid_properties.push('invalid value for "url", the character length must be smaller than or equal to 65536.')
187
+ end
188
+
189
+ if @url.to_s.length < 1
190
+ invalid_properties.push('invalid value for "url", the character length must be great than or equal to 1.')
191
+ end
192
+
193
+ if @version.nil?
194
+ invalid_properties.push('invalid value for "version", version cannot be nil.')
195
+ end
196
+
197
+ invalid_properties
198
+ end
199
+
200
+ # Check to see if the all the properties in the model are valid
201
+ # @return true if the model is valid
202
+ def valid?
203
+ return false if @created_at.nil?
204
+ return false if @id.nil?
205
+ return false if @status.nil?
206
+ return false if !@uid.nil? && @uid.to_s.length > 256
207
+ return false if !@uid.nil? && @uid.to_s.length < 1
208
+ return false if !@uid.nil? && @uid !~ Regexp.new(/^[a-zA-Z0-9\-_.]+$/)
209
+ return false if @url.nil?
210
+ return false if @url.to_s.length > 65536
211
+ return false if @url.to_s.length < 1
212
+ return false if @version.nil?
213
+ true
214
+ end
215
+
216
+ # Custom attribute writer method with validation
217
+ # @param [Object] filter_types Value to be assigned
218
+ def filter_types=(filter_types)
219
+ @filter_types = filter_types
220
+ end
221
+
222
+ # Custom attribute writer method with validation
223
+ # @param [Object] uid Value to be assigned
224
+ def uid=(uid)
225
+ if !uid.nil? && uid.to_s.length > 256
226
+ fail ArgumentError, 'invalid value for "uid", the character length must be smaller than or equal to 256.'
227
+ end
228
+
229
+ if !uid.nil? && uid.to_s.length < 1
230
+ fail ArgumentError, 'invalid value for "uid", the character length must be great than or equal to 1.'
231
+ end
232
+
233
+ pattern = Regexp.new(/^[a-zA-Z0-9\-_.]+$/)
234
+ if !uid.nil? && uid !~ pattern
235
+ fail ArgumentError, "invalid value for \"uid\", must conform to the pattern #{pattern}."
236
+ end
237
+
238
+ @uid = uid
239
+ end
240
+
241
+ # Custom attribute writer method with validation
242
+ # @param [Object] url Value to be assigned
243
+ def url=(url)
244
+ if url.nil?
245
+ fail ArgumentError, 'url cannot be nil'
246
+ end
247
+
248
+ if url.to_s.length > 65536
249
+ fail ArgumentError, 'invalid value for "url", the character length must be smaller than or equal to 65536.'
250
+ end
251
+
252
+ if url.to_s.length < 1
253
+ fail ArgumentError, 'invalid value for "url", the character length must be great than or equal to 1.'
254
+ end
255
+
256
+ @url = url
257
+ end
258
+
259
+ # Checks equality by comparing each attribute.
260
+ # @param [Object] Object to be compared
261
+ def ==(o)
262
+ return true if self.equal?(o)
263
+ self.class == o.class &&
264
+ created_at == o.created_at &&
265
+ description == o.description &&
266
+ disabled == o.disabled &&
267
+ filter_types == o.filter_types &&
268
+ id == o.id &&
269
+ next_attempt == o.next_attempt &&
270
+ rate_limit == o.rate_limit &&
271
+ status == o.status &&
272
+ uid == o.uid &&
273
+ url == o.url &&
274
+ version == o.version
275
+ end
276
+
277
+ # @see the `==` method
278
+ # @param [Object] Object to be compared
279
+ def eql?(o)
280
+ self == o
281
+ end
282
+
283
+ # Calculates hash code according to all attributes.
284
+ # @return [Integer] Hash code
285
+ def hash
286
+ [created_at, description, disabled, filter_types, id, next_attempt, rate_limit, status, uid, url, version].hash
287
+ end
288
+
289
+ # Builds the object from hash
290
+ # @param [Hash] attributes Model attributes in the form of hash
291
+ # @return [Object] Returns the model itself
292
+ def self.build_from_hash(attributes)
293
+ new.build_from_hash(attributes)
294
+ end
295
+
296
+ # Builds the object from hash
297
+ # @param [Hash] attributes Model attributes in the form of hash
298
+ # @return [Object] Returns the model itself
299
+ def build_from_hash(attributes)
300
+ return nil unless attributes.is_a?(Hash)
301
+ self.class.openapi_types.each_pair do |key, type|
302
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
303
+ self.send("#{key}=", nil)
304
+ elsif type =~ /\AArray<(.*)>/i
305
+ # check to ensure the input is an array given that the attribute
306
+ # is documented as an array but the input is not
307
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
308
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
309
+ end
310
+ elsif !attributes[self.class.attribute_map[key]].nil?
311
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
312
+ end
313
+ end
314
+
315
+ self
316
+ end
317
+
318
+ # Deserializes the data based on type
319
+ # @param string type Data type
320
+ # @param string value Value to be deserialized
321
+ # @return [Object] Deserialized data
322
+ def _deserialize(type, value)
323
+ case type.to_sym
324
+ when :Time
325
+ Time.parse(value)
326
+ when :Date
327
+ Date.parse(value)
328
+ when :String
329
+ value.to_s
330
+ when :Integer
331
+ value.to_i
332
+ when :Float
333
+ value.to_f
334
+ when :Boolean
335
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
336
+ true
337
+ else
338
+ false
339
+ end
340
+ when :Object
341
+ # generic object (usually a Hash), return directly
342
+ value
343
+ when /\AArray<(?<inner_type>.+)>\z/
344
+ inner_type = Regexp.last_match[:inner_type]
345
+ value.map { |v| _deserialize(inner_type, v) }
346
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
347
+ k_type = Regexp.last_match[:k_type]
348
+ v_type = Regexp.last_match[:v_type]
349
+ {}.tap do |hash|
350
+ value.each do |k, v|
351
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
352
+ end
353
+ end
354
+ else # model
355
+ # models (e.g. Pet) or oneOf
356
+ klass = Svix.const_get(type)
357
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
358
+ end
359
+ end
360
+
361
+ # Returns the string representation of the object
362
+ # @return [String] String presentation of the object
363
+ def to_s
364
+ to_hash.to_s
365
+ end
366
+
367
+ # to_body is an alias to to_hash (backward compatibility)
368
+ # @return [Hash] Returns the object in the form of hash
369
+ def to_body
370
+ to_hash
371
+ end
372
+
373
+ # Returns the object in the form of hash
374
+ # @return [Hash] Returns the object in the form of hash
375
+ def to_hash
376
+ hash = {}
377
+ self.class.attribute_map.each_pair do |attr, param|
378
+ value = self.send(attr)
379
+ if value.nil?
380
+ is_nullable = self.class.openapi_nullable.include?(attr)
381
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
382
+ end
383
+
384
+ hash[param] = _to_hash(value)
385
+ end
386
+ hash
387
+ end
388
+
389
+ # Outputs non-array value in the form of hash
390
+ # For object, use to_hash. Otherwise, just return the value
391
+ # @param [Object] value Any valid value
392
+ # @return [Hash] Returns the value in the form of hash
393
+ def _to_hash(value)
394
+ if value.is_a?(Array)
395
+ value.compact.map { |v| _to_hash(v) }
396
+ elsif value.is_a?(Hash)
397
+ {}.tap do |hash|
398
+ value.each { |k, v| hash[k] = _to_hash(v) }
399
+ end
400
+ elsif value.respond_to? :to_hash
401
+ value.to_hash
402
+ else
403
+ value
404
+ end
405
+ end
406
+
407
+ end
408
+
409
+ end