=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 Generator version: 7.7.0 =end require 'cgi' module Dropbox end module Dropbox::Sign class OAuthApi attr_accessor :api_client def initialize(api_client = ApiClient.default) @api_client = api_client end # OAuth Token Generate # Once you have retrieved the code from the user callback, you will need to exchange it for an access token via a backend call. # @param o_auth_token_generate_request [OAuthTokenGenerateRequest] # @param [Hash] opts the optional parameters # @return [OAuthTokenResponse] def oauth_token_generate(o_auth_token_generate_request, opts = {}) data, _status_code, _headers = oauth_token_generate_with_http_info(o_auth_token_generate_request, opts) data end # OAuth Token Generate # Once you have retrieved the code from the user callback, you will need to exchange it for an access token via a backend call. # @param o_auth_token_generate_request [OAuthTokenGenerateRequest] # @param [Hash] opts the optional parameters # @return [Array<(OAuthTokenResponse, Integer, Hash)>] OAuthTokenResponse data, response status code and response headers def oauth_token_generate_with_http_info(o_auth_token_generate_request, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: OAuthApi.oauth_token_generate ...' end # verify the required parameter 'o_auth_token_generate_request' is set if @api_client.config.client_side_validation && o_auth_token_generate_request.nil? fail ArgumentError, "Missing the required parameter 'o_auth_token_generate_request' when calling OAuthApi.oauth_token_generate" end # resource path local_var_path = '/oauth/token' # 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( o_auth_token_generate_request, Dropbox::Sign::OAuthTokenGenerateRequest.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] || 'OAuthTokenResponse' # auth_names auth_names = opts[:debug_auth_names] || [] new_options = opts.merge( :operation => :"OAuthApi.oauth_token_generate", :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::OAuthTokenResponse" ) 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: OAuthApi#oauth_token_generate\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # OAuth Token Refresh # Access tokens are only valid for a given period of time (typically one hour) for security reasons. Whenever acquiring an new access token its TTL is also given (see `expires_in`), along with a refresh token that can be used to acquire a new access token after the current one has expired. # @param o_auth_token_refresh_request [OAuthTokenRefreshRequest] # @param [Hash] opts the optional parameters # @return [OAuthTokenResponse] def oauth_token_refresh(o_auth_token_refresh_request, opts = {}) data, _status_code, _headers = oauth_token_refresh_with_http_info(o_auth_token_refresh_request, opts) data end # OAuth Token Refresh # Access tokens are only valid for a given period of time (typically one hour) for security reasons. Whenever acquiring an new access token its TTL is also given (see `expires_in`), along with a refresh token that can be used to acquire a new access token after the current one has expired. # @param o_auth_token_refresh_request [OAuthTokenRefreshRequest] # @param [Hash] opts the optional parameters # @return [Array<(OAuthTokenResponse, Integer, Hash)>] OAuthTokenResponse data, response status code and response headers def oauth_token_refresh_with_http_info(o_auth_token_refresh_request, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: OAuthApi.oauth_token_refresh ...' end # verify the required parameter 'o_auth_token_refresh_request' is set if @api_client.config.client_side_validation && o_auth_token_refresh_request.nil? fail ArgumentError, "Missing the required parameter 'o_auth_token_refresh_request' when calling OAuthApi.oauth_token_refresh" end # resource path local_var_path = '/oauth/token?refresh' # 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( o_auth_token_refresh_request, Dropbox::Sign::OAuthTokenRefreshRequest.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] || 'OAuthTokenResponse' # auth_names auth_names = opts[:debug_auth_names] || [] new_options = opts.merge( :operation => :"OAuthApi.oauth_token_refresh", :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::OAuthTokenResponse" ) 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: OAuthApi#oauth_token_refresh\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end end end