=begin #Custom Workflow Actions #Create custom workflow actions The version of the OpenAPI document: v4 Generated by: https://openapi-generator.tech OpenAPI Generator version: 4.3.1 =end require 'cgi' module Hubspot module Automation module Actions class FunctionsApi attr_accessor :api_client def initialize(api_client = ApiClient.default) @api_client = api_client end # Delete a custom action function # Delete a function for a custom workflow action. This will remove the function itself as well as removing the association between the function and the custom action. This can't be undone. # @param definition_id [String] The ID of the custom workflow action # @param function_type [String] The type of function. This determines when the function will be called. # @param function_id [String] The ID qualifier for the function. This is used to specify which input field a function is associated with for `PRE_FETCH_OPTIONS` and `POST_FETCH_OPTIONS` function types. # @param app_id [Integer] # @param [Hash] opts the optional parameters # @return [nil] def archive(definition_id, function_type, function_id, app_id, opts = {}) archive_with_http_info(definition_id, function_type, function_id, app_id, opts) nil end # Delete a custom action function # Delete a function for a custom workflow action. This will remove the function itself as well as removing the association between the function and the custom action. This can't be undone. # @param definition_id [String] The ID of the custom workflow action # @param function_type [String] The type of function. This determines when the function will be called. # @param function_id [String] The ID qualifier for the function. This is used to specify which input field a function is associated with for `PRE_FETCH_OPTIONS` and `POST_FETCH_OPTIONS` function types. # @param app_id [Integer] # @param [Hash] opts the optional parameters # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers def archive_with_http_info(definition_id, function_type, function_id, app_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: FunctionsApi.archive ...' end # verify the required parameter 'definition_id' is set if @api_client.config.client_side_validation && definition_id.nil? fail ArgumentError, "Missing the required parameter 'definition_id' when calling FunctionsApi.archive" end # verify the required parameter 'function_type' is set if @api_client.config.client_side_validation && function_type.nil? fail ArgumentError, "Missing the required parameter 'function_type' when calling FunctionsApi.archive" end # verify enum value allowable_values = ["PRE_ACTION_EXECUTION", "PRE_FETCH_OPTIONS", "POST_FETCH_OPTIONS"] if @api_client.config.client_side_validation && !allowable_values.include?(function_type) fail ArgumentError, "invalid value for \"function_type\", must be one of #{allowable_values}" end # verify the required parameter 'function_id' is set if @api_client.config.client_side_validation && function_id.nil? fail ArgumentError, "Missing the required parameter 'function_id' when calling FunctionsApi.archive" 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 FunctionsApi.archive" end # resource path local_var_path = '/automation/v4/actions/{appId}/{definitionId}/functions/{functionType}/{functionId}'.sub('{' + 'definitionId' + '}', CGI.escape(definition_id.to_s)).sub('{' + 'functionType' + '}', CGI.escape(function_type.to_s)).sub('{' + 'functionId' + '}', CGI.escape(function_id.to_s)).sub('{' + 'appId' + '}', 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(['*/*']) # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:body] # return_type return_type = opts[:return_type] # auth_names auth_names = opts[:auth_names] || ['developer_hapikey'] new_options = opts.merge( :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: FunctionsApi#archive\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Delete a custom action function # Delete a function for a custom workflow action. This will remove the function itself as well as removing the association between the function and the custom action. This can't be undone. # @param definition_id [String] The ID of the custom workflow action. # @param function_type [String] The type of function. This determines when the function will be called. # @param app_id [Integer] # @param [Hash] opts the optional parameters # @return [nil] def archive_by_function_type(definition_id, function_type, app_id, opts = {}) archive_by_function_type_with_http_info(definition_id, function_type, app_id, opts) nil end # Delete a custom action function # Delete a function for a custom workflow action. This will remove the function itself as well as removing the association between the function and the custom action. This can't be undone. # @param definition_id [String] The ID of the custom workflow action. # @param function_type [String] The type of function. This determines when the function will be called. # @param app_id [Integer] # @param [Hash] opts the optional parameters # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers def archive_by_function_type_with_http_info(definition_id, function_type, app_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: FunctionsApi.archive_by_function_type ...' end # verify the required parameter 'definition_id' is set if @api_client.config.client_side_validation && definition_id.nil? fail ArgumentError, "Missing the required parameter 'definition_id' when calling FunctionsApi.archive_by_function_type" end # verify the required parameter 'function_type' is set if @api_client.config.client_side_validation && function_type.nil? fail ArgumentError, "Missing the required parameter 'function_type' when calling FunctionsApi.archive_by_function_type" end # verify enum value allowable_values = ["PRE_ACTION_EXECUTION", "PRE_FETCH_OPTIONS", "POST_FETCH_OPTIONS"] if @api_client.config.client_side_validation && !allowable_values.include?(function_type) fail ArgumentError, "invalid value for \"function_type\", must be one of #{allowable_values}" 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 FunctionsApi.archive_by_function_type" end # resource path local_var_path = '/automation/v4/actions/{appId}/{definitionId}/functions/{functionType}'.sub('{' + 'definitionId' + '}', CGI.escape(definition_id.to_s)).sub('{' + 'functionType' + '}', CGI.escape(function_type.to_s)).sub('{' + 'appId' + '}', 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(['*/*']) # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:body] # return_type return_type = opts[:return_type] # auth_names auth_names = opts[:auth_names] || ['developer_hapikey'] new_options = opts.merge( :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: FunctionsApi#archive_by_function_type\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Create or replace a custom action function # Creates or replaces a function for a custom workflow action. # @param definition_id [String] The ID of the custom workflow action. # @param function_type [String] The type of function. This determines when the function will be called. # @param function_id [String] The ID qualifier for the function. This is used to specify which input field a function is associated with for `PRE_FETCH_OPTIONS` and `POST_FETCH_OPTIONS` function types. # @param app_id [Integer] # @param body [String] The function source code. Must be valid JavaScript code. # @param [Hash] opts the optional parameters # @return [ActionFunctionIdentifier] def create_or_replace(definition_id, function_type, function_id, app_id, body, opts = {}) data, _status_code, _headers = create_or_replace_with_http_info(definition_id, function_type, function_id, app_id, body, opts) data end # Create or replace a custom action function # Creates or replaces a function for a custom workflow action. # @param definition_id [String] The ID of the custom workflow action. # @param function_type [String] The type of function. This determines when the function will be called. # @param function_id [String] The ID qualifier for the function. This is used to specify which input field a function is associated with for `PRE_FETCH_OPTIONS` and `POST_FETCH_OPTIONS` function types. # @param app_id [Integer] # @param body [String] The function source code. Must be valid JavaScript code. # @param [Hash] opts the optional parameters # @return [Array<(ActionFunctionIdentifier, Integer, Hash)>] ActionFunctionIdentifier data, response status code and response headers def create_or_replace_with_http_info(definition_id, function_type, function_id, app_id, body, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: FunctionsApi.create_or_replace ...' end # verify the required parameter 'definition_id' is set if @api_client.config.client_side_validation && definition_id.nil? fail ArgumentError, "Missing the required parameter 'definition_id' when calling FunctionsApi.create_or_replace" end # verify the required parameter 'function_type' is set if @api_client.config.client_side_validation && function_type.nil? fail ArgumentError, "Missing the required parameter 'function_type' when calling FunctionsApi.create_or_replace" end # verify enum value allowable_values = ["PRE_ACTION_EXECUTION", "PRE_FETCH_OPTIONS", "POST_FETCH_OPTIONS"] if @api_client.config.client_side_validation && !allowable_values.include?(function_type) fail ArgumentError, "invalid value for \"function_type\", must be one of #{allowable_values}" end # verify the required parameter 'function_id' is set if @api_client.config.client_side_validation && function_id.nil? fail ArgumentError, "Missing the required parameter 'function_id' when calling FunctionsApi.create_or_replace" 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 FunctionsApi.create_or_replace" 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 FunctionsApi.create_or_replace" end # resource path local_var_path = '/automation/v4/actions/{appId}/{definitionId}/functions/{functionType}/{functionId}'.sub('{' + 'definitionId' + '}', CGI.escape(definition_id.to_s)).sub('{' + 'functionType' + '}', CGI.escape(function_type.to_s)).sub('{' + 'functionId' + '}', CGI.escape(function_id.to_s)).sub('{' + 'appId' + '}', 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(['text/plain']) # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:body] || @api_client.object_to_http_body(body) # return_type return_type = opts[:return_type] || 'ActionFunctionIdentifier' # auth_names auth_names = opts[:auth_names] || ['developer_hapikey'] new_options = opts.merge( :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: FunctionsApi#create_or_replace\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Create or replace a custom action function # Creates or replaces a function for a custom workflow action. # @param definition_id [String] The ID of the custom workflow action. # @param function_type [String] The type of function. This determines when the function will be called. # @param app_id [Integer] # @param body [String] The function source code. Must be valid JavaScript code. # @param [Hash] opts the optional parameters # @return [ActionFunctionIdentifier] def create_or_replace_by_function_type(definition_id, function_type, app_id, body, opts = {}) data, _status_code, _headers = create_or_replace_by_function_type_with_http_info(definition_id, function_type, app_id, body, opts) data end # Create or replace a custom action function # Creates or replaces a function for a custom workflow action. # @param definition_id [String] The ID of the custom workflow action. # @param function_type [String] The type of function. This determines when the function will be called. # @param app_id [Integer] # @param body [String] The function source code. Must be valid JavaScript code. # @param [Hash] opts the optional parameters # @return [Array<(ActionFunctionIdentifier, Integer, Hash)>] ActionFunctionIdentifier data, response status code and response headers def create_or_replace_by_function_type_with_http_info(definition_id, function_type, app_id, body, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: FunctionsApi.create_or_replace_by_function_type ...' end # verify the required parameter 'definition_id' is set if @api_client.config.client_side_validation && definition_id.nil? fail ArgumentError, "Missing the required parameter 'definition_id' when calling FunctionsApi.create_or_replace_by_function_type" end # verify the required parameter 'function_type' is set if @api_client.config.client_side_validation && function_type.nil? fail ArgumentError, "Missing the required parameter 'function_type' when calling FunctionsApi.create_or_replace_by_function_type" end # verify enum value allowable_values = ["PRE_ACTION_EXECUTION", "PRE_FETCH_OPTIONS", "POST_FETCH_OPTIONS"] if @api_client.config.client_side_validation && !allowable_values.include?(function_type) fail ArgumentError, "invalid value for \"function_type\", must be one of #{allowable_values}" 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 FunctionsApi.create_or_replace_by_function_type" 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 FunctionsApi.create_or_replace_by_function_type" end # resource path local_var_path = '/automation/v4/actions/{appId}/{definitionId}/functions/{functionType}'.sub('{' + 'definitionId' + '}', CGI.escape(definition_id.to_s)).sub('{' + 'functionType' + '}', CGI.escape(function_type.to_s)).sub('{' + 'appId' + '}', 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(['text/plain']) # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:body] || @api_client.object_to_http_body(body) # return_type return_type = opts[:return_type] || 'ActionFunctionIdentifier' # auth_names auth_names = opts[:auth_names] || ['developer_hapikey'] new_options = opts.merge( :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: FunctionsApi#create_or_replace_by_function_type\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Get a custom action function # Returns the given function for a custom workflow action. # @param definition_id [String] The ID of the custom workflow action. # @param function_type [String] The type of function. This determines when the function will be called. # @param app_id [Integer] # @param [Hash] opts the optional parameters # @return [ActionFunction] def get_by_function_type(definition_id, function_type, app_id, opts = {}) data, _status_code, _headers = get_by_function_type_with_http_info(definition_id, function_type, app_id, opts) data end # Get a custom action function # Returns the given function for a custom workflow action. # @param definition_id [String] The ID of the custom workflow action. # @param function_type [String] The type of function. This determines when the function will be called. # @param app_id [Integer] # @param [Hash] opts the optional parameters # @return [Array<(ActionFunction, Integer, Hash)>] ActionFunction data, response status code and response headers def get_by_function_type_with_http_info(definition_id, function_type, app_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: FunctionsApi.get_by_function_type ...' end # verify the required parameter 'definition_id' is set if @api_client.config.client_side_validation && definition_id.nil? fail ArgumentError, "Missing the required parameter 'definition_id' when calling FunctionsApi.get_by_function_type" end # verify the required parameter 'function_type' is set if @api_client.config.client_side_validation && function_type.nil? fail ArgumentError, "Missing the required parameter 'function_type' when calling FunctionsApi.get_by_function_type" end # verify enum value allowable_values = ["PRE_ACTION_EXECUTION", "PRE_FETCH_OPTIONS", "POST_FETCH_OPTIONS"] if @api_client.config.client_side_validation && !allowable_values.include?(function_type) fail ArgumentError, "invalid value for \"function_type\", must be one of #{allowable_values}" 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 FunctionsApi.get_by_function_type" end # resource path local_var_path = '/automation/v4/actions/{appId}/{definitionId}/functions/{functionType}'.sub('{' + 'definitionId' + '}', CGI.escape(definition_id.to_s)).sub('{' + 'functionType' + '}', CGI.escape(function_type.to_s)).sub('{' + 'appId' + '}', 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', '*/*']) # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:body] # return_type return_type = opts[:return_type] || 'ActionFunction' # auth_names auth_names = opts[:auth_names] || ['developer_hapikey'] new_options = opts.merge( :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: FunctionsApi#get_by_function_type\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Get a custom action function # Returns the given function for a custom workflow action. # @param definition_id [String] The ID of the custom workflow action. # @param function_type [String] The type of function. This determines when the function will be called. # @param function_id [String] The ID qualifier for the function. This is used to specify which input field a function is associated with for `PRE_FETCH_OPTIONS` and `POST_FETCH_OPTIONS` function types. # @param app_id [Integer] # @param [Hash] opts the optional parameters # @return [ActionFunction] def get_by_id(definition_id, function_type, function_id, app_id, opts = {}) data, _status_code, _headers = get_by_id_with_http_info(definition_id, function_type, function_id, app_id, opts) data end # Get a custom action function # Returns the given function for a custom workflow action. # @param definition_id [String] The ID of the custom workflow action. # @param function_type [String] The type of function. This determines when the function will be called. # @param function_id [String] The ID qualifier for the function. This is used to specify which input field a function is associated with for `PRE_FETCH_OPTIONS` and `POST_FETCH_OPTIONS` function types. # @param app_id [Integer] # @param [Hash] opts the optional parameters # @return [Array<(ActionFunction, Integer, Hash)>] ActionFunction data, response status code and response headers def get_by_id_with_http_info(definition_id, function_type, function_id, app_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: FunctionsApi.get_by_id ...' end # verify the required parameter 'definition_id' is set if @api_client.config.client_side_validation && definition_id.nil? fail ArgumentError, "Missing the required parameter 'definition_id' when calling FunctionsApi.get_by_id" end # verify the required parameter 'function_type' is set if @api_client.config.client_side_validation && function_type.nil? fail ArgumentError, "Missing the required parameter 'function_type' when calling FunctionsApi.get_by_id" end # verify enum value allowable_values = ["PRE_ACTION_EXECUTION", "PRE_FETCH_OPTIONS", "POST_FETCH_OPTIONS"] if @api_client.config.client_side_validation && !allowable_values.include?(function_type) fail ArgumentError, "invalid value for \"function_type\", must be one of #{allowable_values}" end # verify the required parameter 'function_id' is set if @api_client.config.client_side_validation && function_id.nil? fail ArgumentError, "Missing the required parameter 'function_id' when calling FunctionsApi.get_by_id" 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 FunctionsApi.get_by_id" end # resource path local_var_path = '/automation/v4/actions/{appId}/{definitionId}/functions/{functionType}/{functionId}'.sub('{' + 'definitionId' + '}', CGI.escape(definition_id.to_s)).sub('{' + 'functionType' + '}', CGI.escape(function_type.to_s)).sub('{' + 'functionId' + '}', CGI.escape(function_id.to_s)).sub('{' + 'appId' + '}', 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', '*/*']) # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:body] # return_type return_type = opts[:return_type] || 'ActionFunction' # auth_names auth_names = opts[:auth_names] || ['developer_hapikey'] new_options = opts.merge( :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: FunctionsApi#get_by_id\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Get all custom action functions # Returns a list of all functions that are associated with the given custom workflow action. # @param definition_id [String] The ID of the custom workflow action. # @param app_id [Integer] # @param [Hash] opts the optional parameters # @return [CollectionResponseActionFunctionIdentifierNoPaging] def get_page(definition_id, app_id, opts = {}) data, _status_code, _headers = get_page_with_http_info(definition_id, app_id, opts) data end # Get all custom action functions # Returns a list of all functions that are associated with the given custom workflow action. # @param definition_id [String] The ID of the custom workflow action. # @param app_id [Integer] # @param [Hash] opts the optional parameters # @return [Array<(CollectionResponseActionFunctionIdentifierNoPaging, Integer, Hash)>] CollectionResponseActionFunctionIdentifierNoPaging data, response status code and response headers def get_page_with_http_info(definition_id, app_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: FunctionsApi.get_page ...' end # verify the required parameter 'definition_id' is set if @api_client.config.client_side_validation && definition_id.nil? fail ArgumentError, "Missing the required parameter 'definition_id' when calling FunctionsApi.get_page" 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 FunctionsApi.get_page" end # resource path local_var_path = '/automation/v4/actions/{appId}/{definitionId}/functions'.sub('{' + 'definitionId' + '}', CGI.escape(definition_id.to_s)).sub('{' + 'appId' + '}', 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', '*/*']) # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:body] # return_type return_type = opts[:return_type] || 'CollectionResponseActionFunctionIdentifierNoPaging' # auth_names auth_names = opts[:auth_names] || ['developer_hapikey'] new_options = opts.merge( :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: FunctionsApi#get_page\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end end end end end