=begin #Svix API #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) The version of the OpenAPI document: 1.1.1 Generated by: https://openapi-generator.tech Generator version: 7.9.0 =end require 'cgi' module Svix class WebhookEndpointApi attr_accessor :api_client def initialize(api_client = ApiClient.default) @api_client = api_client end # Create Operational Webhook Endpoint # Create an operational webhook endpoint. # @param operational_webhook_endpoint_in [OperationalWebhookEndpointIn] # @param [Hash] opts the optional parameters # @option opts [String] :idempotency_key The request's idempotency key # @return [OperationalWebhookEndpointOut] def create_operational_webhook_endpoint(operational_webhook_endpoint_in, opts = {}) data, _status_code, _headers = create_operational_webhook_endpoint_with_http_info(operational_webhook_endpoint_in, opts) data end # Create Operational Webhook Endpoint # Create an operational webhook endpoint. # @param operational_webhook_endpoint_in [OperationalWebhookEndpointIn] # @param [Hash] opts the optional parameters # @option opts [String] :idempotency_key The request's idempotency key # @return [Array<(OperationalWebhookEndpointOut, Integer, Hash)>] OperationalWebhookEndpointOut data, response status code and response headers def create_operational_webhook_endpoint_with_http_info(operational_webhook_endpoint_in, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: WebhookEndpointApi.create_operational_webhook_endpoint ...' end # verify the required parameter 'operational_webhook_endpoint_in' is set if @api_client.config.client_side_validation && operational_webhook_endpoint_in.nil? fail ArgumentError, "Missing the required parameter 'operational_webhook_endpoint_in' when calling WebhookEndpointApi.create_operational_webhook_endpoint" end # resource path local_var_path = '/api/v1/operational-webhook/endpoint' # 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']) unless header_params['Accept'] # HTTP header 'Content-Type' content_type = @api_client.select_header_content_type(['application/json']) if !content_type.nil? header_params['Content-Type'] = content_type end 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(operational_webhook_endpoint_in) # return_type return_type = opts[:debug_return_type] || 'OperationalWebhookEndpointOut' # auth_names auth_names = opts[:debug_auth_names] || ['HTTPBearer'] new_options = opts.merge( :operation => :"WebhookEndpointApi.create_operational_webhook_endpoint", :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: WebhookEndpointApi#create_operational_webhook_endpoint\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Delete Operational Webhook Endpoint # Delete an operational webhook endpoint. # @param endpoint_id [String] The ep's ID or UID # @param [Hash] opts the optional parameters # @return [nil] def delete_operational_webhook_endpoint(endpoint_id, opts = {}) delete_operational_webhook_endpoint_with_http_info(endpoint_id, opts) nil end # Delete Operational Webhook Endpoint # Delete an operational webhook endpoint. # @param endpoint_id [String] The ep's ID or UID # @param [Hash] opts the optional parameters # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers def delete_operational_webhook_endpoint_with_http_info(endpoint_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: WebhookEndpointApi.delete_operational_webhook_endpoint ...' end # verify the required parameter 'endpoint_id' is set if @api_client.config.client_side_validation && endpoint_id.nil? fail ArgumentError, "Missing the required parameter 'endpoint_id' when calling WebhookEndpointApi.delete_operational_webhook_endpoint" end if @api_client.config.client_side_validation && endpoint_id.to_s.length > 256 fail ArgumentError, 'invalid value for "endpoint_id" when calling WebhookEndpointApi.delete_operational_webhook_endpoint, the character length must be smaller than or equal to 256.' end if @api_client.config.client_side_validation && endpoint_id.to_s.length < 1 fail ArgumentError, 'invalid value for "endpoint_id" when calling WebhookEndpointApi.delete_operational_webhook_endpoint, 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 && endpoint_id !~ pattern fail ArgumentError, "invalid value for 'endpoint_id' when calling WebhookEndpointApi.delete_operational_webhook_endpoint, must conform to the pattern #{pattern}." end # resource path local_var_path = '/api/v1/operational-webhook/endpoint/{endpoint_id}'.sub('{' + 'endpoint_id' + '}', CGI.escape(endpoint_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']) unless header_params['Accept'] # 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 => :"WebhookEndpointApi.delete_operational_webhook_endpoint", :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(:DELETE, local_var_path, new_options) if @api_client.config.debugging @api_client.config.logger.debug "API called: WebhookEndpointApi#delete_operational_webhook_endpoint\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Get Operational Webhook Endpoint # Get an operational webhook endpoint. # @param endpoint_id [String] The ep's ID or UID # @param [Hash] opts the optional parameters # @return [OperationalWebhookEndpointOut] def get_operational_webhook_endpoint(endpoint_id, opts = {}) data, _status_code, _headers = get_operational_webhook_endpoint_with_http_info(endpoint_id, opts) data end # Get Operational Webhook Endpoint # Get an operational webhook endpoint. # @param endpoint_id [String] The ep's ID or UID # @param [Hash] opts the optional parameters # @return [Array<(OperationalWebhookEndpointOut, Integer, Hash)>] OperationalWebhookEndpointOut data, response status code and response headers def get_operational_webhook_endpoint_with_http_info(endpoint_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: WebhookEndpointApi.get_operational_webhook_endpoint ...' end # verify the required parameter 'endpoint_id' is set if @api_client.config.client_side_validation && endpoint_id.nil? fail ArgumentError, "Missing the required parameter 'endpoint_id' when calling WebhookEndpointApi.get_operational_webhook_endpoint" end if @api_client.config.client_side_validation && endpoint_id.to_s.length > 256 fail ArgumentError, 'invalid value for "endpoint_id" when calling WebhookEndpointApi.get_operational_webhook_endpoint, the character length must be smaller than or equal to 256.' end if @api_client.config.client_side_validation && endpoint_id.to_s.length < 1 fail ArgumentError, 'invalid value for "endpoint_id" when calling WebhookEndpointApi.get_operational_webhook_endpoint, 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 && endpoint_id !~ pattern fail ArgumentError, "invalid value for 'endpoint_id' when calling WebhookEndpointApi.get_operational_webhook_endpoint, must conform to the pattern #{pattern}." end # resource path local_var_path = '/api/v1/operational-webhook/endpoint/{endpoint_id}'.sub('{' + 'endpoint_id' + '}', CGI.escape(endpoint_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']) unless header_params['Accept'] # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] || 'OperationalWebhookEndpointOut' # auth_names auth_names = opts[:debug_auth_names] || ['HTTPBearer'] new_options = opts.merge( :operation => :"WebhookEndpointApi.get_operational_webhook_endpoint", :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(:GET, local_var_path, new_options) if @api_client.config.debugging @api_client.config.logger.debug "API called: WebhookEndpointApi#get_operational_webhook_endpoint\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Get Operational Webhook Endpoint Secret # Get an operational webhook endpoint's signing secret. This is used to verify the authenticity of the webhook. For more information please refer to [the consuming webhooks docs](https://docs.svix.com/consuming-webhooks/). # @param endpoint_id [String] The ep's ID or UID # @param [Hash] opts the optional parameters # @return [OperationalWebhookEndpointSecretOut] def get_operational_webhook_endpoint_secret(endpoint_id, opts = {}) data, _status_code, _headers = get_operational_webhook_endpoint_secret_with_http_info(endpoint_id, opts) data end # Get Operational Webhook Endpoint Secret # Get an operational webhook endpoint's signing secret. This is used to verify the authenticity of the webhook. For more information please refer to [the consuming webhooks docs](https://docs.svix.com/consuming-webhooks/). # @param endpoint_id [String] The ep's ID or UID # @param [Hash] opts the optional parameters # @return [Array<(OperationalWebhookEndpointSecretOut, Integer, Hash)>] OperationalWebhookEndpointSecretOut data, response status code and response headers def get_operational_webhook_endpoint_secret_with_http_info(endpoint_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: WebhookEndpointApi.get_operational_webhook_endpoint_secret ...' end # verify the required parameter 'endpoint_id' is set if @api_client.config.client_side_validation && endpoint_id.nil? fail ArgumentError, "Missing the required parameter 'endpoint_id' when calling WebhookEndpointApi.get_operational_webhook_endpoint_secret" end if @api_client.config.client_side_validation && endpoint_id.to_s.length > 256 fail ArgumentError, 'invalid value for "endpoint_id" when calling WebhookEndpointApi.get_operational_webhook_endpoint_secret, the character length must be smaller than or equal to 256.' end if @api_client.config.client_side_validation && endpoint_id.to_s.length < 1 fail ArgumentError, 'invalid value for "endpoint_id" when calling WebhookEndpointApi.get_operational_webhook_endpoint_secret, 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 && endpoint_id !~ pattern fail ArgumentError, "invalid value for 'endpoint_id' when calling WebhookEndpointApi.get_operational_webhook_endpoint_secret, must conform to the pattern #{pattern}." end # resource path local_var_path = '/api/v1/operational-webhook/endpoint/{endpoint_id}/secret'.sub('{' + 'endpoint_id' + '}', CGI.escape(endpoint_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']) unless header_params['Accept'] # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] || 'OperationalWebhookEndpointSecretOut' # auth_names auth_names = opts[:debug_auth_names] || ['HTTPBearer'] new_options = opts.merge( :operation => :"WebhookEndpointApi.get_operational_webhook_endpoint_secret", :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(:GET, local_var_path, new_options) if @api_client.config.debugging @api_client.config.logger.debug "API called: WebhookEndpointApi#get_operational_webhook_endpoint_secret\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # List Operational Webhook Endpoints # List operational webhook endpoints. # @param [Hash] opts the optional parameters # @option opts [Integer] :limit Limit the number of returned items # @option opts [String] :iterator The iterator returned from a prior invocation # @option opts [Ordering] :order The sorting order of the returned items # @return [ListResponseOperationalWebhookEndpointOut] def list_operational_webhook_endpoints(opts = {}) data, _status_code, _headers = list_operational_webhook_endpoints_with_http_info(opts) data end # List Operational Webhook Endpoints # List operational webhook endpoints. # @param [Hash] opts the optional parameters # @option opts [Integer] :limit Limit the number of returned items # @option opts [String] :iterator The iterator returned from a prior invocation # @option opts [Ordering] :order The sorting order of the returned items # @return [Array<(ListResponseOperationalWebhookEndpointOut, Integer, Hash)>] ListResponseOperationalWebhookEndpointOut data, response status code and response headers def list_operational_webhook_endpoints_with_http_info(opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: WebhookEndpointApi.list_operational_webhook_endpoints ...' end if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] > 250 fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling WebhookEndpointApi.list_operational_webhook_endpoints, must be smaller than or equal to 250.' end if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] < 1 fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling WebhookEndpointApi.list_operational_webhook_endpoints, must be greater than or equal to 1.' end # resource path local_var_path = '/api/v1/operational-webhook/endpoint' # query parameters query_params = opts[:query_params] || {} query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil? query_params[:'iterator'] = opts[:'iterator'] if !opts[:'iterator'].nil? query_params[:'order'] = opts[:'order'] if !opts[:'order'].nil? # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept'] # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] || 'ListResponseOperationalWebhookEndpointOut' # auth_names auth_names = opts[:debug_auth_names] || ['HTTPBearer'] new_options = opts.merge( :operation => :"WebhookEndpointApi.list_operational_webhook_endpoints", :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(:GET, local_var_path, new_options) if @api_client.config.debugging @api_client.config.logger.debug "API called: WebhookEndpointApi#list_operational_webhook_endpoints\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Rotate Operational Webhook Endpoint Secret # Rotates an operational webhook endpoint's signing secret. The previous secret will remain valid for the next 24 hours. # @param endpoint_id [String] The ep's ID or UID # @param operational_webhook_endpoint_secret_in [OperationalWebhookEndpointSecretIn] # @param [Hash] opts the optional parameters # @option opts [String] :idempotency_key The request's idempotency key # @return [nil] def rotate_operational_webhook_endpoint_secret(endpoint_id, operational_webhook_endpoint_secret_in, opts = {}) rotate_operational_webhook_endpoint_secret_with_http_info(endpoint_id, operational_webhook_endpoint_secret_in, opts) nil end # Rotate Operational Webhook Endpoint Secret # Rotates an operational webhook endpoint's signing secret. The previous secret will remain valid for the next 24 hours. # @param endpoint_id [String] The ep's ID or UID # @param operational_webhook_endpoint_secret_in [OperationalWebhookEndpointSecretIn] # @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 rotate_operational_webhook_endpoint_secret_with_http_info(endpoint_id, operational_webhook_endpoint_secret_in, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: WebhookEndpointApi.rotate_operational_webhook_endpoint_secret ...' end # verify the required parameter 'endpoint_id' is set if @api_client.config.client_side_validation && endpoint_id.nil? fail ArgumentError, "Missing the required parameter 'endpoint_id' when calling WebhookEndpointApi.rotate_operational_webhook_endpoint_secret" end if @api_client.config.client_side_validation && endpoint_id.to_s.length > 256 fail ArgumentError, 'invalid value for "endpoint_id" when calling WebhookEndpointApi.rotate_operational_webhook_endpoint_secret, the character length must be smaller than or equal to 256.' end if @api_client.config.client_side_validation && endpoint_id.to_s.length < 1 fail ArgumentError, 'invalid value for "endpoint_id" when calling WebhookEndpointApi.rotate_operational_webhook_endpoint_secret, 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 && endpoint_id !~ pattern fail ArgumentError, "invalid value for 'endpoint_id' when calling WebhookEndpointApi.rotate_operational_webhook_endpoint_secret, must conform to the pattern #{pattern}." end # verify the required parameter 'operational_webhook_endpoint_secret_in' is set if @api_client.config.client_side_validation && operational_webhook_endpoint_secret_in.nil? fail ArgumentError, "Missing the required parameter 'operational_webhook_endpoint_secret_in' when calling WebhookEndpointApi.rotate_operational_webhook_endpoint_secret" end # resource path local_var_path = '/api/v1/operational-webhook/endpoint/{endpoint_id}/secret/rotate'.sub('{' + 'endpoint_id' + '}', CGI.escape(endpoint_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']) unless header_params['Accept'] # HTTP header 'Content-Type' content_type = @api_client.select_header_content_type(['application/json']) if !content_type.nil? header_params['Content-Type'] = content_type end 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(operational_webhook_endpoint_secret_in) # return_type return_type = opts[:debug_return_type] # auth_names auth_names = opts[:debug_auth_names] || ['HTTPBearer'] new_options = opts.merge( :operation => :"WebhookEndpointApi.rotate_operational_webhook_endpoint_secret", :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: WebhookEndpointApi#rotate_operational_webhook_endpoint_secret\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Update Operational Webhook Endpoint # Update an operational webhook endpoint. # @param endpoint_id [String] The ep's ID or UID # @param operational_webhook_endpoint_update [OperationalWebhookEndpointUpdate] # @param [Hash] opts the optional parameters # @return [OperationalWebhookEndpointOut] def update_operational_webhook_endpoint(endpoint_id, operational_webhook_endpoint_update, opts = {}) data, _status_code, _headers = update_operational_webhook_endpoint_with_http_info(endpoint_id, operational_webhook_endpoint_update, opts) data end # Update Operational Webhook Endpoint # Update an operational webhook endpoint. # @param endpoint_id [String] The ep's ID or UID # @param operational_webhook_endpoint_update [OperationalWebhookEndpointUpdate] # @param [Hash] opts the optional parameters # @return [Array<(OperationalWebhookEndpointOut, Integer, Hash)>] OperationalWebhookEndpointOut data, response status code and response headers def update_operational_webhook_endpoint_with_http_info(endpoint_id, operational_webhook_endpoint_update, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: WebhookEndpointApi.update_operational_webhook_endpoint ...' end # verify the required parameter 'endpoint_id' is set if @api_client.config.client_side_validation && endpoint_id.nil? fail ArgumentError, "Missing the required parameter 'endpoint_id' when calling WebhookEndpointApi.update_operational_webhook_endpoint" end if @api_client.config.client_side_validation && endpoint_id.to_s.length > 256 fail ArgumentError, 'invalid value for "endpoint_id" when calling WebhookEndpointApi.update_operational_webhook_endpoint, the character length must be smaller than or equal to 256.' end if @api_client.config.client_side_validation && endpoint_id.to_s.length < 1 fail ArgumentError, 'invalid value for "endpoint_id" when calling WebhookEndpointApi.update_operational_webhook_endpoint, 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 && endpoint_id !~ pattern fail ArgumentError, "invalid value for 'endpoint_id' when calling WebhookEndpointApi.update_operational_webhook_endpoint, must conform to the pattern #{pattern}." end # verify the required parameter 'operational_webhook_endpoint_update' is set if @api_client.config.client_side_validation && operational_webhook_endpoint_update.nil? fail ArgumentError, "Missing the required parameter 'operational_webhook_endpoint_update' when calling WebhookEndpointApi.update_operational_webhook_endpoint" end # resource path local_var_path = '/api/v1/operational-webhook/endpoint/{endpoint_id}'.sub('{' + 'endpoint_id' + '}', CGI.escape(endpoint_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']) unless header_params['Accept'] # HTTP header 'Content-Type' content_type = @api_client.select_header_content_type(['application/json']) if !content_type.nil? header_params['Content-Type'] = content_type end # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] || @api_client.object_to_http_body(operational_webhook_endpoint_update) # return_type return_type = opts[:debug_return_type] || 'OperationalWebhookEndpointOut' # auth_names auth_names = opts[:debug_auth_names] || ['HTTPBearer'] new_options = opts.merge( :operation => :"WebhookEndpointApi.update_operational_webhook_endpoint", :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(:PUT, local_var_path, new_options) if @api_client.config.debugging @api_client.config.logger.debug "API called: WebhookEndpointApi#update_operational_webhook_endpoint\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end end end