=begin #Svix API #Welcome to the Svix API documentation! Useful links: [Homepage](https://www.svix.com) | [Support email](mailto:support+docs@svix.com) | [Blog](https://www.svix.com/blog/) | [Slack Community](https://www.svix.com/slack/) # Introduction This is the reference documentation and schemas for the [Svix webhook service](https://www.svix.com) API. For tutorials and other documentation please refer to [the documentation](https://docs.svix.com). ## Main concepts In Svix you have four important entities you will be interacting with: - `messages`: these are the webhooks being sent. They can have contents and a few other properties. - `application`: this is where `messages` are sent to. Usually you want to create one application for each user on your platform. - `endpoint`: endpoints are the URLs messages will be sent to. Each application can have multiple `endpoints` and each message sent to that application will be sent to all of them (unless they are not subscribed to the sent event type). - `event-type`: event types are identifiers denoting the type of the message being sent. Event types are primarily used to decide which events are sent to which endpoint. ## Authentication Get your authentication token (`AUTH_TOKEN`) from the [Svix dashboard](https://dashboard.svix.com) and use it as part of the `Authorization` header as such: `Authorization: Bearer ${AUTH_TOKEN}`. ## Code samples The code samples assume you already have the respective libraries installed and you know how to use them. For the latest information on how to do that, please refer to [the documentation](https://docs.svix.com/). ## Idempotency Svix supports [idempotency](https://en.wikipedia.org/wiki/Idempotence) for safely retrying requests without accidentally performing the same operation twice. This is useful when an API call is disrupted in transit and you do not receive a response. To perform an idempotent request, pass the idempotency key in the `Idempotency-Key` header to the request. The idempotency key should be a unique value generated by the client. You can create the key in however way you like, though we suggest using UUID v4, or any other string with enough entropy to avoid collisions. Svix's idempotency works by saving the resulting status code and body of the first request made for any given idempotency key for any successful request. Subsequent requests with the same key return the same result. Please note that idempotency is only supported for `POST` requests. ## Cross-Origin Resource Sharing This API features Cross-Origin Resource Sharing (CORS) implemented in compliance with [W3C spec](https://www.w3.org/TR/cors/). And that allows cross-domain communication from the browser. All responses have a wildcard same-origin which makes them completely public and accessible to everyone, including any code on any site. The version of the OpenAPI document: 1.4 Generated by: https://openapi-generator.tech OpenAPI Generator version: 5.2.0 =end require 'cgi' module Svix class AuthenticationApi attr_accessor :api_client def initialize(api_client = ApiClient.default) @api_client = api_client end # Expire All # Expire all of the tokens associated with a specific Application # @param app_id [String] # @param application_token_expire_in [ApplicationTokenExpireIn] # @param [Hash] opts the optional parameters # @option opts [String] :idempotency_key The request's idempotency key # @return [nil] def expire_all_api_v1_auth_app_app_id_expire_all_post(app_id, application_token_expire_in, opts = {}) expire_all_api_v1_auth_app_app_id_expire_all_post_with_http_info(app_id, application_token_expire_in, opts) nil end # Expire All # Expire all of the tokens associated with a specific Application # @param app_id [String] # @param application_token_expire_in [ApplicationTokenExpireIn] # @param [Hash] opts the optional parameters # @option opts [String] :idempotency_key The request's idempotency key # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers def expire_all_api_v1_auth_app_app_id_expire_all_post_with_http_info(app_id, application_token_expire_in, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: AuthenticationApi.expire_all_api_v1_auth_app_app_id_expire_all_post ...' end # verify the required parameter 'app_id' is set if @api_client.config.client_side_validation && app_id.nil? fail ArgumentError, "Missing the required parameter 'app_id' when calling AuthenticationApi.expire_all_api_v1_auth_app_app_id_expire_all_post" end if @api_client.config.client_side_validation && app_id.to_s.length > 256 fail ArgumentError, 'invalid value for "app_id" when calling AuthenticationApi.expire_all_api_v1_auth_app_app_id_expire_all_post, the character length must be smaller than or equal to 256.' end if @api_client.config.client_side_validation && app_id.to_s.length < 1 fail ArgumentError, 'invalid value for "app_id" when calling AuthenticationApi.expire_all_api_v1_auth_app_app_id_expire_all_post, the character length must be great than or equal to 1.' end pattern = Regexp.new(/^[a-zA-Z0-9\-_.]+$/) if @api_client.config.client_side_validation && app_id !~ pattern fail ArgumentError, "invalid value for 'app_id' when calling AuthenticationApi.expire_all_api_v1_auth_app_app_id_expire_all_post, must conform to the pattern #{pattern}." end # verify the required parameter 'application_token_expire_in' is set if @api_client.config.client_side_validation && application_token_expire_in.nil? fail ArgumentError, "Missing the required parameter 'application_token_expire_in' when calling AuthenticationApi.expire_all_api_v1_auth_app_app_id_expire_all_post" end # resource path local_var_path = '/api/v1/auth/app/{app_id}/expire-all/'.sub('{' + 'app_id' + '}', CGI.escape(app_id.to_s)) # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) header_params[:'idempotency-key'] = opts[:'idempotency_key'] if !opts[:'idempotency_key'].nil? # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] || @api_client.object_to_http_body(application_token_expire_in) # return_type return_type = opts[:debug_return_type] # auth_names auth_names = opts[:debug_auth_names] || ['HTTPBearer'] new_options = opts.merge( :operation => :"AuthenticationApi.expire_all_api_v1_auth_app_app_id_expire_all_post", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options) if @api_client.config.debugging @api_client.config.logger.debug "API called: AuthenticationApi#expire_all_api_v1_auth_app_app_id_expire_all_post\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Get Consumer App Portal Access # Use this function to get magic links (and authentication codes) for connecting your users to the Consumer Application Portal. # @param app_id [String] # @param [Hash] opts the optional parameters # @option opts [String] :idempotency_key The request's idempotency key # @return [DashboardAccessOut] def get_dashboard_access_api_v1_auth_dashboard_access_app_id_post(app_id, opts = {}) data, _status_code, _headers = get_dashboard_access_api_v1_auth_dashboard_access_app_id_post_with_http_info(app_id, opts) data end # Get Consumer App Portal Access # Use this function to get magic links (and authentication codes) for connecting your users to the Consumer Application Portal. # @param app_id [String] # @param [Hash] opts the optional parameters # @option opts [String] :idempotency_key The request's idempotency key # @return [Array<(DashboardAccessOut, Integer, Hash)>] DashboardAccessOut data, response status code and response headers def get_dashboard_access_api_v1_auth_dashboard_access_app_id_post_with_http_info(app_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: AuthenticationApi.get_dashboard_access_api_v1_auth_dashboard_access_app_id_post ...' end # verify the required parameter 'app_id' is set if @api_client.config.client_side_validation && app_id.nil? fail ArgumentError, "Missing the required parameter 'app_id' when calling AuthenticationApi.get_dashboard_access_api_v1_auth_dashboard_access_app_id_post" end if @api_client.config.client_side_validation && app_id.to_s.length > 256 fail ArgumentError, 'invalid value for "app_id" when calling AuthenticationApi.get_dashboard_access_api_v1_auth_dashboard_access_app_id_post, the character length must be smaller than or equal to 256.' end if @api_client.config.client_side_validation && app_id.to_s.length < 1 fail ArgumentError, 'invalid value for "app_id" when calling AuthenticationApi.get_dashboard_access_api_v1_auth_dashboard_access_app_id_post, the character length must be great than or equal to 1.' end pattern = Regexp.new(/^[a-zA-Z0-9\-_.]+$/) if @api_client.config.client_side_validation && app_id !~ pattern fail ArgumentError, "invalid value for 'app_id' when calling AuthenticationApi.get_dashboard_access_api_v1_auth_dashboard_access_app_id_post, must conform to the pattern #{pattern}." end # resource path local_var_path = '/api/v1/auth/dashboard-access/{app_id}/'.sub('{' + 'app_id' + '}', CGI.escape(app_id.to_s)) # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) header_params[:'idempotency-key'] = opts[:'idempotency_key'] if !opts[:'idempotency_key'].nil? # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] || 'DashboardAccessOut' # auth_names auth_names = opts[:debug_auth_names] || ['HTTPBearer'] new_options = opts.merge( :operation => :"AuthenticationApi.get_dashboard_access_api_v1_auth_dashboard_access_app_id_post", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options) if @api_client.config.debugging @api_client.config.logger.debug "API called: AuthenticationApi#get_dashboard_access_api_v1_auth_dashboard_access_app_id_post\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Logout # Logout an app token. Trying to log out other tokens will fail. # @param [Hash] opts the optional parameters # @option opts [String] :idempotency_key The request's idempotency key # @return [nil] def logout_api_v1_auth_logout_post(opts = {}) logout_api_v1_auth_logout_post_with_http_info(opts) nil end # Logout # Logout an app token. Trying to log out other tokens will fail. # @param [Hash] opts the optional parameters # @option opts [String] :idempotency_key The request's idempotency key # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers def logout_api_v1_auth_logout_post_with_http_info(opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: AuthenticationApi.logout_api_v1_auth_logout_post ...' end # resource path local_var_path = '/api/v1/auth/logout/' # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) header_params[:'idempotency-key'] = opts[:'idempotency_key'] if !opts[:'idempotency_key'].nil? # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] # auth_names auth_names = opts[:debug_auth_names] || ['HTTPBearer'] new_options = opts.merge( :operation => :"AuthenticationApi.logout_api_v1_auth_logout_post", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options) if @api_client.config.debugging @api_client.config.logger.debug "API called: AuthenticationApi#logout_api_v1_auth_logout_post\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end end end