Class: Meli::OAuth20Api
- Inherits:
-
Object
- Object
- Meli::OAuth20Api
- Defined in:
- lib/meli/api/o_auth20_api.rb
Instance Attribute Summary collapse
-
#api_client ⇒ Object
Returns the value of attribute api_client.
Instance Method Summary collapse
-
#auth(response_type, client_id, redirect_uri, opts = {}) ⇒ nil
Authentication Endpoint.
-
#auth_with_http_info(response_type, client_id, redirect_uri, opts = {}) ⇒ Array<(nil, Integer, Hash)>
Authentication Endpoint.
-
#get_token(opts = {}) ⇒ Object
Request Access Token Partner makes a request to the token endpoint by adding the following parameters described below.
-
#get_token_with_http_info(opts = {}) ⇒ Array<(Object, Integer, Hash)>
Request Access Token Partner makes a request to the token endpoint by adding the following parameters described below.
-
#initialize(api_client = ApiClient.default) ⇒ OAuth20Api
constructor
A new instance of OAuth20Api.
Constructor Details
#initialize(api_client = ApiClient.default) ⇒ OAuth20Api
Returns a new instance of OAuth20Api.
19 20 21 |
# File 'lib/meli/api/o_auth20_api.rb', line 19 def initialize(api_client = ApiClient.default) @api_client = api_client end |
Instance Attribute Details
#api_client ⇒ Object
Returns the value of attribute api_client.
17 18 19 |
# File 'lib/meli/api/o_auth20_api.rb', line 17 def api_client @api_client end |
Instance Method Details
#auth(response_type, client_id, redirect_uri, opts = {}) ⇒ nil
Authentication Endpoint
28 29 30 31 |
# File 'lib/meli/api/o_auth20_api.rb', line 28 def auth(response_type, client_id, redirect_uri, opts = {}) auth_with_http_info(response_type, client_id, redirect_uri, opts) nil end |
#auth_with_http_info(response_type, client_id, redirect_uri, opts = {}) ⇒ Array<(nil, Integer, Hash)>
Authentication Endpoint
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 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 |
# File 'lib/meli/api/o_auth20_api.rb', line 39 def auth_with_http_info(response_type, client_id, redirect_uri, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: OAuth20Api.auth ...' end # verify the required parameter 'response_type' is set if @api_client.config.client_side_validation && response_type.nil? fail ArgumentError, "Missing the required parameter 'response_type' when calling OAuth20Api.auth" end # verify enum value allowable_values = ["code"] if @api_client.config.client_side_validation && !allowable_values.include?(response_type) fail ArgumentError, "invalid value for \"response_type\", must be one of #{allowable_values}" 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 OAuth20Api.auth" end # verify the required parameter 'redirect_uri' is set if @api_client.config.client_side_validation && redirect_uri.nil? fail ArgumentError, "Missing the required parameter 'redirect_uri' when calling OAuth20Api.auth" end # resource path local_var_path = '/authorization' # query parameters query_params = opts[:query_params] || {} query_params[:'response_type'] = response_type query_params[:'client_id'] = client_id query_params[:'redirect_uri'] = redirect_uri # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:body] # return_type return_type = opts[:return_type] # auth_names auth_names = opts[:auth_names] || [] = opts.merge( :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(:GET, local_var_path, ) if @api_client.config.debugging @api_client.config.logger.debug "API called: OAuth20Api#auth\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end |
#get_token(opts = {}) ⇒ Object
Request Access Token Partner makes a request to the token endpoint by adding the following parameters described below
112 113 114 115 |
# File 'lib/meli/api/o_auth20_api.rb', line 112 def get_token(opts = {}) data, _status_code, _headers = get_token_with_http_info(opts) data end |
#get_token_with_http_info(opts = {}) ⇒ Array<(Object, Integer, Hash)>
Request Access Token Partner makes a request to the token endpoint by adding the following parameters described below
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 170 171 172 173 174 175 176 |
# File 'lib/meli/api/o_auth20_api.rb', line 127 def get_token_with_http_info(opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: OAuth20Api.get_token ...' 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' header_params['Content-Type'] = @api_client.select_header_content_type(['application/x-www-form-urlencoded']) # form parameters form_params = opts[:form_params] || {} form_params['grant_type'] = opts[:'grant_type'] if !opts[:'grant_type'].nil? form_params['client_id'] = opts[:'client_id'] if !opts[:'client_id'].nil? form_params['client_secret'] = opts[:'client_secret'] if !opts[:'client_secret'].nil? form_params['redirect_uri'] = opts[:'redirect_uri'] if !opts[:'redirect_uri'].nil? form_params['code'] = opts[:'code'] if !opts[:'code'].nil? form_params['refresh_token'] = opts[:'refresh_token'] if !opts[:'refresh_token'].nil? # http body (model) post_body = opts[:body] # return_type return_type = opts[:return_type] || 'Object' # auth_names auth_names = opts[:auth_names] || [] = opts.merge( :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: OAuth20Api#get_token\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end |