svix 0.21.0 → 0.36.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 +9 -3
- data/README.md +16 -3
- data/lib/svix/api/application_api.rb +386 -0
- data/lib/svix/api/authentication_api.rb +155 -0
- data/lib/svix/api/endpoint_api.rb +980 -0
- data/lib/svix/api/event_type_api.rb +454 -0
- data/lib/svix/api/health_api.rb +77 -0
- data/lib/svix/api/message_api.rb +289 -0
- data/lib/svix/api/message_attempt_api.rb +678 -0
- data/lib/svix/api_client.rb +399 -0
- data/lib/svix/api_error.rb +57 -0
- data/lib/svix/application_api.rb +29 -0
- data/lib/svix/authentication_api.rb +17 -0
- data/lib/svix/configuration.rb +277 -0
- data/lib/svix/endpoint_api.rb +43 -0
- data/{src → lib}/svix/errors.rb +0 -0
- data/lib/svix/event_type_api.rb +25 -0
- data/lib/svix/internal.rb +16 -0
- data/lib/svix/message_api.rb +21 -0
- data/lib/svix/message_attempt_api.rb +33 -0
- data/lib/svix/models/application_in.rb +277 -0
- data/lib/svix/models/application_out.rb +319 -0
- data/lib/svix/models/dashboard_access_out.rb +265 -0
- data/lib/svix/models/endpoint_created_event.rb +269 -0
- data/lib/svix/models/endpoint_created_event_data.rb +282 -0
- data/lib/svix/models/endpoint_deleted_event.rb +269 -0
- data/lib/svix/models/endpoint_deleted_event_data.rb +282 -0
- data/lib/svix/models/endpoint_disabled_event.rb +269 -0
- data/lib/svix/models/endpoint_disabled_event_data.rb +296 -0
- data/lib/svix/models/endpoint_in.rb +394 -0
- data/lib/svix/models/endpoint_message_out.rb +363 -0
- data/lib/svix/models/endpoint_out.rb +409 -0
- data/lib/svix/models/endpoint_secret_out.rb +245 -0
- data/lib/svix/models/endpoint_secret_rotate_in.rb +236 -0
- data/lib/svix/models/endpoint_stats.rb +265 -0
- data/lib/svix/models/endpoint_update.rb +367 -0
- data/lib/svix/models/endpoint_updated_event.rb +269 -0
- data/lib/svix/models/endpoint_updated_event_data.rb +282 -0
- data/lib/svix/models/endpointd_updated_event.rb +269 -0
- data/lib/svix/models/event_example_in.rb +253 -0
- data/lib/svix/models/event_type_example_out.rb +223 -0
- data/lib/svix/models/event_type_in.rb +290 -0
- data/lib/svix/models/event_type_out.rb +318 -0
- data/lib/svix/models/event_type_schema_in.rb +224 -0
- data/lib/svix/models/event_type_update.rb +246 -0
- data/lib/svix/models/http_error_out.rb +237 -0
- data/lib/svix/models/http_validation_error.rb +220 -0
- data/lib/svix/models/list_response_application_out.rb +248 -0
- data/lib/svix/models/list_response_endpoint_message_out.rb +248 -0
- data/lib/svix/models/list_response_endpoint_out.rb +248 -0
- data/lib/svix/models/list_response_event_type_out.rb +248 -0
- data/lib/svix/models/list_response_message_attempt_endpoint_out.rb +248 -0
- data/lib/svix/models/list_response_message_attempt_out.rb +248 -0
- data/lib/svix/models/list_response_message_endpoint_out.rb +248 -0
- data/lib/svix/models/list_response_message_out.rb +248 -0
- data/lib/svix/models/message_attempt_endpoint_out.rb +293 -0
- data/lib/svix/models/message_attempt_exhausted_event.rb +269 -0
- data/lib/svix/models/message_attempt_exhausted_event_data.rb +310 -0
- data/lib/svix/models/message_attempt_failed_event.rb +251 -0
- data/lib/svix/models/message_attempt_out.rb +307 -0
- data/lib/svix/models/message_attempt_trigger_type.rb +37 -0
- data/lib/svix/models/message_endpoint_out.rb +418 -0
- data/lib/svix/models/message_in.rb +312 -0
- data/lib/svix/models/message_out.rb +340 -0
- data/lib/svix/models/message_status.rb +39 -0
- data/lib/svix/models/recover_in.rb +223 -0
- data/lib/svix/models/validation_error.rb +253 -0
- data/lib/svix/models/webhook_types.rb +280 -0
- data/lib/svix/svix.rb +43 -0
- data/{src → lib}/svix/util.rb +1 -1
- data/{src → lib}/svix/version.rb +1 -1
- data/{src → lib}/svix/webhook.rb +7 -2
- data/lib/svix.rb +78 -0
- data/svix.gemspec +17 -7
- metadata +96 -11
- data/.gitignore +0 -9
- data/src/svix.rb +0 -8
@@ -0,0 +1,399 @@
|
|
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 'json'
|
15
|
+
require 'logger'
|
16
|
+
require 'tempfile'
|
17
|
+
require 'time'
|
18
|
+
require 'typhoeus'
|
19
|
+
|
20
|
+
module Svix
|
21
|
+
class ApiClient
|
22
|
+
# The Configuration object holding settings to be used in the API client.
|
23
|
+
attr_accessor :config
|
24
|
+
|
25
|
+
# Defines the headers to be used in HTTP requests of all API calls by default.
|
26
|
+
#
|
27
|
+
# @return [Hash]
|
28
|
+
attr_accessor :default_headers
|
29
|
+
|
30
|
+
# Initializes the ApiClient
|
31
|
+
# @option config [Configuration] Configuration for initializing the object, default to Configuration.default
|
32
|
+
def initialize(config = Configuration.default)
|
33
|
+
@config = config
|
34
|
+
@user_agent = "OpenAPI-Generator/#{VERSION}/ruby"
|
35
|
+
@default_headers = {
|
36
|
+
'Content-Type' => 'application/json',
|
37
|
+
'User-Agent' => @user_agent
|
38
|
+
}
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.default
|
42
|
+
@@default ||= ApiClient.new
|
43
|
+
end
|
44
|
+
|
45
|
+
# Call an API with given options.
|
46
|
+
#
|
47
|
+
# @return [Array<(Object, Integer, Hash)>] an array of 3 elements:
|
48
|
+
# the data deserialized from response body (could be nil), response status code and response headers.
|
49
|
+
def call_api(http_method, path, opts = {})
|
50
|
+
request = build_request(http_method, path, opts)
|
51
|
+
response = request.run
|
52
|
+
|
53
|
+
# retry 500s
|
54
|
+
sleep_time = 0.05
|
55
|
+
(0..1).each do |n|
|
56
|
+
break if response.success? && response.code < 500
|
57
|
+
sleep(sleep_time)
|
58
|
+
sleep_time = sleep_time * 2
|
59
|
+
response = request.run
|
60
|
+
end
|
61
|
+
|
62
|
+
if @config.debugging
|
63
|
+
@config.logger.debug "HTTP response body ~BEGIN~\n#{response.body}\n~END~\n"
|
64
|
+
end
|
65
|
+
|
66
|
+
unless response.success?
|
67
|
+
if response.timed_out?
|
68
|
+
fail ApiError.new('Connection timed out')
|
69
|
+
elsif response.code == 0
|
70
|
+
# Errors from libcurl will be made visible here
|
71
|
+
fail ApiError.new(:code => 0,
|
72
|
+
:message => response.return_message)
|
73
|
+
else
|
74
|
+
fail ApiError.new(:code => response.code,
|
75
|
+
:response_headers => response.headers,
|
76
|
+
:response_body => response.body),
|
77
|
+
response.status_message
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
if opts[:return_type]
|
82
|
+
data = deserialize(response, opts[:return_type])
|
83
|
+
else
|
84
|
+
data = nil
|
85
|
+
end
|
86
|
+
return data, response.code, response.headers
|
87
|
+
end
|
88
|
+
|
89
|
+
# Builds the HTTP request
|
90
|
+
#
|
91
|
+
# @param [String] http_method HTTP method/verb (e.g. POST)
|
92
|
+
# @param [String] path URL path (e.g. /account/new)
|
93
|
+
# @option opts [Hash] :header_params Header parameters
|
94
|
+
# @option opts [Hash] :query_params Query parameters
|
95
|
+
# @option opts [Hash] :form_params Query parameters
|
96
|
+
# @option opts [Object] :body HTTP body (JSON/XML)
|
97
|
+
# @return [Typhoeus::Request] A Typhoeus Request
|
98
|
+
def build_request(http_method, path, opts = {})
|
99
|
+
url = build_request_url(path, opts)
|
100
|
+
http_method = http_method.to_sym.downcase
|
101
|
+
|
102
|
+
header_params = @default_headers.merge(opts[:header_params] || {})
|
103
|
+
query_params = opts[:query_params] || {}
|
104
|
+
form_params = opts[:form_params] || {}
|
105
|
+
|
106
|
+
update_params_for_auth! header_params, query_params, opts[:auth_names]
|
107
|
+
|
108
|
+
# set ssl_verifyhosts option based on @config.verify_ssl_host (true/false)
|
109
|
+
_verify_ssl_host = @config.verify_ssl_host ? 2 : 0
|
110
|
+
|
111
|
+
req_opts = {
|
112
|
+
:method => http_method,
|
113
|
+
:headers => header_params,
|
114
|
+
:params => query_params,
|
115
|
+
:params_encoding => @config.params_encoding,
|
116
|
+
:timeout => @config.timeout,
|
117
|
+
:ssl_verifypeer => @config.verify_ssl,
|
118
|
+
:ssl_verifyhost => _verify_ssl_host,
|
119
|
+
:sslcert => @config.cert_file,
|
120
|
+
:sslkey => @config.key_file,
|
121
|
+
:verbose => @config.debugging
|
122
|
+
}
|
123
|
+
|
124
|
+
# set custom cert, if provided
|
125
|
+
req_opts[:cainfo] = @config.ssl_ca_cert if @config.ssl_ca_cert
|
126
|
+
|
127
|
+
if [:post, :patch, :put, :delete].include?(http_method)
|
128
|
+
req_body = build_request_body(header_params, form_params, opts[:body])
|
129
|
+
req_opts.update :body => req_body
|
130
|
+
if @config.debugging
|
131
|
+
@config.logger.debug "HTTP request body param ~BEGIN~\n#{req_body}\n~END~\n"
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
request = Typhoeus::Request.new(url, req_opts)
|
136
|
+
download_file(request) if opts[:return_type] == 'File'
|
137
|
+
request
|
138
|
+
end
|
139
|
+
|
140
|
+
# Builds the HTTP request body
|
141
|
+
#
|
142
|
+
# @param [Hash] header_params Header parameters
|
143
|
+
# @param [Hash] form_params Query parameters
|
144
|
+
# @param [Object] body HTTP body (JSON/XML)
|
145
|
+
# @return [String] HTTP body data in the form of string
|
146
|
+
def build_request_body(header_params, form_params, body)
|
147
|
+
# http form
|
148
|
+
if header_params['Content-Type'] == 'application/x-www-form-urlencoded' ||
|
149
|
+
header_params['Content-Type'] == 'multipart/form-data'
|
150
|
+
data = {}
|
151
|
+
form_params.each do |key, value|
|
152
|
+
case value
|
153
|
+
when ::File, ::Array, nil
|
154
|
+
# let typhoeus handle File, Array and nil parameters
|
155
|
+
data[key] = value
|
156
|
+
else
|
157
|
+
data[key] = value.to_s
|
158
|
+
end
|
159
|
+
end
|
160
|
+
elsif body
|
161
|
+
data = body.is_a?(String) ? body : body.to_json
|
162
|
+
else
|
163
|
+
data = nil
|
164
|
+
end
|
165
|
+
data
|
166
|
+
end
|
167
|
+
|
168
|
+
# Save response body into a file in (the defined) temporary folder, using the filename
|
169
|
+
# from the "Content-Disposition" header if provided, otherwise a random filename.
|
170
|
+
# The response body is written to the file in chunks in order to handle files which
|
171
|
+
# size is larger than maximum Ruby String or even larger than the maximum memory a Ruby
|
172
|
+
# process can use.
|
173
|
+
#
|
174
|
+
# @see Configuration#temp_folder_path
|
175
|
+
def download_file(request)
|
176
|
+
tempfile = nil
|
177
|
+
encoding = nil
|
178
|
+
request.on_headers do |response|
|
179
|
+
content_disposition = response.headers['Content-Disposition']
|
180
|
+
if content_disposition && content_disposition =~ /filename=/i
|
181
|
+
filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1]
|
182
|
+
prefix = sanitize_filename(filename)
|
183
|
+
else
|
184
|
+
prefix = 'download-'
|
185
|
+
end
|
186
|
+
prefix = prefix + '-' unless prefix.end_with?('-')
|
187
|
+
encoding = response.body.encoding
|
188
|
+
tempfile = Tempfile.open(prefix, @config.temp_folder_path, encoding: encoding)
|
189
|
+
@tempfile = tempfile
|
190
|
+
end
|
191
|
+
request.on_body do |chunk|
|
192
|
+
chunk.force_encoding(encoding)
|
193
|
+
tempfile.write(chunk)
|
194
|
+
end
|
195
|
+
request.on_complete do |response|
|
196
|
+
if tempfile
|
197
|
+
tempfile.close
|
198
|
+
@config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder "\
|
199
|
+
"with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\
|
200
|
+
"will be deleted automatically with GC. It's also recommended to delete the temp file "\
|
201
|
+
"explicitly with `tempfile.delete`"
|
202
|
+
end
|
203
|
+
end
|
204
|
+
end
|
205
|
+
|
206
|
+
# Check if the given MIME is a JSON MIME.
|
207
|
+
# JSON MIME examples:
|
208
|
+
# application/json
|
209
|
+
# application/json; charset=UTF8
|
210
|
+
# APPLICATION/JSON
|
211
|
+
# */*
|
212
|
+
# @param [String] mime MIME
|
213
|
+
# @return [Boolean] True if the MIME is application/json
|
214
|
+
def json_mime?(mime)
|
215
|
+
(mime == '*/*') || !(mime =~ /Application\/.*json(?!p)(;.*)?/i).nil?
|
216
|
+
end
|
217
|
+
|
218
|
+
# Deserialize the response to the given return type.
|
219
|
+
#
|
220
|
+
# @param [Response] response HTTP response
|
221
|
+
# @param [String] return_type some examples: "User", "Array<User>", "Hash<String, Integer>"
|
222
|
+
def deserialize(response, return_type)
|
223
|
+
body = response.body
|
224
|
+
|
225
|
+
# handle file downloading - return the File instance processed in request callbacks
|
226
|
+
# note that response body is empty when the file is written in chunks in request on_body callback
|
227
|
+
return @tempfile if return_type == 'File'
|
228
|
+
|
229
|
+
return nil if body.nil? || body.empty?
|
230
|
+
|
231
|
+
# return response body directly for String return type
|
232
|
+
return body if return_type == 'String'
|
233
|
+
|
234
|
+
# ensuring a default content type
|
235
|
+
content_type = response.headers['Content-Type'] || 'application/json'
|
236
|
+
|
237
|
+
fail "Content-Type is not supported: #{content_type}" unless json_mime?(content_type)
|
238
|
+
|
239
|
+
begin
|
240
|
+
data = JSON.parse("[#{body}]", :symbolize_names => true)[0]
|
241
|
+
rescue JSON::ParserError => e
|
242
|
+
if %w(String Date Time).include?(return_type)
|
243
|
+
data = body
|
244
|
+
else
|
245
|
+
raise e
|
246
|
+
end
|
247
|
+
end
|
248
|
+
|
249
|
+
convert_to_type data, return_type
|
250
|
+
end
|
251
|
+
|
252
|
+
# Convert data to the given return type.
|
253
|
+
# @param [Object] data Data to be converted
|
254
|
+
# @param [String] return_type Return type
|
255
|
+
# @return [Mixed] Data in a particular type
|
256
|
+
def convert_to_type(data, return_type)
|
257
|
+
return nil if data.nil?
|
258
|
+
case return_type
|
259
|
+
when 'String'
|
260
|
+
data.to_s
|
261
|
+
when 'Integer'
|
262
|
+
data.to_i
|
263
|
+
when 'Float'
|
264
|
+
data.to_f
|
265
|
+
when 'Boolean'
|
266
|
+
data == true
|
267
|
+
when 'Time'
|
268
|
+
# parse date time (expecting ISO 8601 format)
|
269
|
+
Time.parse data
|
270
|
+
when 'Date'
|
271
|
+
# parse date time (expecting ISO 8601 format)
|
272
|
+
Date.parse data
|
273
|
+
when 'Object'
|
274
|
+
# generic object (usually a Hash), return directly
|
275
|
+
data
|
276
|
+
when /\AArray<(.+)>\z/
|
277
|
+
# e.g. Array<Pet>
|
278
|
+
sub_type = $1
|
279
|
+
data.map { |item| convert_to_type(item, sub_type) }
|
280
|
+
when /\AHash\<String, (.+)\>\z/
|
281
|
+
# e.g. Hash<String, Integer>
|
282
|
+
sub_type = $1
|
283
|
+
{}.tap do |hash|
|
284
|
+
data.each { |k, v| hash[k] = convert_to_type(v, sub_type) }
|
285
|
+
end
|
286
|
+
else
|
287
|
+
# models (e.g. Pet) or oneOf
|
288
|
+
klass = Svix.const_get(return_type)
|
289
|
+
klass.respond_to?(:openapi_one_of) ? klass.build(data) : klass.build_from_hash(data)
|
290
|
+
end
|
291
|
+
end
|
292
|
+
|
293
|
+
# Sanitize filename by removing path.
|
294
|
+
# e.g. ../../sun.gif becomes sun.gif
|
295
|
+
#
|
296
|
+
# @param [String] filename the filename to be sanitized
|
297
|
+
# @return [String] the sanitized filename
|
298
|
+
def sanitize_filename(filename)
|
299
|
+
filename.gsub(/.*[\/\\]/, '')
|
300
|
+
end
|
301
|
+
|
302
|
+
def build_request_url(path, opts = {})
|
303
|
+
# Add leading and trailing slashes to path
|
304
|
+
path = "/#{path}".gsub(/\/+/, '/')
|
305
|
+
@config.base_url(opts[:operation]) + path
|
306
|
+
end
|
307
|
+
|
308
|
+
# Update hearder and query params based on authentication settings.
|
309
|
+
#
|
310
|
+
# @param [Hash] header_params Header parameters
|
311
|
+
# @param [Hash] query_params Query parameters
|
312
|
+
# @param [String] auth_names Authentication scheme name
|
313
|
+
def update_params_for_auth!(header_params, query_params, auth_names)
|
314
|
+
Array(auth_names).each do |auth_name|
|
315
|
+
auth_setting = @config.auth_settings[auth_name]
|
316
|
+
next unless auth_setting
|
317
|
+
case auth_setting[:in]
|
318
|
+
when 'header' then header_params[auth_setting[:key]] = auth_setting[:value]
|
319
|
+
when 'query' then query_params[auth_setting[:key]] = auth_setting[:value]
|
320
|
+
else fail ArgumentError, 'Authentication token must be in `query` or `header`'
|
321
|
+
end
|
322
|
+
end
|
323
|
+
end
|
324
|
+
|
325
|
+
# Sets user agent in HTTP header
|
326
|
+
#
|
327
|
+
# @param [String] user_agent User agent (e.g. openapi-generator/ruby/1.0.0)
|
328
|
+
def user_agent=(user_agent)
|
329
|
+
@user_agent = user_agent
|
330
|
+
@default_headers['User-Agent'] = @user_agent
|
331
|
+
end
|
332
|
+
|
333
|
+
# Return Accept header based on an array of accepts provided.
|
334
|
+
# @param [Array] accepts array for Accept
|
335
|
+
# @return [String] the Accept header (e.g. application/json)
|
336
|
+
def select_header_accept(accepts)
|
337
|
+
return nil if accepts.nil? || accepts.empty?
|
338
|
+
# use JSON when present, otherwise use all of the provided
|
339
|
+
json_accept = accepts.find { |s| json_mime?(s) }
|
340
|
+
json_accept || accepts.join(',')
|
341
|
+
end
|
342
|
+
|
343
|
+
# Return Content-Type header based on an array of content types provided.
|
344
|
+
# @param [Array] content_types array for Content-Type
|
345
|
+
# @return [String] the Content-Type header (e.g. application/json)
|
346
|
+
def select_header_content_type(content_types)
|
347
|
+
# use application/json by default
|
348
|
+
return 'application/json' if content_types.nil? || content_types.empty?
|
349
|
+
# use JSON when present, otherwise use the first one
|
350
|
+
json_content_type = content_types.find { |s| json_mime?(s) }
|
351
|
+
json_content_type || content_types.first
|
352
|
+
end
|
353
|
+
|
354
|
+
# Convert object (array, hash, object, etc) to JSON string.
|
355
|
+
# @param [Object] model object to be converted into JSON string
|
356
|
+
# @return [String] JSON string representation of the object
|
357
|
+
def object_to_http_body(model)
|
358
|
+
return model if model.nil? || model.is_a?(String)
|
359
|
+
local_body = nil
|
360
|
+
if model.is_a?(Array)
|
361
|
+
local_body = model.map { |m| object_to_hash(m) }
|
362
|
+
else
|
363
|
+
local_body = object_to_hash(model)
|
364
|
+
end
|
365
|
+
local_body.to_json
|
366
|
+
end
|
367
|
+
|
368
|
+
# Convert object(non-array) to hash.
|
369
|
+
# @param [Object] obj object to be converted into JSON string
|
370
|
+
# @return [String] JSON string representation of the object
|
371
|
+
def object_to_hash(obj)
|
372
|
+
if obj.respond_to?(:to_hash)
|
373
|
+
obj.to_hash
|
374
|
+
else
|
375
|
+
obj
|
376
|
+
end
|
377
|
+
end
|
378
|
+
|
379
|
+
# Build parameter value according to the given collection format.
|
380
|
+
# @param [String] collection_format one of :csv, :ssv, :tsv, :pipes and :multi
|
381
|
+
def build_collection_param(param, collection_format)
|
382
|
+
case collection_format
|
383
|
+
when :csv
|
384
|
+
param.join(',')
|
385
|
+
when :ssv
|
386
|
+
param.join(' ')
|
387
|
+
when :tsv
|
388
|
+
param.join("\t")
|
389
|
+
when :pipes
|
390
|
+
param.join('|')
|
391
|
+
when :multi
|
392
|
+
# return the array directly as typhoeus will handle it as expected
|
393
|
+
param
|
394
|
+
else
|
395
|
+
fail "unknown collection format: #{collection_format.inspect}"
|
396
|
+
end
|
397
|
+
end
|
398
|
+
end
|
399
|
+
end
|
@@ -0,0 +1,57 @@
|
|
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 ApiError < StandardError
|
15
|
+
attr_reader :code, :response_headers, :response_body
|
16
|
+
|
17
|
+
# Usage examples:
|
18
|
+
# ApiError.new
|
19
|
+
# ApiError.new("message")
|
20
|
+
# ApiError.new(:code => 500, :response_headers => {}, :response_body => "")
|
21
|
+
# ApiError.new(:code => 404, :message => "Not Found")
|
22
|
+
def initialize(arg = nil)
|
23
|
+
if arg.is_a? Hash
|
24
|
+
if arg.key?(:message) || arg.key?('message')
|
25
|
+
super(arg[:message] || arg['message'])
|
26
|
+
else
|
27
|
+
super arg
|
28
|
+
end
|
29
|
+
|
30
|
+
arg.each do |k, v|
|
31
|
+
instance_variable_set "@#{k}", v
|
32
|
+
end
|
33
|
+
else
|
34
|
+
super arg
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
# Override to_s to display a friendly error message
|
39
|
+
def to_s
|
40
|
+
message
|
41
|
+
end
|
42
|
+
|
43
|
+
def message
|
44
|
+
if @message.nil?
|
45
|
+
msg = "Error message: the server returns an error"
|
46
|
+
else
|
47
|
+
msg = @message
|
48
|
+
end
|
49
|
+
|
50
|
+
msg += "\nHTTP status code: #{code}" if code
|
51
|
+
msg += "\nResponse headers: #{response_headers}" if response_headers
|
52
|
+
msg += "\nResponse body: #{response_body}" if response_body
|
53
|
+
|
54
|
+
msg
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Svix
|
4
|
+
class ApplicationAPI
|
5
|
+
def initialize(api_client)
|
6
|
+
@api = ApplicationApi.new(api_client)
|
7
|
+
end
|
8
|
+
|
9
|
+
def list(options = {})
|
10
|
+
return @api.list_applications_api_v1_app_get(options)
|
11
|
+
end
|
12
|
+
|
13
|
+
def create(application_in)
|
14
|
+
return @api.create_application_api_v1_app_post(application_in)
|
15
|
+
end
|
16
|
+
|
17
|
+
def get(app_id)
|
18
|
+
return @api.get_application_api_v1_app_app_id_get(app_id)
|
19
|
+
end
|
20
|
+
|
21
|
+
def update(app_id, application_in)
|
22
|
+
return @api.update_application_api_v1_app_app_id_put(app_id, application_in)
|
23
|
+
end
|
24
|
+
|
25
|
+
def delete(app_id)
|
26
|
+
return @api.delete_application_api_v1_app_app_id_delete(app_id)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Svix
|
4
|
+
class AuthenticationAPI
|
5
|
+
def initialize(api_client)
|
6
|
+
@api = AuthenticationApi.new(api_client)
|
7
|
+
end
|
8
|
+
|
9
|
+
def dashboard_access(app_id)
|
10
|
+
return @api.get_dashboard_access_api_v1_auth_dashboard_access_app_id_post(app_id)
|
11
|
+
end
|
12
|
+
|
13
|
+
def logout
|
14
|
+
return @api.logout_api_v1_auth_logout_post
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|