=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 InboundApi attr_accessor :api_client def initialize(api_client = ApiClient.default) @api_client = api_client end # Handle Inbound # Handles a raw inbound webhook for the application. # @param app_id [String] The app's ID or UID # @param inbound_token [String] # @param body [String] # @param [Hash] opts the optional parameters # @option opts [String] :event_type The event type's name # @option opts [String] :idempotency_key The request's idempotency key # @return [MessageOut] def v1_inbound_msg(app_id, inbound_token, body, opts = {}) data, _status_code, _headers = v1_inbound_msg_with_http_info(app_id, inbound_token, body, opts) data end # Handle Inbound # Handles a raw inbound webhook for the application. # @param app_id [String] The app's ID or UID # @param inbound_token [String] # @param body [String] # @param [Hash] opts the optional parameters # @option opts [String] :event_type The event type's name # @option opts [String] :idempotency_key The request's idempotency key # @return [Array<(MessageOut, Integer, Hash)>] MessageOut data, response status code and response headers def v1_inbound_msg_with_http_info(app_id, inbound_token, body, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: InboundApi.v1_inbound_msg ...' 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 InboundApi.v1_inbound_msg" end if @api_client.config.client_side_validation && app_id.to_s.length > 256 fail ArgumentError, 'invalid value for "app_id" when calling InboundApi.v1_inbound_msg, 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 InboundApi.v1_inbound_msg, 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 InboundApi.v1_inbound_msg, must conform to the pattern #{pattern}." end # verify the required parameter 'inbound_token' is set if @api_client.config.client_side_validation && inbound_token.nil? fail ArgumentError, "Missing the required parameter 'inbound_token' when calling InboundApi.v1_inbound_msg" end # verify the required parameter 'body' is set if @api_client.config.client_side_validation && body.nil? fail ArgumentError, "Missing the required parameter 'body' when calling InboundApi.v1_inbound_msg" end if @api_client.config.client_side_validation && !opts[:'event_type'].nil? && opts[:'event_type'].to_s.length > 256 fail ArgumentError, 'invalid value for "opts[:"event_type"]" when calling InboundApi.v1_inbound_msg, the character length must be smaller than or equal to 256.' end pattern = Regexp.new(/^[a-zA-Z0-9\-_.]+$/) if @api_client.config.client_side_validation && !opts[:'event_type'].nil? && opts[:'event_type'] !~ pattern fail ArgumentError, "invalid value for 'opts[:\"event_type\"]' when calling InboundApi.v1_inbound_msg, must conform to the pattern #{pattern}." end # resource path local_var_path = '/api/v1/app/{app_id}/inbound/msg/{inbound_token}'.sub('{' + 'app_id' + '}', CGI.escape(app_id.to_s)).sub('{' + 'inbound_token' + '}', CGI.escape(inbound_token.to_s)) # query parameters query_params = opts[:query_params] || {} query_params[:'event_type'] = opts[:'event_type'] if !opts[:'event_type'].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'] # 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(body) # return_type return_type = opts[:debug_return_type] || 'MessageOut' # auth_names auth_names = opts[:debug_auth_names] || ['HTTPBearer'] new_options = opts.merge( :operation => :"InboundApi.v1_inbound_msg", :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: InboundApi#v1_inbound_msg\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Rotate Url # Invalidates the previous inbound url (if one exists), producing a new inbound URL for this app. # @param app_id [String] The app's ID or UID # @param [Hash] opts the optional parameters # @option opts [String] :idempotency_key The request's idempotency key # @return [RotatedUrlOut] def v1_inbound_rotate_url(app_id, opts = {}) data, _status_code, _headers = v1_inbound_rotate_url_with_http_info(app_id, opts) data end # Rotate Url # Invalidates the previous inbound url (if one exists), producing a new inbound URL for this app. # @param app_id [String] The app's ID or UID # @param [Hash] opts the optional parameters # @option opts [String] :idempotency_key The request's idempotency key # @return [Array<(RotatedUrlOut, Integer, Hash)>] RotatedUrlOut data, response status code and response headers def v1_inbound_rotate_url_with_http_info(app_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: InboundApi.v1_inbound_rotate_url ...' 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 InboundApi.v1_inbound_rotate_url" end if @api_client.config.client_side_validation && app_id.to_s.length > 256 fail ArgumentError, 'invalid value for "app_id" when calling InboundApi.v1_inbound_rotate_url, 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 InboundApi.v1_inbound_rotate_url, 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 InboundApi.v1_inbound_rotate_url, must conform to the pattern #{pattern}." end # resource path local_var_path = '/api/v1/app/{app_id}/inbound/rotate-url'.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']) unless header_params['Accept'] 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] || 'RotatedUrlOut' # auth_names auth_names = opts[:debug_auth_names] || ['HTTPBearer'] new_options = opts.merge( :operation => :"InboundApi.v1_inbound_rotate_url", :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: InboundApi#v1_inbound_rotate_url\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end end end