=begin #Dropbox Sign API #Dropbox Sign v3 API The version of the OpenAPI document: 3.0.0 Contact: apisupport@hellosign.com Generated by: https://openapi-generator.tech OpenAPI Generator version: 5.3.0 =end require 'cgi' module Dropbox end module Dropbox::Sign class TemplateApi attr_accessor :api_client def initialize(api_client = ApiClient.default) @api_client = api_client end # Add User to Template # Gives the specified Account access to the specified Template. The specified Account must be a part of your Team. # @param template_id [String] The id of the Template to give the Account access to. # @param template_add_user_request [TemplateAddUserRequest] # @param [Hash] opts the optional parameters # @return [TemplateGetResponse] def template_add_user(template_id, template_add_user_request, opts = {}) data, _status_code, _headers = template_add_user_with_http_info(template_id, template_add_user_request, opts) data end # Add User to Template # Gives the specified Account access to the specified Template. The specified Account must be a part of your Team. # @param template_id [String] The id of the Template to give the Account access to. # @param template_add_user_request [TemplateAddUserRequest] # @param [Hash] opts the optional parameters # @return [Array<(TemplateGetResponse, Integer, Hash)>] TemplateGetResponse data, response status code and response headers def template_add_user_with_http_info(template_id, template_add_user_request, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: TemplateApi.template_add_user ...' end # verify the required parameter 'template_id' is set if @api_client.config.client_side_validation && template_id.nil? fail ArgumentError, "Missing the required parameter 'template_id' when calling TemplateApi.template_add_user" end # verify the required parameter 'template_add_user_request' is set if @api_client.config.client_side_validation && template_add_user_request.nil? fail ArgumentError, "Missing the required parameter 'template_add_user_request' when calling TemplateApi.template_add_user" end # resource path local_var_path = '/template/add_user/{template_id}'.sub('{' + 'template_id' + '}', CGI.escape(template_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' content_type = @api_client.select_header_content_type(['application/json']) if !content_type.nil? header_params['Content-Type'] = content_type end post_body = {} form_params = opts[:form_params] || {} result = @api_client.generate_form_data( template_add_user_request, Dropbox::Sign::TemplateAddUserRequest.openapi_types ) # form parameters if result[:has_file] form_params = opts[:form_params] || result[:params] header_params['Content-Type'] = 'multipart/form-data' else # http body (model) post_body = opts[:debug_body] || result[:params] end # return_type return_type = opts[:debug_return_type] || 'TemplateGetResponse' # auth_names auth_names = opts[:debug_auth_names] || ['api_key', 'oauth2'] new_options = opts.merge( :operation => :"TemplateApi.template_add_user", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) begin data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options) rescue Dropbox::Sign::ApiError => e if e.code === 200 body = @api_client.convert_to_type( JSON.parse("[#{e.response_body}]", :symbolize_names => true)[0], "Dropbox::Sign::TemplateGetResponse" ) fail ApiError.new(:code => e.code, :response_headers => e.response_headers, :response_body => body), e.message end range_code = "4XX".split('').first range_code_left = "#{range_code}00".to_i range_code_right = "#{range_code}99".to_i if e.code >= range_code_left && e.code <= range_code_right body = @api_client.convert_to_type( JSON.parse("[#{e.response_body}]", :symbolize_names => true)[0], "Dropbox::Sign::ErrorResponse" ) fail ApiError.new(:code => e.code, :response_headers => e.response_headers, :response_body => body), e.message end end if @api_client.config.debugging @api_client.config.logger.debug "API called: TemplateApi#template_add_user\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Create Embedded Template Draft # The first step in an embedded template workflow. Creates a draft template that can then be further set up in the template 'edit' stage. # @param template_create_embedded_draft_request [TemplateCreateEmbeddedDraftRequest] # @param [Hash] opts the optional parameters # @return [TemplateCreateEmbeddedDraftResponse] def template_create_embedded_draft(template_create_embedded_draft_request, opts = {}) data, _status_code, _headers = template_create_embedded_draft_with_http_info(template_create_embedded_draft_request, opts) data end # Create Embedded Template Draft # The first step in an embedded template workflow. Creates a draft template that can then be further set up in the template 'edit' stage. # @param template_create_embedded_draft_request [TemplateCreateEmbeddedDraftRequest] # @param [Hash] opts the optional parameters # @return [Array<(TemplateCreateEmbeddedDraftResponse, Integer, Hash)>] TemplateCreateEmbeddedDraftResponse data, response status code and response headers def template_create_embedded_draft_with_http_info(template_create_embedded_draft_request, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: TemplateApi.template_create_embedded_draft ...' end # verify the required parameter 'template_create_embedded_draft_request' is set if @api_client.config.client_side_validation && template_create_embedded_draft_request.nil? fail ArgumentError, "Missing the required parameter 'template_create_embedded_draft_request' when calling TemplateApi.template_create_embedded_draft" end # resource path local_var_path = '/template/create_embedded_draft' # 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' content_type = @api_client.select_header_content_type(['application/json', 'multipart/form-data']) if !content_type.nil? header_params['Content-Type'] = content_type end post_body = {} form_params = opts[:form_params] || {} result = @api_client.generate_form_data( template_create_embedded_draft_request, Dropbox::Sign::TemplateCreateEmbeddedDraftRequest.openapi_types ) # form parameters if result[:has_file] form_params = opts[:form_params] || result[:params] header_params['Content-Type'] = 'multipart/form-data' else # http body (model) post_body = opts[:debug_body] || result[:params] end # return_type return_type = opts[:debug_return_type] || 'TemplateCreateEmbeddedDraftResponse' # auth_names auth_names = opts[:debug_auth_names] || ['api_key', 'oauth2'] new_options = opts.merge( :operation => :"TemplateApi.template_create_embedded_draft", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) begin data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options) rescue Dropbox::Sign::ApiError => e if e.code === 200 body = @api_client.convert_to_type( JSON.parse("[#{e.response_body}]", :symbolize_names => true)[0], "Dropbox::Sign::TemplateCreateEmbeddedDraftResponse" ) fail ApiError.new(:code => e.code, :response_headers => e.response_headers, :response_body => body), e.message end range_code = "4XX".split('').first range_code_left = "#{range_code}00".to_i range_code_right = "#{range_code}99".to_i if e.code >= range_code_left && e.code <= range_code_right body = @api_client.convert_to_type( JSON.parse("[#{e.response_body}]", :symbolize_names => true)[0], "Dropbox::Sign::ErrorResponse" ) fail ApiError.new(:code => e.code, :response_headers => e.response_headers, :response_body => body), e.message end end if @api_client.config.debugging @api_client.config.logger.debug "API called: TemplateApi#template_create_embedded_draft\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Delete Template # Completely deletes the template specified from the account. # @param template_id [String] The id of the Template to delete. # @param [Hash] opts the optional parameters # @return [nil] def template_delete(template_id, opts = {}) template_delete_with_http_info(template_id, opts) nil end # Delete Template # Completely deletes the template specified from the account. # @param template_id [String] The id of the Template to delete. # @param [Hash] opts the optional parameters # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers def template_delete_with_http_info(template_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: TemplateApi.template_delete ...' end # verify the required parameter 'template_id' is set if @api_client.config.client_side_validation && template_id.nil? fail ArgumentError, "Missing the required parameter 'template_id' when calling TemplateApi.template_delete" end # resource path local_var_path = '/template/delete/{template_id}'.sub('{' + 'template_id' + '}', CGI.escape(template_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']) post_body = {} 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] || ['api_key', 'oauth2'] new_options = opts.merge( :operation => :"TemplateApi.template_delete", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) begin data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options) rescue Dropbox::Sign::ApiError => e end if @api_client.config.debugging @api_client.config.logger.debug "API called: TemplateApi#template_delete\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Get Template Files # Obtain a copy of the current documents specified by the `template_id` parameter. Returns a PDF or ZIP file. If the files are currently being prepared, a status code of `409` will be returned instead. In this case please wait for the `template_created` callback event. # @param template_id [String] The id of the template files to retrieve. # @param [Hash] opts the optional parameters # @option opts [String] :file_type Set to `pdf` for a single merged document or `zip` for a collection of individual documents. # @return [File] def template_files(template_id, opts = {}) data, _status_code, _headers = template_files_with_http_info(template_id, opts) data end # Get Template Files # Obtain a copy of the current documents specified by the `template_id` parameter. Returns a PDF or ZIP file. If the files are currently being prepared, a status code of `409` will be returned instead. In this case please wait for the `template_created` callback event. # @param template_id [String] The id of the template files to retrieve. # @param [Hash] opts the optional parameters # @option opts [String] :file_type Set to `pdf` for a single merged document or `zip` for a collection of individual documents. # @return [Array<(File, Integer, Hash)>] File data, response status code and response headers def template_files_with_http_info(template_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: TemplateApi.template_files ...' end # verify the required parameter 'template_id' is set if @api_client.config.client_side_validation && template_id.nil? fail ArgumentError, "Missing the required parameter 'template_id' when calling TemplateApi.template_files" end allowable_values = ["pdf", "zip"] if @api_client.config.client_side_validation && opts[:'file_type'] && !allowable_values.include?(opts[:'file_type']) fail ArgumentError, "invalid value for \"file_type\", must be one of #{allowable_values}" end # resource path local_var_path = '/template/files/{template_id}'.sub('{' + 'template_id' + '}', CGI.escape(template_id.to_s)) # query parameters query_params = opts[:query_params] || {} query_params[:'file_type'] = opts[:'file_type'] if !opts[:'file_type'].nil? # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/pdf', 'application/zip', 'application/json']) post_body = {} form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] || 'File' # auth_names auth_names = opts[:debug_auth_names] || ['api_key', 'oauth2'] new_options = opts.merge( :operation => :"TemplateApi.template_files", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) begin data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options) rescue Dropbox::Sign::ApiError => e if e.code === 200 body = @api_client.convert_to_type( JSON.parse("[#{e.response_body}]", :symbolize_names => true)[0], "Dropbox::Sign::File" ) fail ApiError.new(:code => e.code, :response_headers => e.response_headers, :response_body => body), e.message end range_code = "4XX".split('').first range_code_left = "#{range_code}00".to_i range_code_right = "#{range_code}99".to_i if e.code >= range_code_left && e.code <= range_code_right body = @api_client.convert_to_type( JSON.parse("[#{e.response_body}]", :symbolize_names => true)[0], "Dropbox::Sign::ErrorResponse" ) fail ApiError.new(:code => e.code, :response_headers => e.response_headers, :response_body => body), e.message end end if @api_client.config.debugging @api_client.config.logger.debug "API called: TemplateApi#template_files\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Get Template Files as Data Uri # Obtain a copy of the current documents specified by the `template_id` parameter. Returns a JSON object with a `data_uri` representing the base64 encoded file (PDFs only). If the files are currently being prepared, a status code of `409` will be returned instead. In this case please wait for the `template_created` callback event. # @param template_id [String] The id of the template files to retrieve. # @param [Hash] opts the optional parameters # @return [FileResponseDataUri] def template_files_as_data_uri(template_id, opts = {}) data, _status_code, _headers = template_files_as_data_uri_with_http_info(template_id, opts) data end # Get Template Files as Data Uri # Obtain a copy of the current documents specified by the `template_id` parameter. Returns a JSON object with a `data_uri` representing the base64 encoded file (PDFs only). If the files are currently being prepared, a status code of `409` will be returned instead. In this case please wait for the `template_created` callback event. # @param template_id [String] The id of the template files to retrieve. # @param [Hash] opts the optional parameters # @return [Array<(FileResponseDataUri, Integer, Hash)>] FileResponseDataUri data, response status code and response headers def template_files_as_data_uri_with_http_info(template_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: TemplateApi.template_files_as_data_uri ...' end # verify the required parameter 'template_id' is set if @api_client.config.client_side_validation && template_id.nil? fail ArgumentError, "Missing the required parameter 'template_id' when calling TemplateApi.template_files_as_data_uri" end # resource path local_var_path = '/template/files_as_data_uri/{template_id}'.sub('{' + 'template_id' + '}', CGI.escape(template_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']) post_body = {} form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] || 'FileResponseDataUri' # auth_names auth_names = opts[:debug_auth_names] || ['api_key', 'oauth2'] new_options = opts.merge( :operation => :"TemplateApi.template_files_as_data_uri", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) begin data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options) rescue Dropbox::Sign::ApiError => e if e.code === 200 body = @api_client.convert_to_type( JSON.parse("[#{e.response_body}]", :symbolize_names => true)[0], "Dropbox::Sign::FileResponseDataUri" ) fail ApiError.new(:code => e.code, :response_headers => e.response_headers, :response_body => body), e.message end range_code = "4XX".split('').first range_code_left = "#{range_code}00".to_i range_code_right = "#{range_code}99".to_i if e.code >= range_code_left && e.code <= range_code_right body = @api_client.convert_to_type( JSON.parse("[#{e.response_body}]", :symbolize_names => true)[0], "Dropbox::Sign::ErrorResponse" ) fail ApiError.new(:code => e.code, :response_headers => e.response_headers, :response_body => body), e.message end end if @api_client.config.debugging @api_client.config.logger.debug "API called: TemplateApi#template_files_as_data_uri\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Get Template Files as File Url # Obtain a copy of the current documents specified by the `template_id` parameter. Returns a JSON object with a url to the file (PDFs only). If the files are currently being prepared, a status code of `409` will be returned instead. In this case please wait for the `template_created` callback event. # @param template_id [String] The id of the template files to retrieve. # @param [Hash] opts the optional parameters # @return [FileResponse] def template_files_as_file_url(template_id, opts = {}) data, _status_code, _headers = template_files_as_file_url_with_http_info(template_id, opts) data end # Get Template Files as File Url # Obtain a copy of the current documents specified by the `template_id` parameter. Returns a JSON object with a url to the file (PDFs only). If the files are currently being prepared, a status code of `409` will be returned instead. In this case please wait for the `template_created` callback event. # @param template_id [String] The id of the template files to retrieve. # @param [Hash] opts the optional parameters # @return [Array<(FileResponse, Integer, Hash)>] FileResponse data, response status code and response headers def template_files_as_file_url_with_http_info(template_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: TemplateApi.template_files_as_file_url ...' end # verify the required parameter 'template_id' is set if @api_client.config.client_side_validation && template_id.nil? fail ArgumentError, "Missing the required parameter 'template_id' when calling TemplateApi.template_files_as_file_url" end # resource path local_var_path = '/template/files_as_file_url/{template_id}'.sub('{' + 'template_id' + '}', CGI.escape(template_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']) post_body = {} form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] || 'FileResponse' # auth_names auth_names = opts[:debug_auth_names] || ['api_key', 'oauth2'] new_options = opts.merge( :operation => :"TemplateApi.template_files_as_file_url", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) begin data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options) rescue Dropbox::Sign::ApiError => e if e.code === 200 body = @api_client.convert_to_type( JSON.parse("[#{e.response_body}]", :symbolize_names => true)[0], "Dropbox::Sign::FileResponse" ) fail ApiError.new(:code => e.code, :response_headers => e.response_headers, :response_body => body), e.message end range_code = "4XX".split('').first range_code_left = "#{range_code}00".to_i range_code_right = "#{range_code}99".to_i if e.code >= range_code_left && e.code <= range_code_right body = @api_client.convert_to_type( JSON.parse("[#{e.response_body}]", :symbolize_names => true)[0], "Dropbox::Sign::ErrorResponse" ) fail ApiError.new(:code => e.code, :response_headers => e.response_headers, :response_body => body), e.message end end if @api_client.config.debugging @api_client.config.logger.debug "API called: TemplateApi#template_files_as_file_url\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Get Template # Returns the Template specified by the `template_id` parameter. # @param template_id [String] The id of the Template to retrieve. # @param [Hash] opts the optional parameters # @return [TemplateGetResponse] def template_get(template_id, opts = {}) data, _status_code, _headers = template_get_with_http_info(template_id, opts) data end # Get Template # Returns the Template specified by the `template_id` parameter. # @param template_id [String] The id of the Template to retrieve. # @param [Hash] opts the optional parameters # @return [Array<(TemplateGetResponse, Integer, Hash)>] TemplateGetResponse data, response status code and response headers def template_get_with_http_info(template_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: TemplateApi.template_get ...' end # verify the required parameter 'template_id' is set if @api_client.config.client_side_validation && template_id.nil? fail ArgumentError, "Missing the required parameter 'template_id' when calling TemplateApi.template_get" end # resource path local_var_path = '/template/{template_id}'.sub('{' + 'template_id' + '}', CGI.escape(template_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']) post_body = {} form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] || 'TemplateGetResponse' # auth_names auth_names = opts[:debug_auth_names] || ['api_key', 'oauth2'] new_options = opts.merge( :operation => :"TemplateApi.template_get", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) begin data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options) rescue Dropbox::Sign::ApiError => e if e.code === 200 body = @api_client.convert_to_type( JSON.parse("[#{e.response_body}]", :symbolize_names => true)[0], "Dropbox::Sign::TemplateGetResponse" ) fail ApiError.new(:code => e.code, :response_headers => e.response_headers, :response_body => body), e.message end range_code = "4XX".split('').first range_code_left = "#{range_code}00".to_i range_code_right = "#{range_code}99".to_i if e.code >= range_code_left && e.code <= range_code_right body = @api_client.convert_to_type( JSON.parse("[#{e.response_body}]", :symbolize_names => true)[0], "Dropbox::Sign::ErrorResponse" ) fail ApiError.new(:code => e.code, :response_headers => e.response_headers, :response_body => body), e.message end end if @api_client.config.debugging @api_client.config.logger.debug "API called: TemplateApi#template_get\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # List Templates # Returns a list of the Templates that are accessible by you. Take a look at our [search guide](/api/reference/search/) to learn more about querying templates. # @param [Hash] opts the optional parameters # @option opts [String] :account_id Which account to return Templates for. Must be a team member. Use `all` to indicate all team members. Defaults to your account. # @option opts [Integer] :page Which page number of the Template List to return. Defaults to `1`. (default to 1) # @option opts [Integer] :page_size Number of objects to be returned per page. Must be between `1` and `100`. Default is `20`. (default to 20) # @option opts [String] :query String that includes search terms and/or fields to be used to filter the Template objects. # @return [TemplateListResponse] def template_list(opts = {}) data, _status_code, _headers = template_list_with_http_info(opts) data end # List Templates # Returns a list of the Templates that are accessible by you. Take a look at our [search guide](/api/reference/search/) to learn more about querying templates. # @param [Hash] opts the optional parameters # @option opts [String] :account_id Which account to return Templates for. Must be a team member. Use `all` to indicate all team members. Defaults to your account. # @option opts [Integer] :page Which page number of the Template List to return. Defaults to `1`. # @option opts [Integer] :page_size Number of objects to be returned per page. Must be between `1` and `100`. Default is `20`. # @option opts [String] :query String that includes search terms and/or fields to be used to filter the Template objects. # @return [Array<(TemplateListResponse, Integer, Hash)>] TemplateListResponse data, response status code and response headers def template_list_with_http_info(opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: TemplateApi.template_list ...' end if @api_client.config.client_side_validation && !opts[:'page_size'].nil? && opts[:'page_size'] > 100 fail ArgumentError, 'invalid value for "opts[:"page_size"]" when calling TemplateApi.template_list, must be smaller than or equal to 100.' end if @api_client.config.client_side_validation && !opts[:'page_size'].nil? && opts[:'page_size'] < 1 fail ArgumentError, 'invalid value for "opts[:"page_size"]" when calling TemplateApi.template_list, must be greater than or equal to 1.' end # resource path local_var_path = '/template/list' # query parameters query_params = opts[:query_params] || {} query_params[:'account_id'] = opts[:'account_id'] if !opts[:'account_id'].nil? query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil? query_params[:'page_size'] = opts[:'page_size'] if !opts[:'page_size'].nil? query_params[:'query'] = opts[:'query'] if !opts[:'query'].nil? # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) post_body = {} form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] || 'TemplateListResponse' # auth_names auth_names = opts[:debug_auth_names] || ['api_key', 'oauth2'] new_options = opts.merge( :operation => :"TemplateApi.template_list", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) begin data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options) rescue Dropbox::Sign::ApiError => e if e.code === 200 body = @api_client.convert_to_type( JSON.parse("[#{e.response_body}]", :symbolize_names => true)[0], "Dropbox::Sign::TemplateListResponse" ) fail ApiError.new(:code => e.code, :response_headers => e.response_headers, :response_body => body), e.message end range_code = "4XX".split('').first range_code_left = "#{range_code}00".to_i range_code_right = "#{range_code}99".to_i if e.code >= range_code_left && e.code <= range_code_right body = @api_client.convert_to_type( JSON.parse("[#{e.response_body}]", :symbolize_names => true)[0], "Dropbox::Sign::ErrorResponse" ) fail ApiError.new(:code => e.code, :response_headers => e.response_headers, :response_body => body), e.message end end if @api_client.config.debugging @api_client.config.logger.debug "API called: TemplateApi#template_list\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Remove User from Template # Removes the specified Account's access to the specified Template. # @param template_id [String] The id of the Template to remove the Account's access to. # @param template_remove_user_request [TemplateRemoveUserRequest] # @param [Hash] opts the optional parameters # @return [TemplateGetResponse] def template_remove_user(template_id, template_remove_user_request, opts = {}) data, _status_code, _headers = template_remove_user_with_http_info(template_id, template_remove_user_request, opts) data end # Remove User from Template # Removes the specified Account's access to the specified Template. # @param template_id [String] The id of the Template to remove the Account's access to. # @param template_remove_user_request [TemplateRemoveUserRequest] # @param [Hash] opts the optional parameters # @return [Array<(TemplateGetResponse, Integer, Hash)>] TemplateGetResponse data, response status code and response headers def template_remove_user_with_http_info(template_id, template_remove_user_request, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: TemplateApi.template_remove_user ...' end # verify the required parameter 'template_id' is set if @api_client.config.client_side_validation && template_id.nil? fail ArgumentError, "Missing the required parameter 'template_id' when calling TemplateApi.template_remove_user" end # verify the required parameter 'template_remove_user_request' is set if @api_client.config.client_side_validation && template_remove_user_request.nil? fail ArgumentError, "Missing the required parameter 'template_remove_user_request' when calling TemplateApi.template_remove_user" end # resource path local_var_path = '/template/remove_user/{template_id}'.sub('{' + 'template_id' + '}', CGI.escape(template_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' content_type = @api_client.select_header_content_type(['application/json']) if !content_type.nil? header_params['Content-Type'] = content_type end post_body = {} form_params = opts[:form_params] || {} result = @api_client.generate_form_data( template_remove_user_request, Dropbox::Sign::TemplateRemoveUserRequest.openapi_types ) # form parameters if result[:has_file] form_params = opts[:form_params] || result[:params] header_params['Content-Type'] = 'multipart/form-data' else # http body (model) post_body = opts[:debug_body] || result[:params] end # return_type return_type = opts[:debug_return_type] || 'TemplateGetResponse' # auth_names auth_names = opts[:debug_auth_names] || ['api_key', 'oauth2'] new_options = opts.merge( :operation => :"TemplateApi.template_remove_user", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) begin data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options) rescue Dropbox::Sign::ApiError => e if e.code === 200 body = @api_client.convert_to_type( JSON.parse("[#{e.response_body}]", :symbolize_names => true)[0], "Dropbox::Sign::TemplateGetResponse" ) fail ApiError.new(:code => e.code, :response_headers => e.response_headers, :response_body => body), e.message end range_code = "4XX".split('').first range_code_left = "#{range_code}00".to_i range_code_right = "#{range_code}99".to_i if e.code >= range_code_left && e.code <= range_code_right body = @api_client.convert_to_type( JSON.parse("[#{e.response_body}]", :symbolize_names => true)[0], "Dropbox::Sign::ErrorResponse" ) fail ApiError.new(:code => e.code, :response_headers => e.response_headers, :response_body => body), e.message end end if @api_client.config.debugging @api_client.config.logger.debug "API called: TemplateApi#template_remove_user\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Update Template Files # Overlays a new file with the overlay of an existing template. The new file(s) must: 1. have the same or higher page count 2. the same orientation as the file(s) being replaced. This will not overwrite or in any way affect the existing template. Both the existing template and new template will be available for use after executing this endpoint. Also note that this will decrement your template quota. Overlaying new files is asynchronous and a successful call to this endpoint will return 200 OK response if the request passes initial validation checks. It is recommended that a callback be implemented to listen for the callback event. A `template_created` event will be sent when the files are updated or a `template_error` event will be sent if there was a problem while updating the files. If a callback handler has been configured and the event has not been received within 60 minutes of making the call, check the status of the request in the API dashboard and retry the request if necessary. If the page orientation or page count is different from the original template document, we will notify you with a `template_error` [callback event](https://app.hellosign.com/api/eventsAndCallbacksWalkthrough). # @param template_id [String] The ID of the template whose files to update. # @param template_update_files_request [TemplateUpdateFilesRequest] # @param [Hash] opts the optional parameters # @return [TemplateUpdateFilesResponse] def template_update_files(template_id, template_update_files_request, opts = {}) data, _status_code, _headers = template_update_files_with_http_info(template_id, template_update_files_request, opts) data end # Update Template Files # Overlays a new file with the overlay of an existing template. The new file(s) must: 1. have the same or higher page count 2. the same orientation as the file(s) being replaced. This will not overwrite or in any way affect the existing template. Both the existing template and new template will be available for use after executing this endpoint. Also note that this will decrement your template quota. Overlaying new files is asynchronous and a successful call to this endpoint will return 200 OK response if the request passes initial validation checks. It is recommended that a callback be implemented to listen for the callback event. A `template_created` event will be sent when the files are updated or a `template_error` event will be sent if there was a problem while updating the files. If a callback handler has been configured and the event has not been received within 60 minutes of making the call, check the status of the request in the API dashboard and retry the request if necessary. If the page orientation or page count is different from the original template document, we will notify you with a `template_error` [callback event](https://app.hellosign.com/api/eventsAndCallbacksWalkthrough). # @param template_id [String] The ID of the template whose files to update. # @param template_update_files_request [TemplateUpdateFilesRequest] # @param [Hash] opts the optional parameters # @return [Array<(TemplateUpdateFilesResponse, Integer, Hash)>] TemplateUpdateFilesResponse data, response status code and response headers def template_update_files_with_http_info(template_id, template_update_files_request, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: TemplateApi.template_update_files ...' end # verify the required parameter 'template_id' is set if @api_client.config.client_side_validation && template_id.nil? fail ArgumentError, "Missing the required parameter 'template_id' when calling TemplateApi.template_update_files" end # verify the required parameter 'template_update_files_request' is set if @api_client.config.client_side_validation && template_update_files_request.nil? fail ArgumentError, "Missing the required parameter 'template_update_files_request' when calling TemplateApi.template_update_files" end # resource path local_var_path = '/template/update_files/{template_id}'.sub('{' + 'template_id' + '}', CGI.escape(template_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' content_type = @api_client.select_header_content_type(['application/json', 'multipart/form-data']) if !content_type.nil? header_params['Content-Type'] = content_type end post_body = {} form_params = opts[:form_params] || {} result = @api_client.generate_form_data( template_update_files_request, Dropbox::Sign::TemplateUpdateFilesRequest.openapi_types ) # form parameters if result[:has_file] form_params = opts[:form_params] || result[:params] header_params['Content-Type'] = 'multipart/form-data' else # http body (model) post_body = opts[:debug_body] || result[:params] end # return_type return_type = opts[:debug_return_type] || 'TemplateUpdateFilesResponse' # auth_names auth_names = opts[:debug_auth_names] || ['api_key', 'oauth2'] new_options = opts.merge( :operation => :"TemplateApi.template_update_files", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) begin data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options) rescue Dropbox::Sign::ApiError => e if e.code === 200 body = @api_client.convert_to_type( JSON.parse("[#{e.response_body}]", :symbolize_names => true)[0], "Dropbox::Sign::TemplateUpdateFilesResponse" ) fail ApiError.new(:code => e.code, :response_headers => e.response_headers, :response_body => body), e.message end range_code = "4XX".split('').first range_code_left = "#{range_code}00".to_i range_code_right = "#{range_code}99".to_i if e.code >= range_code_left && e.code <= range_code_right body = @api_client.convert_to_type( JSON.parse("[#{e.response_body}]", :symbolize_names => true)[0], "Dropbox::Sign::ErrorResponse" ) fail ApiError.new(:code => e.code, :response_headers => e.response_headers, :response_body => body), e.message end end if @api_client.config.debugging @api_client.config.logger.debug "API called: TemplateApi#template_update_files\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end end end