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,253 @@
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 ValidationError
18
+ attr_accessor :loc
19
+
20
+ attr_accessor :msg
21
+
22
+ attr_accessor :type
23
+
24
+ # Attribute mapping from ruby-style variable name to JSON key.
25
+ def self.attribute_map
26
+ {
27
+ :'loc' => :'loc',
28
+ :'msg' => :'msg',
29
+ :'type' => :'type'
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
+ :'loc' => :'Array<String>',
42
+ :'msg' => :'String',
43
+ :'type' => :'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::ValidationError` 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::ValidationError`. 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?(:'loc')
69
+ if (value = attributes[:'loc']).is_a?(Array)
70
+ self.loc = value
71
+ end
72
+ end
73
+
74
+ if attributes.key?(:'msg')
75
+ self.msg = attributes[:'msg']
76
+ end
77
+
78
+ if attributes.key?(:'type')
79
+ self.type = attributes[:'type']
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 @loc.nil?
88
+ invalid_properties.push('invalid value for "loc", loc cannot be nil.')
89
+ end
90
+
91
+ if @msg.nil?
92
+ invalid_properties.push('invalid value for "msg", msg cannot be nil.')
93
+ end
94
+
95
+ if @type.nil?
96
+ invalid_properties.push('invalid value for "type", type cannot be nil.')
97
+ end
98
+
99
+ invalid_properties
100
+ end
101
+
102
+ # Check to see if the all the properties in the model are valid
103
+ # @return true if the model is valid
104
+ def valid?
105
+ return false if @loc.nil?
106
+ return false if @msg.nil?
107
+ return false if @type.nil?
108
+ true
109
+ end
110
+
111
+ # Checks equality by comparing each attribute.
112
+ # @param [Object] Object to be compared
113
+ def ==(o)
114
+ return true if self.equal?(o)
115
+ self.class == o.class &&
116
+ loc == o.loc &&
117
+ msg == o.msg &&
118
+ type == o.type
119
+ end
120
+
121
+ # @see the `==` method
122
+ # @param [Object] Object to be compared
123
+ def eql?(o)
124
+ self == o
125
+ end
126
+
127
+ # Calculates hash code according to all attributes.
128
+ # @return [Integer] Hash code
129
+ def hash
130
+ [loc, msg, type].hash
131
+ end
132
+
133
+ # Builds the object from hash
134
+ # @param [Hash] attributes Model attributes in the form of hash
135
+ # @return [Object] Returns the model itself
136
+ def self.build_from_hash(attributes)
137
+ new.build_from_hash(attributes)
138
+ end
139
+
140
+ # Builds the object from hash
141
+ # @param [Hash] attributes Model attributes in the form of hash
142
+ # @return [Object] Returns the model itself
143
+ def build_from_hash(attributes)
144
+ return nil unless attributes.is_a?(Hash)
145
+ self.class.openapi_types.each_pair do |key, type|
146
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
147
+ self.send("#{key}=", nil)
148
+ elsif type =~ /\AArray<(.*)>/i
149
+ # check to ensure the input is an array given that the attribute
150
+ # is documented as an array but the input is not
151
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
152
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
153
+ end
154
+ elsif !attributes[self.class.attribute_map[key]].nil?
155
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
156
+ end
157
+ end
158
+
159
+ self
160
+ end
161
+
162
+ # Deserializes the data based on type
163
+ # @param string type Data type
164
+ # @param string value Value to be deserialized
165
+ # @return [Object] Deserialized data
166
+ def _deserialize(type, value)
167
+ case type.to_sym
168
+ when :Time
169
+ Time.parse(value)
170
+ when :Date
171
+ Date.parse(value)
172
+ when :String
173
+ value.to_s
174
+ when :Integer
175
+ value.to_i
176
+ when :Float
177
+ value.to_f
178
+ when :Boolean
179
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
180
+ true
181
+ else
182
+ false
183
+ end
184
+ when :Object
185
+ # generic object (usually a Hash), return directly
186
+ value
187
+ when /\AArray<(?<inner_type>.+)>\z/
188
+ inner_type = Regexp.last_match[:inner_type]
189
+ value.map { |v| _deserialize(inner_type, v) }
190
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
191
+ k_type = Regexp.last_match[:k_type]
192
+ v_type = Regexp.last_match[:v_type]
193
+ {}.tap do |hash|
194
+ value.each do |k, v|
195
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
196
+ end
197
+ end
198
+ else # model
199
+ # models (e.g. Pet) or oneOf
200
+ klass = Svix.const_get(type)
201
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
202
+ end
203
+ end
204
+
205
+ # Returns the string representation of the object
206
+ # @return [String] String presentation of the object
207
+ def to_s
208
+ to_hash.to_s
209
+ end
210
+
211
+ # to_body is an alias to to_hash (backward compatibility)
212
+ # @return [Hash] Returns the object in the form of hash
213
+ def to_body
214
+ to_hash
215
+ end
216
+
217
+ # Returns the object in the form of hash
218
+ # @return [Hash] Returns the object in the form of hash
219
+ def to_hash
220
+ hash = {}
221
+ self.class.attribute_map.each_pair do |attr, param|
222
+ value = self.send(attr)
223
+ if value.nil?
224
+ is_nullable = self.class.openapi_nullable.include?(attr)
225
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
226
+ end
227
+
228
+ hash[param] = _to_hash(value)
229
+ end
230
+ hash
231
+ end
232
+
233
+ # Outputs non-array value in the form of hash
234
+ # For object, use to_hash. Otherwise, just return the value
235
+ # @param [Object] value Any valid value
236
+ # @return [Hash] Returns the value in the form of hash
237
+ def _to_hash(value)
238
+ if value.is_a?(Array)
239
+ value.compact.map { |v| _to_hash(v) }
240
+ elsif value.is_a?(Hash)
241
+ {}.tap do |hash|
242
+ value.each { |k, v| hash[k] = _to_hash(v) }
243
+ end
244
+ elsif value.respond_to? :to_hash
245
+ value.to_hash
246
+ else
247
+ value
248
+ end
249
+ end
250
+
251
+ end
252
+
253
+ end
@@ -0,0 +1,280 @@
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
+ # All of the webhook types that we support
18
+ class WebhookTypes
19
+ attr_accessor :a
20
+
21
+ attr_accessor :b
22
+
23
+ attr_accessor :c
24
+
25
+ attr_accessor :d
26
+
27
+ attr_accessor :e
28
+
29
+ # Attribute mapping from ruby-style variable name to JSON key.
30
+ def self.attribute_map
31
+ {
32
+ :'a' => :'a',
33
+ :'b' => :'b',
34
+ :'c' => :'c',
35
+ :'d' => :'d',
36
+ :'e' => :'e'
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
+ :'a' => :'EndpointDisabledEvent',
49
+ :'b' => :'EndpointCreatedEvent',
50
+ :'c' => :'EndpointdUpdatedEvent',
51
+ :'d' => :'EndpointDeletedEvent',
52
+ :'e' => :'MessageAttemptExhaustedEvent'
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::WebhookTypes` 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::WebhookTypes`. 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?(:'a')
78
+ self.a = attributes[:'a']
79
+ end
80
+
81
+ if attributes.key?(:'b')
82
+ self.b = attributes[:'b']
83
+ end
84
+
85
+ if attributes.key?(:'c')
86
+ self.c = attributes[:'c']
87
+ end
88
+
89
+ if attributes.key?(:'d')
90
+ self.d = attributes[:'d']
91
+ end
92
+
93
+ if attributes.key?(:'e')
94
+ self.e = attributes[:'e']
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 @a.nil?
103
+ invalid_properties.push('invalid value for "a", a cannot be nil.')
104
+ end
105
+
106
+ if @b.nil?
107
+ invalid_properties.push('invalid value for "b", b cannot be nil.')
108
+ end
109
+
110
+ if @c.nil?
111
+ invalid_properties.push('invalid value for "c", c cannot be nil.')
112
+ end
113
+
114
+ if @d.nil?
115
+ invalid_properties.push('invalid value for "d", d cannot be nil.')
116
+ end
117
+
118
+ if @e.nil?
119
+ invalid_properties.push('invalid value for "e", e cannot be nil.')
120
+ end
121
+
122
+ invalid_properties
123
+ end
124
+
125
+ # Check to see if the all the properties in the model are valid
126
+ # @return true if the model is valid
127
+ def valid?
128
+ return false if @a.nil?
129
+ return false if @b.nil?
130
+ return false if @c.nil?
131
+ return false if @d.nil?
132
+ return false if @e.nil?
133
+ true
134
+ end
135
+
136
+ # Checks equality by comparing each attribute.
137
+ # @param [Object] Object to be compared
138
+ def ==(o)
139
+ return true if self.equal?(o)
140
+ self.class == o.class &&
141
+ a == o.a &&
142
+ b == o.b &&
143
+ c == o.c &&
144
+ d == o.d &&
145
+ e == o.e
146
+ end
147
+
148
+ # @see the `==` method
149
+ # @param [Object] Object to be compared
150
+ def eql?(o)
151
+ self == o
152
+ end
153
+
154
+ # Calculates hash code according to all attributes.
155
+ # @return [Integer] Hash code
156
+ def hash
157
+ [a, b, c, d, e].hash
158
+ end
159
+
160
+ # Builds the object from hash
161
+ # @param [Hash] attributes Model attributes in the form of hash
162
+ # @return [Object] Returns the model itself
163
+ def self.build_from_hash(attributes)
164
+ new.build_from_hash(attributes)
165
+ end
166
+
167
+ # Builds the object from hash
168
+ # @param [Hash] attributes Model attributes in the form of hash
169
+ # @return [Object] Returns the model itself
170
+ def build_from_hash(attributes)
171
+ return nil unless attributes.is_a?(Hash)
172
+ self.class.openapi_types.each_pair do |key, type|
173
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
174
+ self.send("#{key}=", nil)
175
+ elsif type =~ /\AArray<(.*)>/i
176
+ # check to ensure the input is an array given that the attribute
177
+ # is documented as an array but the input is not
178
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
179
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
180
+ end
181
+ elsif !attributes[self.class.attribute_map[key]].nil?
182
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
183
+ end
184
+ end
185
+
186
+ self
187
+ end
188
+
189
+ # Deserializes the data based on type
190
+ # @param string type Data type
191
+ # @param string value Value to be deserialized
192
+ # @return [Object] Deserialized data
193
+ def _deserialize(type, value)
194
+ case type.to_sym
195
+ when :Time
196
+ Time.parse(value)
197
+ when :Date
198
+ Date.parse(value)
199
+ when :String
200
+ value.to_s
201
+ when :Integer
202
+ value.to_i
203
+ when :Float
204
+ value.to_f
205
+ when :Boolean
206
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
207
+ true
208
+ else
209
+ false
210
+ end
211
+ when :Object
212
+ # generic object (usually a Hash), return directly
213
+ value
214
+ when /\AArray<(?<inner_type>.+)>\z/
215
+ inner_type = Regexp.last_match[:inner_type]
216
+ value.map { |v| _deserialize(inner_type, v) }
217
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
218
+ k_type = Regexp.last_match[:k_type]
219
+ v_type = Regexp.last_match[:v_type]
220
+ {}.tap do |hash|
221
+ value.each do |k, v|
222
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
223
+ end
224
+ end
225
+ else # model
226
+ # models (e.g. Pet) or oneOf
227
+ klass = Svix.const_get(type)
228
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
229
+ end
230
+ end
231
+
232
+ # Returns the string representation of the object
233
+ # @return [String] String presentation of the object
234
+ def to_s
235
+ to_hash.to_s
236
+ end
237
+
238
+ # to_body is an alias to to_hash (backward compatibility)
239
+ # @return [Hash] Returns the object in the form of hash
240
+ def to_body
241
+ to_hash
242
+ end
243
+
244
+ # Returns the object in the form of hash
245
+ # @return [Hash] Returns the object in the form of hash
246
+ def to_hash
247
+ hash = {}
248
+ self.class.attribute_map.each_pair do |attr, param|
249
+ value = self.send(attr)
250
+ if value.nil?
251
+ is_nullable = self.class.openapi_nullable.include?(attr)
252
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
253
+ end
254
+
255
+ hash[param] = _to_hash(value)
256
+ end
257
+ hash
258
+ end
259
+
260
+ # Outputs non-array value in the form of hash
261
+ # For object, use to_hash. Otherwise, just return the value
262
+ # @param [Object] value Any valid value
263
+ # @return [Hash] Returns the value in the form of hash
264
+ def _to_hash(value)
265
+ if value.is_a?(Array)
266
+ value.compact.map { |v| _to_hash(v) }
267
+ elsif value.is_a?(Hash)
268
+ {}.tap do |hash|
269
+ value.each { |k, v| hash[k] = _to_hash(v) }
270
+ end
271
+ elsif value.respond_to? :to_hash
272
+ value.to_hash
273
+ else
274
+ value
275
+ end
276
+ end
277
+
278
+ end
279
+
280
+ end
data/lib/svix/svix.rb ADDED
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Svix
4
+ class SvixOptions
5
+ attr_accessor :debug
6
+ attr_accessor :debug_url
7
+
8
+ def initialize(debug = false, debug_url = "https://api.svix.com")
9
+ @debug=debug
10
+ @debug_url=debug_url
11
+ end
12
+ end
13
+
14
+ class Client
15
+ attr_accessor :application
16
+ attr_accessor :authentication
17
+ attr_accessor :endpoint
18
+ attr_accessor :event_type
19
+ attr_accessor :message
20
+ attr_accessor :message_attempt
21
+
22
+ def initialize(auth_token, options = SvixOptions.new)
23
+ uri = URI(options.debug_url)
24
+
25
+ configuration = Configuration.new
26
+ configuration.debugging = options.debug
27
+ configuration.scheme = uri.scheme
28
+ configuration.host = uri.port ? "#{uri.host}:#{uri.port}" : uri.host
29
+ configuration.access_token = auth_token
30
+ configuration.server_index = nil
31
+
32
+ api_client = ApiClient.new(configuration)
33
+ api_client.user_agent = "svix-libs/#{VERSION}/ruby"
34
+
35
+ @application = ApplicationAPI.new(api_client)
36
+ @authentication = AuthenticationAPI.new(api_client)
37
+ @endpoint = EndpointAPI.new(api_client)
38
+ @event_type = EventTypeAPI.new(api_client)
39
+ @message = MessageAPI.new(api_client)
40
+ @message_attempt = MessageAttemptAPI.new(api_client)
41
+ end
42
+ end
43
+ end
@@ -34,4 +34,4 @@ module Svix
34
34
  a.length == b.length && fixed_length_secure_compare(a, b)
35
35
  end
36
36
  module_function :secure_compare
37
- end
37
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Svix
4
- VERSION = "0.28.0"
4
+ VERSION = "0.32.0"
5
5
  end
@@ -34,7 +34,7 @@ module Svix
34
34
  if version != "v1"
35
35
  next
36
36
  end
37
- if Svix.secure_compare(signature, expectedSignature)
37
+ if ::Svix::secure_compare(signature, expectedSignature)
38
38
  return JSON.parse(payload, symbolize_names: true)
39
39
  end
40
40
  end
data/lib/svix.rb ADDED
@@ -0,0 +1,76 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "json"
4
+ require "openssl"
5
+ require "Base64"
6
+
7
+ # API
8
+ require "svix/api/application_api"
9
+ require "svix/api/authentication_api"
10
+ require "svix/api/endpoint_api"
11
+ require "svix/api/event_type_api"
12
+ require "svix/api/health_api"
13
+ require "svix/api/message_api"
14
+ require "svix/api/message_attempt_api"
15
+
16
+ # Models
17
+ require "svix/models/application_in"
18
+ require "svix/models/application_out"
19
+ require "svix/models/dashboard_access_out"
20
+ require "svix/models/endpoint_created_event_data"
21
+ require "svix/models/endpoint_created_event"
22
+ require "svix/models/endpoint_deleted_event_data"
23
+ require "svix/models/endpoint_deleted_event"
24
+ require "svix/models/endpoint_disabled_event_data"
25
+ require "svix/models/endpoint_disabled_event"
26
+ require "svix/models/endpoint_in"
27
+ require "svix/models/endpoint_message_out"
28
+ require "svix/models/endpoint_out"
29
+ require "svix/models/endpoint_secret_out"
30
+ require "svix/models/endpoint_stats"
31
+ require "svix/models/endpoint_update"
32
+ require "svix/models/endpoint_updated_event_data"
33
+ require "svix/models/endpointd_updated_event"
34
+ require "svix/models/event_example_in"
35
+ require "svix/models/event_type_in"
36
+ require "svix/models/event_type_out"
37
+ require "svix/models/event_type_update"
38
+ require "svix/models/http_error_out"
39
+ require "svix/models/http_validation_error"
40
+ require "svix/models/list_response_application_out"
41
+ require "svix/models/list_response_endpoint_message_out"
42
+ require "svix/models/list_response_endpoint_out"
43
+ require "svix/models/list_response_event_type_out"
44
+ require "svix/models/list_response_message_attempt_endpoint_out"
45
+ require "svix/models/list_response_message_attempt_out"
46
+ require "svix/models/list_response_message_endpoint_out"
47
+ require "svix/models/list_response_message_out"
48
+ require "svix/models/message_attempt_endpoint_out"
49
+ require "svix/models/message_attempt_exhausted_event_data"
50
+ require "svix/models/message_attempt_exhausted_event"
51
+ require "svix/models/message_attempt_failed_event"
52
+ require "svix/models/message_attempt_out"
53
+ require "svix/models/message_attempt_trigger_type"
54
+ require "svix/models/message_endpoint_out"
55
+ require "svix/models/message_in"
56
+ require "svix/models/message_out"
57
+ require "svix/models/message_status"
58
+ require "svix/models/validation_error"
59
+ require "svix/models/webhook_types"
60
+
61
+ # Core
62
+ require "svix/api_client"
63
+ require "svix/api_error"
64
+ require "svix/application_api"
65
+ require "svix/authentication_api"
66
+ require "svix/configuration"
67
+ require "svix/endpoint_api"
68
+ require "svix/errors"
69
+ require "svix/event_type_api"
70
+ require "svix/message_api"
71
+ require "svix/message_attempt_api"
72
+ require "svix/svix"
73
+ require "svix/util"
74
+ require "svix/version"
75
+ require "svix/webhook"
76
+ require "svix/internal"