=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 ApiAppApi attr_accessor :api_client def initialize(api_client = ApiClient.default) @api_client = api_client end # Create API App # Creates a new API App. # @param api_app_create_request [ApiAppCreateRequest] # @param [Hash] opts the optional parameters # @return [ApiAppGetResponse] def api_app_create(api_app_create_request, opts = {}) data, _status_code, _headers = api_app_create_with_http_info(api_app_create_request, opts) data end # Create API App # Creates a new API App. # @param api_app_create_request [ApiAppCreateRequest] # @param [Hash] opts the optional parameters # @return [Array<(ApiAppGetResponse, Integer, Hash)>] ApiAppGetResponse data, response status code and response headers def api_app_create_with_http_info(api_app_create_request, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: ApiAppApi.api_app_create ...' end # verify the required parameter 'api_app_create_request' is set if @api_client.config.client_side_validation && api_app_create_request.nil? fail ArgumentError, "Missing the required parameter 'api_app_create_request' when calling ApiAppApi.api_app_create" end # resource path local_var_path = '/api_app' # 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( api_app_create_request, Dropbox::Sign::ApiAppCreateRequest.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] || 'ApiAppGetResponse' # auth_names auth_names = opts[:debug_auth_names] || ['api_key', 'oauth2'] new_options = opts.merge( :operation => :"ApiAppApi.api_app_create", :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 === 201 body = @api_client.convert_to_type( JSON.parse("[#{e.response_body}]", :symbolize_names => true)[0], "Dropbox::Sign::ApiAppGetResponse" ) 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: ApiAppApi#api_app_create\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Delete API App # Deletes an API App. Can only be invoked for apps you own. # @param client_id [String] The client id of the API App to delete. # @param [Hash] opts the optional parameters # @return [nil] def api_app_delete(client_id, opts = {}) api_app_delete_with_http_info(client_id, opts) nil end # Delete API App # Deletes an API App. Can only be invoked for apps you own. # @param client_id [String] The client id of the API App to delete. # @param [Hash] opts the optional parameters # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers def api_app_delete_with_http_info(client_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: ApiAppApi.api_app_delete ...' end # verify the required parameter 'client_id' is set if @api_client.config.client_side_validation && client_id.nil? fail ArgumentError, "Missing the required parameter 'client_id' when calling ApiAppApi.api_app_delete" end # resource path local_var_path = '/api_app/{client_id}'.sub('{' + 'client_id' + '}', CGI.escape(client_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 => :"ApiAppApi.api_app_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(:DELETE, local_var_path, new_options) rescue Dropbox::Sign::ApiError => e end if @api_client.config.debugging @api_client.config.logger.debug "API called: ApiAppApi#api_app_delete\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Get API App # Returns an object with information about an API App. # @param client_id [String] The client id of the API App to retrieve. # @param [Hash] opts the optional parameters # @return [ApiAppGetResponse] def api_app_get(client_id, opts = {}) data, _status_code, _headers = api_app_get_with_http_info(client_id, opts) data end # Get API App # Returns an object with information about an API App. # @param client_id [String] The client id of the API App to retrieve. # @param [Hash] opts the optional parameters # @return [Array<(ApiAppGetResponse, Integer, Hash)>] ApiAppGetResponse data, response status code and response headers def api_app_get_with_http_info(client_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: ApiAppApi.api_app_get ...' end # verify the required parameter 'client_id' is set if @api_client.config.client_side_validation && client_id.nil? fail ArgumentError, "Missing the required parameter 'client_id' when calling ApiAppApi.api_app_get" end # resource path local_var_path = '/api_app/{client_id}'.sub('{' + 'client_id' + '}', CGI.escape(client_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] || 'ApiAppGetResponse' # auth_names auth_names = opts[:debug_auth_names] || ['api_key', 'oauth2'] new_options = opts.merge( :operation => :"ApiAppApi.api_app_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::ApiAppGetResponse" ) 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: ApiAppApi#api_app_get\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # List API Apps # Returns a list of API Apps that are accessible by you. If you are on a team with an Admin or Developer role, this list will include apps owned by teammates. # @param [Hash] opts the optional parameters # @option opts [Integer] :page Which page number of the API App 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) # @return [ApiAppListResponse] def api_app_list(opts = {}) data, _status_code, _headers = api_app_list_with_http_info(opts) data end # List API Apps # Returns a list of API Apps that are accessible by you. If you are on a team with an Admin or Developer role, this list will include apps owned by teammates. # @param [Hash] opts the optional parameters # @option opts [Integer] :page Which page number of the API App 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`. # @return [Array<(ApiAppListResponse, Integer, Hash)>] ApiAppListResponse data, response status code and response headers def api_app_list_with_http_info(opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: ApiAppApi.api_app_list ...' end # resource path local_var_path = '/api_app/list' # query parameters query_params = opts[:query_params] || {} query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil? query_params[:'page_size'] = opts[:'page_size'] if !opts[:'page_size'].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] || 'ApiAppListResponse' # auth_names auth_names = opts[:debug_auth_names] || ['api_key', 'oauth2'] new_options = opts.merge( :operation => :"ApiAppApi.api_app_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::ApiAppListResponse" ) 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: ApiAppApi#api_app_list\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Update API App # Updates an existing API App. Can only be invoked for apps you own. Only the fields you provide will be updated. If you wish to clear an existing optional field, provide an empty string. # @param client_id [String] The client id of the API App to update. # @param api_app_update_request [ApiAppUpdateRequest] # @param [Hash] opts the optional parameters # @return [ApiAppGetResponse] def api_app_update(client_id, api_app_update_request, opts = {}) data, _status_code, _headers = api_app_update_with_http_info(client_id, api_app_update_request, opts) data end # Update API App # Updates an existing API App. Can only be invoked for apps you own. Only the fields you provide will be updated. If you wish to clear an existing optional field, provide an empty string. # @param client_id [String] The client id of the API App to update. # @param api_app_update_request [ApiAppUpdateRequest] # @param [Hash] opts the optional parameters # @return [Array<(ApiAppGetResponse, Integer, Hash)>] ApiAppGetResponse data, response status code and response headers def api_app_update_with_http_info(client_id, api_app_update_request, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: ApiAppApi.api_app_update ...' end # verify the required parameter 'client_id' is set if @api_client.config.client_side_validation && client_id.nil? fail ArgumentError, "Missing the required parameter 'client_id' when calling ApiAppApi.api_app_update" end # verify the required parameter 'api_app_update_request' is set if @api_client.config.client_side_validation && api_app_update_request.nil? fail ArgumentError, "Missing the required parameter 'api_app_update_request' when calling ApiAppApi.api_app_update" end # resource path local_var_path = '/api_app/{client_id}'.sub('{' + 'client_id' + '}', CGI.escape(client_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( api_app_update_request, Dropbox::Sign::ApiAppUpdateRequest.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] || 'ApiAppGetResponse' # auth_names auth_names = opts[:debug_auth_names] || ['api_key', 'oauth2'] new_options = opts.merge( :operation => :"ApiAppApi.api_app_update", :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(:PUT, 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::ApiAppGetResponse" ) 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: ApiAppApi#api_app_update\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end end end