Class: BancoBrasilClientCredentials::DefaultApi

Inherits:
Object
  • Object
show all
Defined in:
lib/bb_oauth/api/default_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ DefaultApi

Returns a new instance of DefaultApi.



5
6
7
# File 'lib/bb_oauth/api/default_api.rb', line 5

def initialize(api_client = ApiClient.default)
  @api_client = api_client
end

Instance Attribute Details

#api_clientObject

Returns the value of attribute api_client.



3
4
5
# File 'lib/bb_oauth/api/default_api.rb', line 3

def api_client
  @api_client
end

Instance Method Details

#oauth_token_post(grant_type, scope, authorization, content_type, opts = {}) ⇒ ResponseToken

Parameters:

  • grant_type
  • scope
  • authorization

    Deverá ser informado no padrão: Basic Base64(client_id:client_secret)

  • content_type

    Deverá ser informado: application/x-www-form-urlencoded

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



14
15
16
17
# File 'lib/bb_oauth/api/default_api.rb', line 14

def oauth_token_post(grant_type, scope, authorization, content_type, opts = {})
  data, _status_code, _headers = oauth_token_post_with_http_info(grant_type, scope, authorization, content_type, opts)
  data
end

#oauth_token_post_with_http_info(grant_type, scope, authorization, content_type, opts = {}) ⇒ Array<(ResponseToken, Integer, Hash)>

Returns ResponseToken data, response status code and response headers.

Parameters:

  • grant_type
  • scope
  • authorization

    Deverá ser informado no padrão: Basic Base64(client_id:client_secret)

  • content_type

    Deverá ser informado: application/x-www-form-urlencoded

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(ResponseToken, Integer, Hash)>)

    ResponseToken data, response status code and response headers



25
26
27
28
29
30
31
32
33
34
35
36
37
38
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
# File 'lib/bb_oauth/api/default_api.rb', line 25

def oauth_token_post_with_http_info(grant_type, scope, authorization, content_type, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: DefaultApi.oauth_token_post ...'
  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 DefaultApi.oauth_token_post"
  end
  # verify the required parameter 'scope' is set
  if @api_client.config.client_side_validation && scope.nil?
    fail ArgumentError, "Missing the required parameter 'scope' when calling DefaultApi.oauth_token_post"
  end
  # verify the required parameter 'authorization' is set
  if @api_client.config.client_side_validation && authorization.nil?
    fail ArgumentError, "Missing the required parameter 'authorization' when calling DefaultApi.oauth_token_post"
  end
  # verify the required parameter 'content_type' is set
  if @api_client.config.client_side_validation && content_type.nil?
    fail ArgumentError, "Missing the required parameter 'content_type' when calling DefaultApi.oauth_token_post"
  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/x-www-form-urlencoded'])
  # HTTP header 'Content-Type'
  # header_params['Content-Type'] = @api_client.select_header_content_type(['application/x-www-form-urlencoded'])
  header_params['Authorization'] = authorization
  header_params['Content-Type'] = content_type

  # form parameters
  form_params = opts[:form_params] || {}
  form_params['grant_type'] = grant_type
  form_params['scope'] = scope

  # http body (model)
  post_body = opts[:body]

  return_type = opts[:return_type] || 'ResponseToken'

  auth_names = opts[:auth_names] || []
  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 => return_type)

  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: DefaultApi#oauth_token_post\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end