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