Class: UltracartClient::OauthApi
- Inherits:
-
Object
- Object
- UltracartClient::OauthApi
- Defined in:
- lib/ultracart_api/api/oauth_api.rb
Instance Attribute Summary collapse
-
#api_client ⇒ Object
Returns the value of attribute api_client.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(api_client = ApiClient.default) ⇒ OauthApi
constructor
A new instance of OauthApi.
-
#oauth_access_token(client_id, grant_type, opts = {}) ⇒ OauthTokenResponse
Exchange authorization code for access token.
-
#oauth_access_token_with_http_info(client_id, grant_type, opts = {}) ⇒ Array<(OauthTokenResponse, Fixnum, Hash)>
Exchange authorization code for access token.
-
#oauth_revoke(client_id, token, opts = {}) ⇒ OauthRevokeSuccessResponse
Revoke this OAuth application.
-
#oauth_revoke_with_http_info(client_id, token, opts = {}) ⇒ Array<(OauthRevokeSuccessResponse, Fixnum, Hash)>
Revoke this OAuth application.
Constructor Details
Instance Attribute Details
#api_client ⇒ Object
Returns the value of attribute api_client.
17 18 19 |
# File 'lib/ultracart_api/api/oauth_api.rb', line 17 def api_client @api_client end |
Class Method Details
.new_using_api_key(simple_key, verify_ssl = true, debugging = false) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/ultracart_api/api/oauth_api.rb', line 23 def self.new_using_api_key(simple_key, verify_ssl = true, debugging = false) api_config = Configuration.new api_config.api_key_prefix['x-ultracart-simple-key'] = simple_key api_config.api_version = '2017-03-01' api_config.verify_ssl = verify_ssl api_client = ApiClient.new(api_config) api_client.config.debugging = debugging UltracartClient::OauthApi.new(api_client) end |
Instance Method Details
#oauth_access_token(client_id, grant_type, opts = {}) ⇒ OauthTokenResponse
Exchange authorization code for access token. The final leg in the OAuth process which exchanges the specified access token for the access code needed to make API calls.
44 45 46 47 |
# File 'lib/ultracart_api/api/oauth_api.rb', line 44 def oauth_access_token(client_id, grant_type, opts = {}) data, _status_code, _headers = oauth_access_token_with_http_info(client_id, grant_type, opts) data end |
#oauth_access_token_with_http_info(client_id, grant_type, opts = {}) ⇒ Array<(OauthTokenResponse, Fixnum, Hash)>
Exchange authorization code for access token. The final leg in the OAuth process which exchanges the specified access token for the access code needed to make API calls.
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/ultracart_api/api/oauth_api.rb', line 58 def oauth_access_token_with_http_info(client_id, grant_type, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: OauthApi.oauth_access_token ...' 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 OauthApi.oauth_access_token" end # verify the required parameter 'grant_type' is set if @api_client.config.client_side_validation && grant_type.nil? fail ArgumentError, "Missing the required parameter 'grant_type' when calling OauthApi.oauth_access_token" end # resource path local_var_path = '/oauth/token' # query parameters query_params = {} # header parameters header_params = {} header_params['X-UltraCart-Api-Version'] = @api_client.select_header_api_version() # 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(['application/x-www-form-urlencoded']) # form parameters form_params = {} form_params['client_id'] = client_id form_params['grant_type'] = grant_type form_params['code'] = opts[:'code'] if !opts[:'code'].nil? form_params['redirect_uri'] = opts[:'redirect_uri'] if !opts[:'redirect_uri'].nil? form_params['refresh_token'] = opts[:'refresh_token'] if !opts[:'refresh_token'].nil? # http body (model) post_body = nil auth_names = ['ultraCartBrowserApiKey', 'ultraCartOauth', 'ultraCartSimpleApiKey'] 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 => 'OauthTokenResponse') if @api_client.config.debugging @api_client.config.logger.debug "API called: OauthApi#oauth_access_token\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end |
#oauth_revoke(client_id, token, opts = {}) ⇒ OauthRevokeSuccessResponse
Revoke this OAuth application. Revokes the OAuth application associated with the specified client_id and token.
113 114 115 116 |
# File 'lib/ultracart_api/api/oauth_api.rb', line 113 def oauth_revoke(client_id, token, opts = {}) data, _status_code, _headers = oauth_revoke_with_http_info(client_id, token, opts) data end |
#oauth_revoke_with_http_info(client_id, token, opts = {}) ⇒ Array<(OauthRevokeSuccessResponse, Fixnum, Hash)>
Revoke this OAuth application. Revokes the OAuth application associated with the specified client_id and token.
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 |
# File 'lib/ultracart_api/api/oauth_api.rb', line 124 def oauth_revoke_with_http_info(client_id, token, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: OauthApi.oauth_revoke ...' 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 OauthApi.oauth_revoke" end # verify the required parameter 'token' is set if @api_client.config.client_side_validation && token.nil? fail ArgumentError, "Missing the required parameter 'token' when calling OauthApi.oauth_revoke" end # resource path local_var_path = '/oauth/revoke' # query parameters query_params = {} # header parameters header_params = {} header_params['X-UltraCart-Api-Version'] = @api_client.select_header_api_version() # 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(['application/x-www-form-urlencoded']) # form parameters form_params = {} form_params['client_id'] = client_id form_params['token'] = token # http body (model) post_body = nil auth_names = ['ultraCartBrowserApiKey', 'ultraCartOauth', 'ultraCartSimpleApiKey'] 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 => 'OauthRevokeSuccessResponse') if @api_client.config.debugging @api_client.config.logger.debug "API called: OauthApi#oauth_revoke\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end |