class AsposeEmailCloud::ApiInvoker
API client invoker. Processes all requests and obtains actual token if necessary.
Attributes
api_client[R]
Public Class Methods
new(api_client)
click to toggle source
# File lib/aspose-email-cloud/api_invoker.rb, line 33 def initialize(api_client) @api_client = api_client end
Public Instance Methods
make_request(http_request, method, return_type)
click to toggle source
# File lib/aspose-email-cloud/api_invoker.rb, line 37 def make_request(http_request, method, return_type) call_api(http_request, method, return_type) rescue ApiError => e if e.code.equal? 401 request_token return call_api(http_request, method, return_type) end raise end
Private Instance Methods
call_api(http_request, method, return_type)
click to toggle source
# File lib/aspose-email-cloud/api_invoker.rb, line 49 def call_api(http_request, method, return_type) response = @api_client.call_api(method, http_request.resource_path, header_params: http_request.header_params, query_params: http_request.query_params, form_params: http_request.form_params, body: http_request.body, auth_names: http_request.auth_names, return_type: return_type) response[0] end
request_token()
click to toggle source
# File lib/aspose-email-cloud/api_invoker.rb, line 61 def request_token config = @api_client.config header_params = { 'Accept' => 'application/json', 'Content-Type' => 'application/x-www-form-urlencoded' } base_path = @api_client.config.base_path @api_client.config.base_path = '' data = @api_client.call_api(:POST, '/connect/token', header_params: header_params, form_params: request_token_form_params(config), return_type: 'Object', host: @api_client.config.auth_url) @api_client.config.base_path = base_path @api_client.config.access_token = data[0]['access_token'.to_sym] end
request_token_form_params(config)
click to toggle source
# File lib/aspose-email-cloud/api_invoker.rb, line 83 def request_token_form_params(config) { 'grant_type': 'client_credentials', 'client_id': config.client_credentials[:client_id], 'client_secret': config.client_credentials[:client_secret] } end