=begin
#Docusign eSignature REST API

#The Docusign eSignature REST API provides you with a powerful, convenient, and simple Web services API for interacting with Docusign.

OpenAPI spec version: v2.1
Contact: devcenter@docusign.com
Generated by: https://github.com/swagger-api/swagger-codegen.git

=end

require "uri"

module DocuSign_eSign

  class ListOptions
    # When set to **true**, only custom tabs are returned in the response. 
    attr_accessor :custom_tab_only

    def self.default
      @@default ||= ListOptions.new
    end
  end


  class CustomTabsApi
    attr_accessor :api_client

    def initialize(api_client = CustomTabsApi.default)
      @api_client = api_client
    end

    # Creates a custom tab.
    # Creates a tab with pre-defined properties, such as a text tab with a certain font type and validation pattern. Users can access the custom tabs when sending documents through the DocuSign web application.  Custom tabs can be created for approve, checkbox, company, date, date signed, decline, email, email address, envelope ID, first name, formula, full name, initial here, last name, list, note, number, radio, sign here, signer attachment, SSN, text, title, and zip tabs.
    # @param account_id The external account number (int) or account ID Guid.
    # @param tab_metadata  (optional parameter)
    # @return [TabMetadata]
    def create(account_id, tab_metadata)
      data, _status_code, _headers = create_with_http_info(account_id,  tab_metadata)
      return data
    end

    # Creates a custom tab.
    # Creates a tab with pre-defined properties, such as a text tab with a certain font type and validation pattern. Users can access the custom tabs when sending documents through the DocuSign web application.  Custom tabs can be created for approve, checkbox, company, date, date signed, decline, email, email address, envelope ID, first name, formula, full name, initial here, last name, list, note, number, radio, sign here, signer attachment, SSN, text, title, and zip tabs.
    # @param account_id The external account number (int) or account ID Guid.
    # @param tab_metadata  (optional parameter)
    # @return [Array<(TabMetadata, Fixnum, Hash)>] TabMetadata data, response status code and response headers
    def create_with_http_info(account_id, tab_metadata)
      if @api_client.config.debugging
        @api_client.config.logger.debug "Calling API: CustomTabsApi.create ..."
      end
      # verify the required parameter 'account_id' is set
      fail ArgumentError, "Missing the required parameter 'account_id' when calling CustomTabsApi.create" if account_id.nil?
      # resource path
      local_var_path = "/v2.1/accounts/{accountId}/tab_definitions".sub('{format}','json').sub('{' + 'accountId' + '}', account_id.to_s)

      # query parameters
      query_params = {}

      # header parameters
      header_params = {}
      # HTTP header 'Accept' (if needed)
      header_params['Accept'] = @api_client.select_header_accept(['application/json'])

      # form parameters
      form_params = {}

      # http body (model)
      post_body = @api_client.object_to_http_body(tab_metadata)
      auth_names = []
      data, status_code, headers = @api_client.call_api(:POST, local_var_path,
        :header_params => header_params,
        :query_params => query_params,
        :form_params => form_params,
        :body => post_body,
        :auth_names => auth_names,
        :return_type => 'TabMetadata')
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: CustomTabsApi#create\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end

    # Deletes custom tab information.
    # Deletes the custom from the specified account.
    # @param account_id The external account number (int) or account ID Guid.
    # @param custom_tab_id 
    # @return [nil]
    def delete(account_id, custom_tab_id)
      delete_with_http_info(account_id, custom_tab_id)
      return nil
    end

    # Deletes custom tab information.
    # Deletes the custom from the specified account.
    # @param account_id The external account number (int) or account ID Guid.
    # @param custom_tab_id 
    # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
    def delete_with_http_info(account_id, custom_tab_id)
      if @api_client.config.debugging
        @api_client.config.logger.debug "Calling API: CustomTabsApi.delete ..."
      end
      # verify the required parameter 'account_id' is set
      fail ArgumentError, "Missing the required parameter 'account_id' when calling CustomTabsApi.delete" if account_id.nil?
      # verify the required parameter 'custom_tab_id' is set
      fail ArgumentError, "Missing the required parameter 'custom_tab_id' when calling CustomTabsApi.delete" if custom_tab_id.nil?
      # resource path
      local_var_path = "/v2.1/accounts/{accountId}/tab_definitions/{customTabId}".sub('{format}','json').sub('{' + 'accountId' + '}', account_id.to_s).sub('{' + 'customTabId' + '}', custom_tab_id.to_s)

      # query parameters
      query_params = {}

      # header parameters
      header_params = {}
      # HTTP header 'Accept' (if needed)
      header_params['Accept'] = @api_client.select_header_accept(['application/json'])

      # form parameters
      form_params = {}

      # http body (model)
      post_body = nil
      auth_names = []
      data, status_code, headers = @api_client.call_api(:DELETE, local_var_path,
        :header_params => header_params,
        :query_params => query_params,
        :form_params => form_params,
        :body => post_body,
        :auth_names => auth_names)
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: CustomTabsApi#delete\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end

    # Gets custom tab information.
    # Retrieves information about the requested custom tab on the specified account.
    # @param account_id The external account number (int) or account ID Guid.
    # @param custom_tab_id 
    # @return [TabMetadata]
    def get(account_id, custom_tab_id)
      data, _status_code, _headers = get_with_http_info(account_id, custom_tab_id)
      return data
    end

    # Gets custom tab information.
    # Retrieves information about the requested custom tab on the specified account.
    # @param account_id The external account number (int) or account ID Guid.
    # @param custom_tab_id 
    # @return [Array<(TabMetadata, Fixnum, Hash)>] TabMetadata data, response status code and response headers
    def get_with_http_info(account_id, custom_tab_id)
      if @api_client.config.debugging
        @api_client.config.logger.debug "Calling API: CustomTabsApi.get ..."
      end
      # verify the required parameter 'account_id' is set
      fail ArgumentError, "Missing the required parameter 'account_id' when calling CustomTabsApi.get" if account_id.nil?
      # verify the required parameter 'custom_tab_id' is set
      fail ArgumentError, "Missing the required parameter 'custom_tab_id' when calling CustomTabsApi.get" if custom_tab_id.nil?
      # resource path
      local_var_path = "/v2.1/accounts/{accountId}/tab_definitions/{customTabId}".sub('{format}','json').sub('{' + 'accountId' + '}', account_id.to_s).sub('{' + 'customTabId' + '}', custom_tab_id.to_s)

      # query parameters
      query_params = {}

      # header parameters
      header_params = {}
      # HTTP header 'Accept' (if needed)
      header_params['Accept'] = @api_client.select_header_accept(['application/json'])

      # form parameters
      form_params = {}

      # http body (model)
      post_body = nil
      auth_names = []
      data, status_code, headers = @api_client.call_api(:GET, local_var_path,
        :header_params => header_params,
        :query_params => query_params,
        :form_params => form_params,
        :body => post_body,
        :auth_names => auth_names,
        :return_type => 'TabMetadata')
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: CustomTabsApi#get\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end

    # Gets a list of all account tabs.
    # Retrieves a list of all tabs associated with the account.
    # @param account_id The external account number (int) or account ID Guid.
    # @param DocuSign_eSign::ListOptions Options for modifying the behavior of the function.
    # @return [TabMetadataList]
    def list(account_id, options = DocuSign_eSign::ListOptions.default)
      data, _status_code, _headers = list_with_http_info(account_id, options)
      return data
    end

    # Gets a list of all account tabs.
    # Retrieves a list of all tabs associated with the account.
    # @param account_id The external account number (int) or account ID Guid.
    # @param DocuSign_eSign::ListOptions Options for modifying the behavior of the function.
    # @return [Array<(TabMetadataList, Fixnum, Hash)>] TabMetadataList data, response status code and response headers
    def list_with_http_info(account_id, options = DocuSign_eSign::ListOptions.default)
      if @api_client.config.debugging
        @api_client.config.logger.debug "Calling API: CustomTabsApi.list ..."
      end
      # verify the required parameter 'account_id' is set
      fail ArgumentError, "Missing the required parameter 'account_id' when calling CustomTabsApi.list" if account_id.nil?
      # resource path
      local_var_path = "/v2.1/accounts/{accountId}/tab_definitions".sub('{format}','json').sub('{' + 'accountId' + '}', account_id.to_s)

      # query parameters
      query_params = {}
      query_params[:'custom_tab_only'] = options.custom_tab_only if !options.custom_tab_only.nil?

      # header parameters
      header_params = {}
      # HTTP header 'Accept' (if needed)
      header_params['Accept'] = @api_client.select_header_accept(['application/json'])

      # form parameters
      form_params = {}

      # http body (model)
      post_body = nil
      auth_names = []
      data, status_code, headers = @api_client.call_api(:GET, local_var_path,
        :header_params => header_params,
        :query_params => query_params,
        :form_params => form_params,
        :body => post_body,
        :auth_names => auth_names,
        :return_type => 'TabMetadataList')
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: CustomTabsApi#list\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end

    # Updates custom tab information.  
    # Updates the information in a custom tab for the specified account.
    # @param account_id The external account number (int) or account ID Guid.
    # @param custom_tab_id 
    # @param tab_metadata  (optional parameter)
    # @return [TabMetadata]
    def update(account_id, custom_tab_id, tab_metadata)
      data, _status_code, _headers = update_with_http_info(account_id, custom_tab_id,  tab_metadata)
      return data
    end

    # Updates custom tab information.  
    # Updates the information in a custom tab for the specified account.
    # @param account_id The external account number (int) or account ID Guid.
    # @param custom_tab_id 
    # @param tab_metadata  (optional parameter)
    # @return [Array<(TabMetadata, Fixnum, Hash)>] TabMetadata data, response status code and response headers
    def update_with_http_info(account_id, custom_tab_id, tab_metadata)
      if @api_client.config.debugging
        @api_client.config.logger.debug "Calling API: CustomTabsApi.update ..."
      end
      # verify the required parameter 'account_id' is set
      fail ArgumentError, "Missing the required parameter 'account_id' when calling CustomTabsApi.update" if account_id.nil?
      # verify the required parameter 'custom_tab_id' is set
      fail ArgumentError, "Missing the required parameter 'custom_tab_id' when calling CustomTabsApi.update" if custom_tab_id.nil?
      # resource path
      local_var_path = "/v2.1/accounts/{accountId}/tab_definitions/{customTabId}".sub('{format}','json').sub('{' + 'accountId' + '}', account_id.to_s).sub('{' + 'customTabId' + '}', custom_tab_id.to_s)

      # query parameters
      query_params = {}

      # header parameters
      header_params = {}
      # HTTP header 'Accept' (if needed)
      header_params['Accept'] = @api_client.select_header_accept(['application/json'])

      # form parameters
      form_params = {}

      # http body (model)
      post_body = @api_client.object_to_http_body(tab_metadata)
      auth_names = []
      data, status_code, headers = @api_client.call_api(:PUT, local_var_path,
        :header_params => header_params,
        :query_params => query_params,
        :form_params => form_params,
        :body => post_body,
        :auth_names => auth_names,
        :return_type => 'TabMetadata')
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: CustomTabsApi#update\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end
  end
end