svix 0.67.0 → 0.68.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,283 @@
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 user on your platform. - `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/). ## Idempotency Svix supports [idempotency](https://en.wikipedia.org/wiki/Idempotence) for safely retrying requests without accidentally performing the same operation twice. This is useful when an API call is disrupted in transit and you do not receive a response. To perform an idempotent request, pass the idempotency key in the `Idempotency-Key` header to the request. The idempotency key should be a unique value generated by the client. You can create the key in however way you like, though we suggest using UUID v4, or any other string with enough entropy to avoid collisions. Svix's idempotency works by saving the resulting status code and body of the first request made for any given idempotency key for any successful request. Subsequent requests with the same key return the same result. Please note that idempotency is only supported for `POST` requests. ## 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 ApplicationStats
18
+ attr_accessor :app_id
19
+
20
+ # Optional unique identifier for the application
21
+ attr_accessor :app_uid
22
+
23
+ attr_accessor :message_destinations
24
+
25
+ # Attribute mapping from ruby-style variable name to JSON key.
26
+ def self.attribute_map
27
+ {
28
+ :'app_id' => :'appId',
29
+ :'app_uid' => :'appUid',
30
+ :'message_destinations' => :'messageDestinations'
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
+ :'app_id' => :'String',
43
+ :'app_uid' => :'String',
44
+ :'message_destinations' => :'Integer'
45
+ }
46
+ end
47
+
48
+ # List of attributes with nullable: true
49
+ def self.openapi_nullable
50
+ Set.new([
51
+ :'app_uid',
52
+ ])
53
+ end
54
+
55
+ # Initializes the object
56
+ # @param [Hash] attributes Model attributes in the form of hash
57
+ def initialize(attributes = {})
58
+ if (!attributes.is_a?(Hash))
59
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Svix::ApplicationStats` initialize method"
60
+ end
61
+
62
+ # check to see if the attribute exists and convert string to symbol for hash key
63
+ attributes = attributes.each_with_object({}) { |(k, v), h|
64
+ if (!self.class.attribute_map.key?(k.to_sym))
65
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Svix::ApplicationStats`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
66
+ end
67
+ h[k.to_sym] = v
68
+ }
69
+
70
+ if attributes.key?(:'app_id')
71
+ self.app_id = attributes[:'app_id']
72
+ end
73
+
74
+ if attributes.key?(:'app_uid')
75
+ self.app_uid = attributes[:'app_uid']
76
+ end
77
+
78
+ if attributes.key?(:'message_destinations')
79
+ self.message_destinations = attributes[:'message_destinations']
80
+ end
81
+ end
82
+
83
+ # Show invalid properties with the reasons. Usually used together with valid?
84
+ # @return Array for valid properties with the reasons
85
+ def list_invalid_properties
86
+ invalid_properties = Array.new
87
+ if @app_id.nil?
88
+ invalid_properties.push('invalid value for "app_id", app_id cannot be nil.')
89
+ end
90
+
91
+ if !@app_uid.nil? && @app_uid.to_s.length > 256
92
+ invalid_properties.push('invalid value for "app_uid", the character length must be smaller than or equal to 256.')
93
+ end
94
+
95
+ if !@app_uid.nil? && @app_uid.to_s.length < 1
96
+ invalid_properties.push('invalid value for "app_uid", the character length must be great than or equal to 1.')
97
+ end
98
+
99
+ pattern = Regexp.new(/^[a-zA-Z0-9\-_.]+$/)
100
+ if !@app_uid.nil? && @app_uid !~ pattern
101
+ invalid_properties.push("invalid value for \"app_uid\", must conform to the pattern #{pattern}.")
102
+ end
103
+
104
+ if @message_destinations.nil?
105
+ invalid_properties.push('invalid value for "message_destinations", message_destinations cannot be nil.')
106
+ end
107
+
108
+ invalid_properties
109
+ end
110
+
111
+ # Check to see if the all the properties in the model are valid
112
+ # @return true if the model is valid
113
+ def valid?
114
+ return false if @app_id.nil?
115
+ return false if !@app_uid.nil? && @app_uid.to_s.length > 256
116
+ return false if !@app_uid.nil? && @app_uid.to_s.length < 1
117
+ return false if !@app_uid.nil? && @app_uid !~ Regexp.new(/^[a-zA-Z0-9\-_.]+$/)
118
+ return false if @message_destinations.nil?
119
+ true
120
+ end
121
+
122
+ # Custom attribute writer method with validation
123
+ # @param [Object] app_uid Value to be assigned
124
+ def app_uid=(app_uid)
125
+ if !app_uid.nil? && app_uid.to_s.length > 256
126
+ fail ArgumentError, 'invalid value for "app_uid", the character length must be smaller than or equal to 256.'
127
+ end
128
+
129
+ if !app_uid.nil? && app_uid.to_s.length < 1
130
+ fail ArgumentError, 'invalid value for "app_uid", the character length must be great than or equal to 1.'
131
+ end
132
+
133
+ pattern = Regexp.new(/^[a-zA-Z0-9\-_.]+$/)
134
+ if !app_uid.nil? && app_uid !~ pattern
135
+ fail ArgumentError, "invalid value for \"app_uid\", must conform to the pattern #{pattern}."
136
+ end
137
+
138
+ @app_uid = app_uid
139
+ end
140
+
141
+ # Checks equality by comparing each attribute.
142
+ # @param [Object] Object to be compared
143
+ def ==(o)
144
+ return true if self.equal?(o)
145
+ self.class == o.class &&
146
+ app_id == o.app_id &&
147
+ app_uid == o.app_uid &&
148
+ message_destinations == o.message_destinations
149
+ end
150
+
151
+ # @see the `==` method
152
+ # @param [Object] Object to be compared
153
+ def eql?(o)
154
+ self == o
155
+ end
156
+
157
+ # Calculates hash code according to all attributes.
158
+ # @return [Integer] Hash code
159
+ def hash
160
+ [app_id, app_uid, message_destinations].hash
161
+ end
162
+
163
+ # Builds the object from hash
164
+ # @param [Hash] attributes Model attributes in the form of hash
165
+ # @return [Object] Returns the model itself
166
+ def self.build_from_hash(attributes)
167
+ new.build_from_hash(attributes)
168
+ end
169
+
170
+ # Builds the object from hash
171
+ # @param [Hash] attributes Model attributes in the form of hash
172
+ # @return [Object] Returns the model itself
173
+ def build_from_hash(attributes)
174
+ return nil unless attributes.is_a?(Hash)
175
+ self.class.openapi_types.each_pair do |key, type|
176
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
177
+ self.send("#{key}=", nil)
178
+ elsif type =~ /\AArray<(.*)>/i
179
+ # check to ensure the input is an array given that the attribute
180
+ # is documented as an array but the input is not
181
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
182
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
183
+ end
184
+ elsif !attributes[self.class.attribute_map[key]].nil?
185
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
186
+ end
187
+ end
188
+
189
+ self
190
+ end
191
+
192
+ # Deserializes the data based on type
193
+ # @param string type Data type
194
+ # @param string value Value to be deserialized
195
+ # @return [Object] Deserialized data
196
+ def _deserialize(type, value)
197
+ case type.to_sym
198
+ when :Time
199
+ Time.parse(value)
200
+ when :Date
201
+ Date.parse(value)
202
+ when :String
203
+ value.to_s
204
+ when :Integer
205
+ value.to_i
206
+ when :Float
207
+ value.to_f
208
+ when :Boolean
209
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
210
+ true
211
+ else
212
+ false
213
+ end
214
+ when :Object
215
+ # generic object (usually a Hash), return directly
216
+ value
217
+ when /\AArray<(?<inner_type>.+)>\z/
218
+ inner_type = Regexp.last_match[:inner_type]
219
+ value.map { |v| _deserialize(inner_type, v) }
220
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
221
+ k_type = Regexp.last_match[:k_type]
222
+ v_type = Regexp.last_match[:v_type]
223
+ {}.tap do |hash|
224
+ value.each do |k, v|
225
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
226
+ end
227
+ end
228
+ else # model
229
+ # models (e.g. Pet) or oneOf
230
+ klass = Svix.const_get(type)
231
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
232
+ end
233
+ end
234
+
235
+ # Returns the string representation of the object
236
+ # @return [String] String presentation of the object
237
+ def to_s
238
+ to_hash.to_s
239
+ end
240
+
241
+ # to_body is an alias to to_hash (backward compatibility)
242
+ # @return [Hash] Returns the object in the form of hash
243
+ def to_body
244
+ to_hash
245
+ end
246
+
247
+ # Returns the object in the form of hash
248
+ # @return [Hash] Returns the object in the form of hash
249
+ def to_hash
250
+ hash = {}
251
+ self.class.attribute_map.each_pair do |attr, param|
252
+ value = self.send(attr)
253
+ if value.nil?
254
+ is_nullable = self.class.openapi_nullable.include?(attr)
255
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
256
+ end
257
+
258
+ hash[param] = _to_hash(value)
259
+ end
260
+ hash
261
+ end
262
+
263
+ # Outputs non-array value in the form of hash
264
+ # For object, use to_hash. Otherwise, just return the value
265
+ # @param [Object] value Any valid value
266
+ # @return [Hash] Returns the value in the form of hash
267
+ def _to_hash(value)
268
+ if value.is_a?(Array)
269
+ value.compact.map { |v| _to_hash(v) }
270
+ elsif value.is_a?(Hash)
271
+ {}.tap do |hash|
272
+ value.each { |k, v| hash[k] = _to_hash(v) }
273
+ end
274
+ elsif value.respond_to? :to_hash
275
+ value.to_hash
276
+ else
277
+ value
278
+ end
279
+ end
280
+
281
+ end
282
+
283
+ end
@@ -24,6 +24,8 @@ module Svix
24
24
 
25
25
  attr_accessor :filter_types
26
26
 
27
+ attr_accessor :metadata
28
+
27
29
  attr_accessor :rate_limit
28
30
 
29
31
  # The endpoint's verification secret. If `null` is passed, a secret is automatically generated. Format: `base64` encoded random bytes optionally prefixed with `whsec_`. Recommended size: 24.
@@ -43,6 +45,7 @@ module Svix
43
45
  :'description' => :'description',
44
46
  :'disabled' => :'disabled',
45
47
  :'filter_types' => :'filterTypes',
48
+ :'metadata' => :'metadata',
46
49
  :'rate_limit' => :'rateLimit',
47
50
  :'secret' => :'secret',
48
51
  :'uid' => :'uid',
@@ -63,6 +66,7 @@ module Svix
63
66
  :'description' => :'String',
64
67
  :'disabled' => :'Boolean',
65
68
  :'filter_types' => :'Array<String>',
69
+ :'metadata' => :'Hash<String, String>',
66
70
  :'rate_limit' => :'Integer',
67
71
  :'secret' => :'String',
68
72
  :'uid' => :'String',
@@ -76,6 +80,7 @@ module Svix
76
80
  Set.new([
77
81
  :'channels',
78
82
  :'filter_types',
83
+ :'metadata',
79
84
  :'rate_limit',
80
85
  :'secret',
81
86
  :'uid',
@@ -121,6 +126,12 @@ module Svix
121
126
  end
122
127
  end
123
128
 
129
+ if attributes.key?(:'metadata')
130
+ if (value = attributes[:'metadata']).is_a?(Hash)
131
+ self.metadata = value
132
+ end
133
+ end
134
+
124
135
  if attributes.key?(:'rate_limit')
125
136
  self.rate_limit = attributes[:'rate_limit']
126
137
  end
@@ -317,6 +328,7 @@ module Svix
317
328
  description == o.description &&
318
329
  disabled == o.disabled &&
319
330
  filter_types == o.filter_types &&
331
+ metadata == o.metadata &&
320
332
  rate_limit == o.rate_limit &&
321
333
  secret == o.secret &&
322
334
  uid == o.uid &&
@@ -333,7 +345,7 @@ module Svix
333
345
  # Calculates hash code according to all attributes.
334
346
  # @return [Integer] Hash code
335
347
  def hash
336
- [channels, description, disabled, filter_types, rate_limit, secret, uid, url, version].hash
348
+ [channels, description, disabled, filter_types, metadata, rate_limit, secret, uid, url, version].hash
337
349
  end
338
350
 
339
351
  # Builds the object from hash
@@ -28,6 +28,8 @@ module Svix
28
28
 
29
29
  attr_accessor :id
30
30
 
31
+ attr_accessor :metadata
32
+
31
33
  attr_accessor :rate_limit
32
34
 
33
35
  # Optional unique identifier for the endpoint
@@ -48,6 +50,7 @@ module Svix
48
50
  :'disabled' => :'disabled',
49
51
  :'filter_types' => :'filterTypes',
50
52
  :'id' => :'id',
53
+ :'metadata' => :'metadata',
51
54
  :'rate_limit' => :'rateLimit',
52
55
  :'uid' => :'uid',
53
56
  :'updated_at' => :'updatedAt',
@@ -70,6 +73,7 @@ module Svix
70
73
  :'disabled' => :'Boolean',
71
74
  :'filter_types' => :'Array<String>',
72
75
  :'id' => :'String',
76
+ :'metadata' => :'Hash<String, String>',
73
77
  :'rate_limit' => :'Integer',
74
78
  :'uid' => :'String',
75
79
  :'updated_at' => :'Time',
@@ -83,6 +87,7 @@ module Svix
83
87
  Set.new([
84
88
  :'channels',
85
89
  :'filter_types',
90
+ :'metadata',
86
91
  :'rate_limit',
87
92
  :'uid',
88
93
  ])
@@ -135,6 +140,12 @@ module Svix
135
140
  self.id = attributes[:'id']
136
141
  end
137
142
 
143
+ if attributes.key?(:'metadata')
144
+ if (value = attributes[:'metadata']).is_a?(Hash)
145
+ self.metadata = value
146
+ end
147
+ end
148
+
138
149
  if attributes.key?(:'rate_limit')
139
150
  self.rate_limit = attributes[:'rate_limit']
140
151
  end
@@ -331,6 +342,7 @@ module Svix
331
342
  disabled == o.disabled &&
332
343
  filter_types == o.filter_types &&
333
344
  id == o.id &&
345
+ metadata == o.metadata &&
334
346
  rate_limit == o.rate_limit &&
335
347
  uid == o.uid &&
336
348
  updated_at == o.updated_at &&
@@ -347,7 +359,7 @@ module Svix
347
359
  # Calculates hash code according to all attributes.
348
360
  # @return [Integer] Hash code
349
361
  def hash
350
- [channels, created_at, description, disabled, filter_types, id, rate_limit, uid, updated_at, url, version].hash
362
+ [channels, created_at, description, disabled, filter_types, id, metadata, rate_limit, uid, updated_at, url, version].hash
351
363
  end
352
364
 
353
365
  # Builds the object from hash
@@ -24,6 +24,8 @@ module Svix
24
24
 
25
25
  attr_accessor :filter_types
26
26
 
27
+ attr_accessor :metadata
28
+
27
29
  attr_accessor :rate_limit
28
30
 
29
31
  # Optional unique identifier for the endpoint
@@ -40,6 +42,7 @@ module Svix
40
42
  :'description' => :'description',
41
43
  :'disabled' => :'disabled',
42
44
  :'filter_types' => :'filterTypes',
45
+ :'metadata' => :'metadata',
43
46
  :'rate_limit' => :'rateLimit',
44
47
  :'uid' => :'uid',
45
48
  :'url' => :'url',
@@ -59,6 +62,7 @@ module Svix
59
62
  :'description' => :'String',
60
63
  :'disabled' => :'Boolean',
61
64
  :'filter_types' => :'Array<String>',
65
+ :'metadata' => :'Hash<String, String>',
62
66
  :'rate_limit' => :'Integer',
63
67
  :'uid' => :'String',
64
68
  :'url' => :'String',
@@ -71,6 +75,7 @@ module Svix
71
75
  Set.new([
72
76
  :'channels',
73
77
  :'filter_types',
78
+ :'metadata',
74
79
  :'rate_limit',
75
80
  :'uid',
76
81
  ])
@@ -115,6 +120,12 @@ module Svix
115
120
  end
116
121
  end
117
122
 
123
+ if attributes.key?(:'metadata')
124
+ if (value = attributes[:'metadata']).is_a?(Hash)
125
+ self.metadata = value
126
+ end
127
+ end
128
+
118
129
  if attributes.key?(:'rate_limit')
119
130
  self.rate_limit = attributes[:'rate_limit']
120
131
  end
@@ -290,6 +301,7 @@ module Svix
290
301
  description == o.description &&
291
302
  disabled == o.disabled &&
292
303
  filter_types == o.filter_types &&
304
+ metadata == o.metadata &&
293
305
  rate_limit == o.rate_limit &&
294
306
  uid == o.uid &&
295
307
  url == o.url &&
@@ -305,7 +317,7 @@ module Svix
305
317
  # Calculates hash code according to all attributes.
306
318
  # @return [Integer] Hash code
307
319
  def hash
308
- [channels, description, disabled, filter_types, rate_limit, uid, url, version].hash
320
+ [channels, description, disabled, filter_types, metadata, rate_limit, uid, url, version].hash
309
321
  end
310
322
 
311
323
  # Builds the object from hash