svix 0.21.0 → 0.36.0

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