svix 0.16.0 → 0.34.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (79) 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 +877 -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 +38 -0
  17. data/{src → lib}/svix/errors.rb +4 -1
  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 +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 +395 -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 +290 -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/validation_error.rb +253 -0
  68. data/lib/svix/models/webhook_types.rb +280 -0
  69. data/lib/svix/svix.rb +43 -0
  70. data/{src → lib}/svix/util.rb +1 -1
  71. data/lib/svix/version.rb +5 -0
  72. data/lib/svix/webhook.rb +75 -0
  73. data/lib/svix.rb +77 -0
  74. data/svix.gemspec +19 -9
  75. metadata +97 -13
  76. data/.gitignore +0 -9
  77. data/src/svix/version.rb +0 -3
  78. data/src/svix/webhook.rb +0 -33
  79. data/src/svix.rb +0 -8
@@ -0,0 +1,277 @@
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
+ module Svix
14
+ class Configuration
15
+ # Defines url scheme
16
+ attr_accessor :scheme
17
+
18
+ # Defines url host
19
+ attr_accessor :host
20
+
21
+ # Defines url base path
22
+ attr_accessor :base_path
23
+
24
+ # Define server configuration index
25
+ attr_accessor :server_index
26
+
27
+ # Define server operation configuration index
28
+ attr_accessor :server_operation_index
29
+
30
+ # Default server variables
31
+ attr_accessor :server_variables
32
+
33
+ # Default server operation variables
34
+ attr_accessor :server_operation_variables
35
+
36
+ # Defines API keys used with API Key authentications.
37
+ #
38
+ # @return [Hash] key: parameter name, value: parameter value (API key)
39
+ #
40
+ # @example parameter name is "api_key", API key is "xxx" (e.g. "api_key=xxx" in query string)
41
+ # config.api_key['api_key'] = 'xxx'
42
+ attr_accessor :api_key
43
+
44
+ # Defines API key prefixes used with API Key authentications.
45
+ #
46
+ # @return [Hash] key: parameter name, value: API key prefix
47
+ #
48
+ # @example parameter name is "Authorization", API key prefix is "Token" (e.g. "Authorization: Token xxx" in headers)
49
+ # config.api_key_prefix['api_key'] = 'Token'
50
+ attr_accessor :api_key_prefix
51
+
52
+ # Defines the username used with HTTP basic authentication.
53
+ #
54
+ # @return [String]
55
+ attr_accessor :username
56
+
57
+ # Defines the password used with HTTP basic authentication.
58
+ #
59
+ # @return [String]
60
+ attr_accessor :password
61
+
62
+ # Defines the access token (Bearer) used with OAuth2.
63
+ attr_accessor :access_token
64
+
65
+ # Set this to enable/disable debugging. When enabled (set to true), HTTP request/response
66
+ # details will be logged with `logger.debug` (see the `logger` attribute).
67
+ # Default to false.
68
+ #
69
+ # @return [true, false]
70
+ attr_accessor :debugging
71
+
72
+ # Defines the logger used for debugging.
73
+ # Default to `Rails.logger` (when in Rails) or logging to STDOUT.
74
+ #
75
+ # @return [#debug]
76
+ attr_accessor :logger
77
+
78
+ # Defines the temporary folder to store downloaded files
79
+ # (for API endpoints that have file response).
80
+ # Default to use `Tempfile`.
81
+ #
82
+ # @return [String]
83
+ attr_accessor :temp_folder_path
84
+
85
+ # The time limit for HTTP request in seconds.
86
+ # Default to 0 (never times out).
87
+ attr_accessor :timeout
88
+
89
+ # Set this to false to skip client side validation in the operation.
90
+ # Default to true.
91
+ # @return [true, false]
92
+ attr_accessor :client_side_validation
93
+
94
+ ### TLS/SSL setting
95
+ # Set this to false to skip verifying SSL certificate when calling API from https server.
96
+ # Default to true.
97
+ #
98
+ # @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
99
+ #
100
+ # @return [true, false]
101
+ attr_accessor :verify_ssl
102
+
103
+ ### TLS/SSL setting
104
+ # Set this to false to skip verifying SSL host name
105
+ # Default to true.
106
+ #
107
+ # @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
108
+ #
109
+ # @return [true, false]
110
+ attr_accessor :verify_ssl_host
111
+
112
+ ### TLS/SSL setting
113
+ # Set this to customize the certificate file to verify the peer.
114
+ #
115
+ # @return [String] the path to the certificate file
116
+ #
117
+ # @see The `cainfo` option of Typhoeus, `--cert` option of libcurl. Related source code:
118
+ # https://github.com/typhoeus/typhoeus/blob/master/lib/typhoeus/easy_factory.rb#L145
119
+ attr_accessor :ssl_ca_cert
120
+
121
+ ### TLS/SSL setting
122
+ # Client certificate file (for client certificate)
123
+ attr_accessor :cert_file
124
+
125
+ ### TLS/SSL setting
126
+ # Client private key file (for client certificate)
127
+ attr_accessor :key_file
128
+
129
+ # Set this to customize parameters encoding of array parameter with multi collectionFormat.
130
+ # Default to nil.
131
+ #
132
+ # @see The params_encoding option of Ethon. Related source code:
133
+ # https://github.com/typhoeus/ethon/blob/master/lib/ethon/easy/queryable.rb#L96
134
+ attr_accessor :params_encoding
135
+
136
+ attr_accessor :inject_format
137
+
138
+ attr_accessor :force_ending_format
139
+
140
+ def initialize
141
+ @scheme = 'http'
142
+ @host = 'localhost'
143
+ @base_path = ''
144
+ @server_index = 0
145
+ @server_operation_index = {}
146
+ @server_variables = {}
147
+ @server_operation_variables = {}
148
+ @api_key = {}
149
+ @api_key_prefix = {}
150
+ @timeout = 0
151
+ @client_side_validation = true
152
+ @verify_ssl = true
153
+ @verify_ssl_host = true
154
+ @params_encoding = nil
155
+ @cert_file = nil
156
+ @key_file = nil
157
+ @debugging = false
158
+ @inject_format = false
159
+ @force_ending_format = false
160
+ @logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
161
+
162
+ yield(self) if block_given?
163
+ end
164
+
165
+ # The default Configuration object.
166
+ def self.default
167
+ @@default ||= Configuration.new
168
+ end
169
+
170
+ def configure
171
+ yield(self) if block_given?
172
+ end
173
+
174
+ def scheme=(scheme)
175
+ # remove :// from scheme
176
+ @scheme = scheme.sub(/:\/\//, '')
177
+ end
178
+
179
+ def host=(host)
180
+ # remove http(s):// and anything after a slash
181
+ @host = host.sub(/https?:\/\//, '').split('/').first
182
+ end
183
+
184
+ def base_path=(base_path)
185
+ # Add leading and trailing slashes to base_path
186
+ @base_path = "/#{base_path}".gsub(/\/+/, '/')
187
+ @base_path = '' if @base_path == '/'
188
+ end
189
+
190
+ # Returns base URL for specified operation based on server settings
191
+ def base_url(operation = nil)
192
+ index = server_operation_index.fetch(operation, server_index)
193
+ return "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '') if index == nil
194
+
195
+ server_url(index, server_operation_variables.fetch(operation, server_variables), operation_server_settings[operation])
196
+ end
197
+
198
+ # Gets API key (with prefix if set).
199
+ # @param [String] param_name the parameter name of API key auth
200
+ def api_key_with_prefix(param_name, param_alias = nil)
201
+ key = @api_key[param_name]
202
+ key = @api_key.fetch(param_alias, key) unless param_alias.nil?
203
+ if @api_key_prefix[param_name]
204
+ "#{@api_key_prefix[param_name]} #{key}"
205
+ else
206
+ key
207
+ end
208
+ end
209
+
210
+ # Gets Basic Auth token string
211
+ def basic_auth_token
212
+ 'Basic ' + ["#{username}:#{password}"].pack('m').delete("\r\n")
213
+ end
214
+
215
+ # Returns Auth Settings hash for api client.
216
+ def auth_settings
217
+ {
218
+ 'HTTPBearer' =>
219
+ {
220
+ type: 'bearer',
221
+ in: 'header',
222
+ key: 'Authorization',
223
+ value: "Bearer #{access_token}"
224
+ },
225
+ }
226
+ end
227
+
228
+ # Returns an array of Server setting
229
+ def server_settings
230
+ [
231
+ {
232
+ url: "",
233
+ description: "No description provided",
234
+ }
235
+ ]
236
+ end
237
+
238
+ def operation_server_settings
239
+ {
240
+ }
241
+ end
242
+
243
+ # Returns URL based on server settings
244
+ #
245
+ # @param index array index of the server settings
246
+ # @param variables hash of variable and the corresponding value
247
+ def server_url(index, variables = {}, servers = nil)
248
+ servers = server_settings if servers == nil
249
+
250
+ # check array index out of bound
251
+ if (index < 0 || index >= servers.size)
252
+ fail ArgumentError, "Invalid index #{index} when selecting the server. Must be less than #{servers.size}"
253
+ end
254
+
255
+ server = servers[index]
256
+ url = server[:url]
257
+
258
+ return url unless server.key? :variables
259
+
260
+ # go through variable and assign a value
261
+ server[:variables].each do |name, variable|
262
+ if variables.key?(name)
263
+ if (!server[:variables][name].key?(:enum_values) || server[:variables][name][:enum_values].include?(variables[name]))
264
+ url.gsub! "{" + name.to_s + "}", variables[name]
265
+ else
266
+ fail ArgumentError, "The variable `#{name}` in the server URL has invalid value #{variables[name]}. Must be #{server[:variables][name][:enum_values]}."
267
+ end
268
+ else
269
+ # use default value
270
+ url.gsub! "{" + name.to_s + "}", server[:variables][name][:default_value]
271
+ end
272
+ end
273
+
274
+ url
275
+ end
276
+ end
277
+ end
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Svix
4
+ class EndpointAPI
5
+ def initialize(api_client)
6
+ @api = EndpointApi.new(api_client)
7
+ end
8
+
9
+ def list(app_id, options = {})
10
+ return @api.list_endpoints_api_v1_app_app_id_endpoint_get(app_id, options)
11
+ end
12
+
13
+ def create(app_id, endpoint_in)
14
+ return @api.create_endpoint_api_v1_app_app_id_endpoint_post(app_id, endpoint_in)
15
+ end
16
+
17
+ def get(app_id, endpoint_id)
18
+ return @api.get_endpoint_api_v1_app_app_id_endpoint_endpoint_id_get(endpoint_id, app_id)
19
+ end
20
+
21
+ def update(app_id, endpoint_id, endpoint_in)
22
+ return @api.update_endpoint_api_v1_app_app_id_endpoint_endpoint_id_put(endpoint_id, app_id, endpoint_update)
23
+ end
24
+
25
+ def delete(app_id, endpoint_id)
26
+ return @api.delete_endpoint_api_v1_app_app_id_endpoint_endpoint_id_delete(endpoint_id, app_id)
27
+ end
28
+
29
+ def get_secret(app_id, endpoint_id)
30
+ return @api.get_endpoint_secret_api_v1_app_app_id_endpoint_endpoint_id_secret_get(endpoint_id, app_id)
31
+ end
32
+
33
+ def rotate_secret(app_id, endpoint_id, endpoint_secret_rotate_in)
34
+ return @api.rotate_endpoint_secret_api_v1_app_app_id_endpoint_endpoint_id_secret_rotate_post(endpoint_id, app_id, endpoint_secret_rotate_in)
35
+ end
36
+
37
+ end
38
+ end
@@ -11,4 +11,7 @@ module Svix
11
11
 
12
12
  class WebhookVerificationError < SvixError
13
13
  end
14
- end
14
+
15
+ class WebhookSigningError < SvixError
16
+ end
17
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Svix
4
+ class EventTypeAPI
5
+ def initialize(api_client)
6
+ @api = EventTypeApi.new(api_client)
7
+ end
8
+
9
+ def list(options = {})
10
+ return @api.list_event_types_api_v1_event_type_get(options)
11
+ end
12
+
13
+ def create(event_type_in)
14
+ return @api.create_event_type_api_v1_event_type_post(event_type_in)
15
+ end
16
+
17
+ def update(event_type_name, event_type_update)
18
+ return @api.update_event_type_api_v1_event_type_event_type_name_put(event_type_name, event_type_update)
19
+ end
20
+
21
+ def delete(event_type_name)
22
+ return @api.delete_event_type_api_v1_event_type_event_type_name_delete(event_type_name)
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Svix
4
+ private_constant :ApiClient
5
+ private_constant :Configuration
6
+ private_constant :ApplicationApi
7
+ private_constant :AuthenticationApi
8
+ private_constant :EndpointApi
9
+ private_constant :HealthApi
10
+ private_constant :MessageApi
11
+ private_constant :MessageAttemptApi
12
+ private_constant :WebhookTypes
13
+ private_constant :HttpErrorOut
14
+ private_constant :HTTPValidationError
15
+ private_constant :ValidationError
16
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Svix
4
+ class MessageAPI
5
+ def initialize(api_client)
6
+ @api = MessageApi.new(api_client)
7
+ end
8
+
9
+ def list(app_id, options = {})
10
+ return @api.list_messages_api_v1_app_app_id_msg_get(app_id, options)
11
+ end
12
+
13
+ def create(app_id, message_in)
14
+ return @api.create_message_api_v1_app_app_id_msg_post(app_id, message_in)
15
+ end
16
+
17
+ def get(app_id, msg_id)
18
+ return @api.get_message_api_v1_app_app_id_msg_msg_id_get(msg_id, app_id)
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Svix
4
+ class MessageAttemptAPI
5
+ def initialize(api_client)
6
+ @api = MessageAttemptApi.new(api_client)
7
+ end
8
+
9
+ def list(app_id, msg_id, options = {})
10
+ return @api.list_attempts_api_v1_app_app_id_msg_msg_id_attempt_get(app_id, msg_id, options)
11
+ end
12
+
13
+ def get(app_id, msg_id, attempt_id)
14
+ return @api.get_attempt_api_v1_app_app_id_msg_msg_id_attempt_attempt_id_get(attempt_id, msg_id, app_id)
15
+ end
16
+
17
+ def resend(app_id, msg_id, endpoint_id)
18
+ return @api.resend_webhook_api_v1_app_app_id_msg_msg_id_endpoint_endpoint_id_resend_post(endpoint_id, msg_id, app_id)
19
+ end
20
+
21
+ def list_attempted_messages(app_id, endpoint_id, options = {})
22
+ return @api.list_attempted_messages_api_v1_app_app_id_endpoint_endpoint_id_msg_get(endpoint_id, app_id, options)
23
+ end
24
+
25
+ def list_attempted_destinations(app_id, msg_id, options = {})
26
+ return @api.list_attempted_destinations_api_v1_app_app_id_msg_msg_id_endpoint_get(msg_id, app_id, options)
27
+ end
28
+
29
+ def list_attempts_for_endpoint(app_id, endpoint_id, msg_id, options = {})
30
+ return @api.list_attempts_for_endpoint_api_v1_app_app_id_msg_msg_id_endpoint_endpoint_id_attempt_get(msg_id, app_id, endpoint_id, options)
31
+ end
32
+ end
33
+ end