svix 0.28.0 → 0.32.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) 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 +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 +0 -0
  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/{src → lib}/svix/version.rb +1 -1
  68. data/{src → lib}/svix/webhook.rb +1 -1
  69. data/lib/svix.rb +76 -0
  70. data/svix.gemspec +16 -6
  71. metadata +89 -9
  72. data/.gitignore +0 -9
  73. data/src/svix.rb +0 -8
@@ -0,0 +1,312 @@
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 MessageIn
18
+ # Optional unique identifier for the message
19
+ attr_accessor :event_id
20
+
21
+ attr_accessor :event_type
22
+
23
+ attr_accessor :payload
24
+
25
+ # Attribute mapping from ruby-style variable name to JSON key.
26
+ def self.attribute_map
27
+ {
28
+ :'event_id' => :'eventId',
29
+ :'event_type' => :'eventType',
30
+ :'payload' => :'payload'
31
+ }
32
+ end
33
+
34
+ # Returns all the JSON keys this model knows about
35
+ def self.acceptable_attributes
36
+ attribute_map.values
37
+ end
38
+
39
+ # Attribute type mapping.
40
+ def self.openapi_types
41
+ {
42
+ :'event_id' => :'String',
43
+ :'event_type' => :'String',
44
+ :'payload' => :'Object'
45
+ }
46
+ end
47
+
48
+ # List of attributes with nullable: true
49
+ def self.openapi_nullable
50
+ Set.new([
51
+ ])
52
+ end
53
+
54
+ # Initializes the object
55
+ # @param [Hash] attributes Model attributes in the form of hash
56
+ def initialize(attributes = {})
57
+ if (!attributes.is_a?(Hash))
58
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Svix::MessageIn` initialize method"
59
+ end
60
+
61
+ # check to see if the attribute exists and convert string to symbol for hash key
62
+ attributes = attributes.each_with_object({}) { |(k, v), h|
63
+ if (!self.class.attribute_map.key?(k.to_sym))
64
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Svix::MessageIn`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
65
+ end
66
+ h[k.to_sym] = v
67
+ }
68
+
69
+ if attributes.key?(:'event_id')
70
+ self.event_id = attributes[:'event_id']
71
+ end
72
+
73
+ if attributes.key?(:'event_type')
74
+ self.event_type = attributes[:'event_type']
75
+ end
76
+
77
+ if attributes.key?(:'payload')
78
+ self.payload = attributes[:'payload']
79
+ end
80
+ end
81
+
82
+ # Show invalid properties with the reasons. Usually used together with valid?
83
+ # @return Array for valid properties with the reasons
84
+ def list_invalid_properties
85
+ invalid_properties = Array.new
86
+ if !@event_id.nil? && @event_id.to_s.length > 256
87
+ invalid_properties.push('invalid value for "event_id", the character length must be smaller than or equal to 256.')
88
+ end
89
+
90
+ if !@event_id.nil? && @event_id.to_s.length < 1
91
+ invalid_properties.push('invalid value for "event_id", the character length must be great than or equal to 1.')
92
+ end
93
+
94
+ pattern = Regexp.new(/^[a-zA-Z0-9\-_.]+$/)
95
+ if !@event_id.nil? && @event_id !~ pattern
96
+ invalid_properties.push("invalid value for \"event_id\", must conform to the pattern #{pattern}.")
97
+ end
98
+
99
+ if @event_type.nil?
100
+ invalid_properties.push('invalid value for "event_type", event_type cannot be nil.')
101
+ end
102
+
103
+ if @event_type.to_s.length > 256
104
+ invalid_properties.push('invalid value for "event_type", the character length must be smaller than or equal to 256.')
105
+ end
106
+
107
+ pattern = Regexp.new(/^[a-zA-Z0-9\-_.]+$/)
108
+ if @event_type !~ pattern
109
+ invalid_properties.push("invalid value for \"event_type\", must conform to the pattern #{pattern}.")
110
+ end
111
+
112
+ if @payload.nil?
113
+ invalid_properties.push('invalid value for "payload", payload cannot be nil.')
114
+ end
115
+
116
+ invalid_properties
117
+ end
118
+
119
+ # Check to see if the all the properties in the model are valid
120
+ # @return true if the model is valid
121
+ def valid?
122
+ return false if !@event_id.nil? && @event_id.to_s.length > 256
123
+ return false if !@event_id.nil? && @event_id.to_s.length < 1
124
+ return false if !@event_id.nil? && @event_id !~ Regexp.new(/^[a-zA-Z0-9\-_.]+$/)
125
+ return false if @event_type.nil?
126
+ return false if @event_type.to_s.length > 256
127
+ return false if @event_type !~ Regexp.new(/^[a-zA-Z0-9\-_.]+$/)
128
+ return false if @payload.nil?
129
+ true
130
+ end
131
+
132
+ # Custom attribute writer method with validation
133
+ # @param [Object] event_id Value to be assigned
134
+ def event_id=(event_id)
135
+ if !event_id.nil? && event_id.to_s.length > 256
136
+ fail ArgumentError, 'invalid value for "event_id", the character length must be smaller than or equal to 256.'
137
+ end
138
+
139
+ if !event_id.nil? && event_id.to_s.length < 1
140
+ fail ArgumentError, 'invalid value for "event_id", the character length must be great than or equal to 1.'
141
+ end
142
+
143
+ pattern = Regexp.new(/^[a-zA-Z0-9\-_.]+$/)
144
+ if !event_id.nil? && event_id !~ pattern
145
+ fail ArgumentError, "invalid value for \"event_id\", must conform to the pattern #{pattern}."
146
+ end
147
+
148
+ @event_id = event_id
149
+ end
150
+
151
+ # Custom attribute writer method with validation
152
+ # @param [Object] event_type Value to be assigned
153
+ def event_type=(event_type)
154
+ if event_type.nil?
155
+ fail ArgumentError, 'event_type cannot be nil'
156
+ end
157
+
158
+ if event_type.to_s.length > 256
159
+ fail ArgumentError, 'invalid value for "event_type", the character length must be smaller than or equal to 256.'
160
+ end
161
+
162
+ pattern = Regexp.new(/^[a-zA-Z0-9\-_.]+$/)
163
+ if event_type !~ pattern
164
+ fail ArgumentError, "invalid value for \"event_type\", must conform to the pattern #{pattern}."
165
+ end
166
+
167
+ @event_type = event_type
168
+ end
169
+
170
+ # Checks equality by comparing each attribute.
171
+ # @param [Object] Object to be compared
172
+ def ==(o)
173
+ return true if self.equal?(o)
174
+ self.class == o.class &&
175
+ event_id == o.event_id &&
176
+ event_type == o.event_type &&
177
+ payload == o.payload
178
+ end
179
+
180
+ # @see the `==` method
181
+ # @param [Object] Object to be compared
182
+ def eql?(o)
183
+ self == o
184
+ end
185
+
186
+ # Calculates hash code according to all attributes.
187
+ # @return [Integer] Hash code
188
+ def hash
189
+ [event_id, event_type, payload].hash
190
+ end
191
+
192
+ # Builds the object from hash
193
+ # @param [Hash] attributes Model attributes in the form of hash
194
+ # @return [Object] Returns the model itself
195
+ def self.build_from_hash(attributes)
196
+ new.build_from_hash(attributes)
197
+ end
198
+
199
+ # Builds the object from hash
200
+ # @param [Hash] attributes Model attributes in the form of hash
201
+ # @return [Object] Returns the model itself
202
+ def build_from_hash(attributes)
203
+ return nil unless attributes.is_a?(Hash)
204
+ self.class.openapi_types.each_pair do |key, type|
205
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
206
+ self.send("#{key}=", nil)
207
+ elsif type =~ /\AArray<(.*)>/i
208
+ # check to ensure the input is an array given that the attribute
209
+ # is documented as an array but the input is not
210
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
211
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
212
+ end
213
+ elsif !attributes[self.class.attribute_map[key]].nil?
214
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
215
+ end
216
+ end
217
+
218
+ self
219
+ end
220
+
221
+ # Deserializes the data based on type
222
+ # @param string type Data type
223
+ # @param string value Value to be deserialized
224
+ # @return [Object] Deserialized data
225
+ def _deserialize(type, value)
226
+ case type.to_sym
227
+ when :Time
228
+ Time.parse(value)
229
+ when :Date
230
+ Date.parse(value)
231
+ when :String
232
+ value.to_s
233
+ when :Integer
234
+ value.to_i
235
+ when :Float
236
+ value.to_f
237
+ when :Boolean
238
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
239
+ true
240
+ else
241
+ false
242
+ end
243
+ when :Object
244
+ # generic object (usually a Hash), return directly
245
+ value
246
+ when /\AArray<(?<inner_type>.+)>\z/
247
+ inner_type = Regexp.last_match[:inner_type]
248
+ value.map { |v| _deserialize(inner_type, v) }
249
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
250
+ k_type = Regexp.last_match[:k_type]
251
+ v_type = Regexp.last_match[:v_type]
252
+ {}.tap do |hash|
253
+ value.each do |k, v|
254
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
255
+ end
256
+ end
257
+ else # model
258
+ # models (e.g. Pet) or oneOf
259
+ klass = Svix.const_get(type)
260
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
261
+ end
262
+ end
263
+
264
+ # Returns the string representation of the object
265
+ # @return [String] String presentation of the object
266
+ def to_s
267
+ to_hash.to_s
268
+ end
269
+
270
+ # to_body is an alias to to_hash (backward compatibility)
271
+ # @return [Hash] Returns the object in the form of hash
272
+ def to_body
273
+ to_hash
274
+ end
275
+
276
+ # Returns the object in the form of hash
277
+ # @return [Hash] Returns the object in the form of hash
278
+ def to_hash
279
+ hash = {}
280
+ self.class.attribute_map.each_pair do |attr, param|
281
+ value = self.send(attr)
282
+ if value.nil?
283
+ is_nullable = self.class.openapi_nullable.include?(attr)
284
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
285
+ end
286
+
287
+ hash[param] = _to_hash(value)
288
+ end
289
+ hash
290
+ end
291
+
292
+ # Outputs non-array value in the form of hash
293
+ # For object, use to_hash. Otherwise, just return the value
294
+ # @param [Object] value Any valid value
295
+ # @return [Hash] Returns the value in the form of hash
296
+ def _to_hash(value)
297
+ if value.is_a?(Array)
298
+ value.compact.map { |v| _to_hash(v) }
299
+ elsif value.is_a?(Hash)
300
+ {}.tap do |hash|
301
+ value.each { |k, v| hash[k] = _to_hash(v) }
302
+ end
303
+ elsif value.respond_to? :to_hash
304
+ value.to_hash
305
+ else
306
+ value
307
+ end
308
+ end
309
+
310
+ end
311
+
312
+ end
@@ -0,0 +1,340 @@
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 MessageOut
18
+ # Optional unique identifier for the message
19
+ attr_accessor :event_id
20
+
21
+ attr_accessor :event_type
22
+
23
+ attr_accessor :id
24
+
25
+ attr_accessor :payload
26
+
27
+ attr_accessor :timestamp
28
+
29
+ # Attribute mapping from ruby-style variable name to JSON key.
30
+ def self.attribute_map
31
+ {
32
+ :'event_id' => :'eventId',
33
+ :'event_type' => :'eventType',
34
+ :'id' => :'id',
35
+ :'payload' => :'payload',
36
+ :'timestamp' => :'timestamp'
37
+ }
38
+ end
39
+
40
+ # Returns all the JSON keys this model knows about
41
+ def self.acceptable_attributes
42
+ attribute_map.values
43
+ end
44
+
45
+ # Attribute type mapping.
46
+ def self.openapi_types
47
+ {
48
+ :'event_id' => :'String',
49
+ :'event_type' => :'String',
50
+ :'id' => :'String',
51
+ :'payload' => :'Object',
52
+ :'timestamp' => :'Time'
53
+ }
54
+ end
55
+
56
+ # List of attributes with nullable: true
57
+ def self.openapi_nullable
58
+ Set.new([
59
+ ])
60
+ end
61
+
62
+ # Initializes the object
63
+ # @param [Hash] attributes Model attributes in the form of hash
64
+ def initialize(attributes = {})
65
+ if (!attributes.is_a?(Hash))
66
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Svix::MessageOut` initialize method"
67
+ end
68
+
69
+ # check to see if the attribute exists and convert string to symbol for hash key
70
+ attributes = attributes.each_with_object({}) { |(k, v), h|
71
+ if (!self.class.attribute_map.key?(k.to_sym))
72
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Svix::MessageOut`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
73
+ end
74
+ h[k.to_sym] = v
75
+ }
76
+
77
+ if attributes.key?(:'event_id')
78
+ self.event_id = attributes[:'event_id']
79
+ end
80
+
81
+ if attributes.key?(:'event_type')
82
+ self.event_type = attributes[:'event_type']
83
+ end
84
+
85
+ if attributes.key?(:'id')
86
+ self.id = attributes[:'id']
87
+ end
88
+
89
+ if attributes.key?(:'payload')
90
+ self.payload = attributes[:'payload']
91
+ end
92
+
93
+ if attributes.key?(:'timestamp')
94
+ self.timestamp = attributes[:'timestamp']
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 !@event_id.nil? && @event_id.to_s.length > 256
103
+ invalid_properties.push('invalid value for "event_id", the character length must be smaller than or equal to 256.')
104
+ end
105
+
106
+ if !@event_id.nil? && @event_id.to_s.length < 1
107
+ invalid_properties.push('invalid value for "event_id", the character length must be great than or equal to 1.')
108
+ end
109
+
110
+ pattern = Regexp.new(/^[a-zA-Z0-9\-_.]+$/)
111
+ if !@event_id.nil? && @event_id !~ pattern
112
+ invalid_properties.push("invalid value for \"event_id\", must conform to the pattern #{pattern}.")
113
+ end
114
+
115
+ if @event_type.nil?
116
+ invalid_properties.push('invalid value for "event_type", event_type cannot be nil.')
117
+ end
118
+
119
+ if @event_type.to_s.length > 256
120
+ invalid_properties.push('invalid value for "event_type", the character length must be smaller than or equal to 256.')
121
+ end
122
+
123
+ pattern = Regexp.new(/^[a-zA-Z0-9\-_.]+$/)
124
+ if @event_type !~ pattern
125
+ invalid_properties.push("invalid value for \"event_type\", must conform to the pattern #{pattern}.")
126
+ end
127
+
128
+ if @id.nil?
129
+ invalid_properties.push('invalid value for "id", id cannot be nil.')
130
+ end
131
+
132
+ if @payload.nil?
133
+ invalid_properties.push('invalid value for "payload", payload cannot be nil.')
134
+ end
135
+
136
+ if @timestamp.nil?
137
+ invalid_properties.push('invalid value for "timestamp", timestamp cannot be nil.')
138
+ end
139
+
140
+ invalid_properties
141
+ end
142
+
143
+ # Check to see if the all the properties in the model are valid
144
+ # @return true if the model is valid
145
+ def valid?
146
+ return false if !@event_id.nil? && @event_id.to_s.length > 256
147
+ return false if !@event_id.nil? && @event_id.to_s.length < 1
148
+ return false if !@event_id.nil? && @event_id !~ Regexp.new(/^[a-zA-Z0-9\-_.]+$/)
149
+ return false if @event_type.nil?
150
+ return false if @event_type.to_s.length > 256
151
+ return false if @event_type !~ Regexp.new(/^[a-zA-Z0-9\-_.]+$/)
152
+ return false if @id.nil?
153
+ return false if @payload.nil?
154
+ return false if @timestamp.nil?
155
+ true
156
+ end
157
+
158
+ # Custom attribute writer method with validation
159
+ # @param [Object] event_id Value to be assigned
160
+ def event_id=(event_id)
161
+ if !event_id.nil? && event_id.to_s.length > 256
162
+ fail ArgumentError, 'invalid value for "event_id", the character length must be smaller than or equal to 256.'
163
+ end
164
+
165
+ if !event_id.nil? && event_id.to_s.length < 1
166
+ fail ArgumentError, 'invalid value for "event_id", the character length must be great than or equal to 1.'
167
+ end
168
+
169
+ pattern = Regexp.new(/^[a-zA-Z0-9\-_.]+$/)
170
+ if !event_id.nil? && event_id !~ pattern
171
+ fail ArgumentError, "invalid value for \"event_id\", must conform to the pattern #{pattern}."
172
+ end
173
+
174
+ @event_id = event_id
175
+ end
176
+
177
+ # Custom attribute writer method with validation
178
+ # @param [Object] event_type Value to be assigned
179
+ def event_type=(event_type)
180
+ if event_type.nil?
181
+ fail ArgumentError, 'event_type cannot be nil'
182
+ end
183
+
184
+ if event_type.to_s.length > 256
185
+ fail ArgumentError, 'invalid value for "event_type", the character length must be smaller than or equal to 256.'
186
+ end
187
+
188
+ pattern = Regexp.new(/^[a-zA-Z0-9\-_.]+$/)
189
+ if event_type !~ pattern
190
+ fail ArgumentError, "invalid value for \"event_type\", must conform to the pattern #{pattern}."
191
+ end
192
+
193
+ @event_type = event_type
194
+ end
195
+
196
+ # Checks equality by comparing each attribute.
197
+ # @param [Object] Object to be compared
198
+ def ==(o)
199
+ return true if self.equal?(o)
200
+ self.class == o.class &&
201
+ event_id == o.event_id &&
202
+ event_type == o.event_type &&
203
+ id == o.id &&
204
+ payload == o.payload &&
205
+ timestamp == o.timestamp
206
+ end
207
+
208
+ # @see the `==` method
209
+ # @param [Object] Object to be compared
210
+ def eql?(o)
211
+ self == o
212
+ end
213
+
214
+ # Calculates hash code according to all attributes.
215
+ # @return [Integer] Hash code
216
+ def hash
217
+ [event_id, event_type, id, payload, timestamp].hash
218
+ end
219
+
220
+ # Builds the object from hash
221
+ # @param [Hash] attributes Model attributes in the form of hash
222
+ # @return [Object] Returns the model itself
223
+ def self.build_from_hash(attributes)
224
+ new.build_from_hash(attributes)
225
+ end
226
+
227
+ # Builds the object from hash
228
+ # @param [Hash] attributes Model attributes in the form of hash
229
+ # @return [Object] Returns the model itself
230
+ def build_from_hash(attributes)
231
+ return nil unless attributes.is_a?(Hash)
232
+ self.class.openapi_types.each_pair do |key, type|
233
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
234
+ self.send("#{key}=", nil)
235
+ elsif type =~ /\AArray<(.*)>/i
236
+ # check to ensure the input is an array given that the attribute
237
+ # is documented as an array but the input is not
238
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
239
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
240
+ end
241
+ elsif !attributes[self.class.attribute_map[key]].nil?
242
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
243
+ end
244
+ end
245
+
246
+ self
247
+ end
248
+
249
+ # Deserializes the data based on type
250
+ # @param string type Data type
251
+ # @param string value Value to be deserialized
252
+ # @return [Object] Deserialized data
253
+ def _deserialize(type, value)
254
+ case type.to_sym
255
+ when :Time
256
+ Time.parse(value)
257
+ when :Date
258
+ Date.parse(value)
259
+ when :String
260
+ value.to_s
261
+ when :Integer
262
+ value.to_i
263
+ when :Float
264
+ value.to_f
265
+ when :Boolean
266
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
267
+ true
268
+ else
269
+ false
270
+ end
271
+ when :Object
272
+ # generic object (usually a Hash), return directly
273
+ value
274
+ when /\AArray<(?<inner_type>.+)>\z/
275
+ inner_type = Regexp.last_match[:inner_type]
276
+ value.map { |v| _deserialize(inner_type, v) }
277
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
278
+ k_type = Regexp.last_match[:k_type]
279
+ v_type = Regexp.last_match[:v_type]
280
+ {}.tap do |hash|
281
+ value.each do |k, v|
282
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
283
+ end
284
+ end
285
+ else # model
286
+ # models (e.g. Pet) or oneOf
287
+ klass = Svix.const_get(type)
288
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
289
+ end
290
+ end
291
+
292
+ # Returns the string representation of the object
293
+ # @return [String] String presentation of the object
294
+ def to_s
295
+ to_hash.to_s
296
+ end
297
+
298
+ # to_body is an alias to to_hash (backward compatibility)
299
+ # @return [Hash] Returns the object in the form of hash
300
+ def to_body
301
+ to_hash
302
+ end
303
+
304
+ # Returns the object in the form of hash
305
+ # @return [Hash] Returns the object in the form of hash
306
+ def to_hash
307
+ hash = {}
308
+ self.class.attribute_map.each_pair do |attr, param|
309
+ value = self.send(attr)
310
+ if value.nil?
311
+ is_nullable = self.class.openapi_nullable.include?(attr)
312
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
313
+ end
314
+
315
+ hash[param] = _to_hash(value)
316
+ end
317
+ hash
318
+ end
319
+
320
+ # Outputs non-array value in the form of hash
321
+ # For object, use to_hash. Otherwise, just return the value
322
+ # @param [Object] value Any valid value
323
+ # @return [Hash] Returns the value in the form of hash
324
+ def _to_hash(value)
325
+ if value.is_a?(Array)
326
+ value.compact.map { |v| _to_hash(v) }
327
+ elsif value.is_a?(Hash)
328
+ {}.tap do |hash|
329
+ value.each { |k, v| hash[k] = _to_hash(v) }
330
+ end
331
+ elsif value.respond_to? :to_hash
332
+ value.to_hash
333
+ else
334
+ value
335
+ end
336
+ end
337
+
338
+ end
339
+
340
+ end
@@ -0,0 +1,39 @@
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 MessageStatus
18
+ Success = 0.freeze
19
+ Pending = 1.freeze
20
+ Fail = 2.freeze
21
+ Sending = 3.freeze
22
+
23
+ # Builds the enum from string
24
+ # @param [String] The enum value in the form of the string
25
+ # @return [String] The enum value
26
+ def self.build_from_hash(value)
27
+ new.build_from_hash(value)
28
+ end
29
+
30
+ # Builds the enum from string
31
+ # @param [String] The enum value in the form of the string
32
+ # @return [String] The enum value
33
+ def build_from_hash(value)
34
+ constantValues = MessageStatus.constants.select { |c| MessageStatus::const_get(c) == value }
35
+ raise "Invalid ENUM value #{value} for class #MessageStatus" if constantValues.empty?
36
+ value
37
+ end
38
+ end
39
+ end