Class: CyberSource::OAuthApi

Inherits:
Object
  • Object
show all
Defined in:
lib/cybersource_rest_client/api/o_auth_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default, config) ⇒ OAuthApi

Returns a new instance of OAuthApi.



19
20
21
22
# File 'lib/cybersource_rest_client/api/o_auth_api.rb', line 19

def initialize(api_client = ApiClient.default, config)
  @api_client = api_client
	  @api_client.set_configuration(config)
end

Instance Attribute Details

#api_clientObject

Returns the value of attribute api_client.



17
18
19
# File 'lib/cybersource_rest_client/api/o_auth_api.rb', line 17

def api_client
  @api_client
end

Instance Method Details

#create_access_token(create_access_token_request, opts = {}) ⇒ AccessTokenResponse

Create access token and refresh token This request is used by technology partners to obtain an access token and a refresh token, which are contained in the response. The partner can then use the access token for authentication when submitting API requests to CyberSource on behalf of the merchant. The request must include the authorization code that was included in the URL redirect response from CyberSource (see [full documentation](developer.cybersource.com/api/developer-guides/OAuth/cybs_extend_intro.html)). Access tokens expire after 15 minutes. The refresh token is used to create a new access token, it expires after one year.

Parameters:

  • create_access_token_request

    Request payload

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

    the optional parameters

Options Hash (opts):

  • :v_c_client_correlation_id (String)

    We recommended that you submit this header with a unique value in every client request to this endpoint. It is sent back in the response header and logged both in the request log and response log.

Returns:



29
30
31
32
# File 'lib/cybersource_rest_client/api/o_auth_api.rb', line 29

def create_access_token(create_access_token_request, opts = {})
  data, status_code, headers = create_access_token_with_http_info(create_access_token_request, opts)
  return data, status_code, headers
end

#create_access_token_with_http_info(create_access_token_request, opts = {}) ⇒ Array<(AccessTokenResponse, Fixnum, Hash)>

Create access token and refresh token This request is used by technology partners to obtain an access token and a refresh token, which are contained in the response. The partner can then use the access token for authentication when submitting API requests to CyberSource on behalf of the merchant. The request must include the authorization code that was included in the URL redirect response from CyberSource (see [full documentation](developer.cybersource.com/api/developer-guides/OAuth/cybs_extend_intro.html)). Access tokens expire after 15 minutes. The refresh token is used to create a new access token, it expires after one year.

Parameters:

  • create_access_token_request

    Request payload

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

    the optional parameters

Options Hash (opts):

  • :v_c_client_correlation_id (String)

    We recommended that you submit this header with a unique value in every client request to this endpoint. It is sent back in the response header and logged both in the request log and response log.

Returns:

  • (Array<(AccessTokenResponse, Fixnum, Hash)>)

    AccessTokenResponse data, response status code and response headers



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
101
102
# File 'lib/cybersource_rest_client/api/o_auth_api.rb', line 40

def create_access_token_with_http_info(create_access_token_request, opts = {})
  
	  if @api_client.config.debugging
begin
			raise
@api_client.config.logger.debug 'Calling API: OAuthApi.create_access_token ...'
			rescue
puts 'Cannot write to log'
			end
  end
  # verify the required parameter 'create_access_token_request' is set
  if @api_client.config.client_side_validation && create_access_token_request.nil?
    fail ArgumentError, "Missing the required parameter 'create_access_token_request' when calling OAuthApi.create_access_token"
  end
  if @api_client.config.client_side_validation && !opts[:'v_c_client_correlation_id'].nil? && opts[:'v_c_client_correlation_id'].to_s.length > 36
    fail ArgumentError, 'invalid value for "opts[:"v_c_client_correlation_id"]" when calling OAuthApi.create_access_token, the character length must be smaller than or equal to 36.'
  end

  if @api_client.config.client_side_validation && !opts[:'v_c_client_correlation_id'].nil? && opts[:'v_c_client_correlation_id'].to_s.length < 36
    fail ArgumentError, 'invalid value for "opts[:"v_c_client_correlation_id"]" when calling OAuthApi.create_access_token, the character length must be great than or equal to 36.'
  end

  #if @api_client.config.client_side_validation && !opts[:'v_c_client_correlation_id'].nil? && opts[:'v_c_client_correlation_id'] !~ Regexp.new(/^[A-Za-z0-9\\.\\-_:]+$/)
    #fail ArgumentError, "invalid value for 'opts[:\"v_c_client_correlation_id\"]' when calling OAuthApi.create_access_token, must conform to the pattern /^[A-Za-z0-9\\.\\-_:]+$/."
  #end

  # resource path
  local_var_path = 'oauth2/v3/token'

  # query parameters
  query_params = {}

  # header parameters
  header_params = {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json;charset=utf-8'])
  # HTTP header 'Content-Type'
  header_params['Content-Type'] = @api_client.select_header_content_type(['application/x-www-form-urlencoded'])
  header_params[:'v-c-client-correlation-id'] = opts[:'v_c_client_correlation_id'] if !opts[:'v_c_client_correlation_id'].nil?

  # form parameters
  form_params = {}

  # http body (model)
  post_body = @api_client.object_to_http_body(create_access_token_request)
  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 => 'AccessTokenResponse')
  if @api_client.config.debugging
		begin
		raise
			@api_client.config.logger.debug "API called: OAuthApi#create_access_token\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
		rescue
			puts 'Cannot write to log'
		end
	  end
  return data, status_code, headers
end