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, Integer, 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, Integer, 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, Integer, 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 107 108 109 110 111 112 113 114 115 116 117 118 119 |
# 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 = opts[:query_params] || {} # header parameters header_params = opts[: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' content_type = @api_client.select_header_content_type(['application/x-www-form-urlencoded']) if !content_type.nil? header_params['Content-Type'] = content_type end # form parameters form_params = opts[: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 = opts[:debug_body] # return_type return_type = opts[:debug_return_type] || 'OauthTokenResponse' # auth_names auth_names = opts[:debug_auth_names] || ['ultraCartBrowserApiKey', 'ultraCartOauth', 'ultraCartSimpleApiKey'] = opts.merge( :operation => :"OauthApi.oauth_access_token", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:POST, local_var_path, ) 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.
127 128 129 130 |
# File 'lib/ultracart_api/api/oauth_api.rb', line 127 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, Integer, Hash)>
Revoke this OAuth application. Revokes the OAuth application associated with the specified client_id and token.
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 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 |
# File 'lib/ultracart_api/api/oauth_api.rb', line 138 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 = opts[:query_params] || {} # header parameters header_params = opts[: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' content_type = @api_client.select_header_content_type(['application/x-www-form-urlencoded']) if !content_type.nil? header_params['Content-Type'] = content_type end # form parameters form_params = opts[:form_params] || {} form_params['client_id'] = client_id form_params['token'] = token # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] || 'OauthRevokeSuccessResponse' # auth_names auth_names = opts[:debug_auth_names] || ['ultraCartBrowserApiKey', 'ultraCartOauth', 'ultraCartSimpleApiKey'] = opts.merge( :operation => :"OauthApi.oauth_revoke", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:POST, local_var_path, ) 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 |