Class: Yapstone::TokenApi

Inherits:
Object
  • Object
show all
Defined in:
lib/yapstone-payments/api/token_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ TokenApi

Returns a new instance of TokenApi.



19
20
21
# File 'lib/yapstone-payments/api/token_api.rb', line 19

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

Instance Attribute Details

#api_clientObject

Returns the value of attribute api_client.



17
18
19
# File 'lib/yapstone-payments/api/token_api.rb', line 17

def api_client
  @api_client
end

Instance Method Details

#create_token(authorization, x_yapstone_ip_address, opts = {}) ⇒ Token

Create a Token Create a token to make a payment. In your request you specify the type of instrument and you are returned a token for that instrument in the response.

Parameters:

  • authorization (String)

    Authorization

  • x_yapstone_ip_address (String)

    IP Address of the client

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

    the optional parameters

Options Hash (opts):

  • :x_yapstone_trace_id (String)

    Optionally provide a unique identifier for this request, for use later if you need to debug this request with Yapstone support. Can be any arbitrary string.

  • :x_yapstone_fpsid (String)

    Device Finger Print Id

  • :token_request (TokenRequest)

Returns:



31
32
33
34
# File 'lib/yapstone-payments/api/token_api.rb', line 31

def create_token(authorization, x_yapstone_ip_address, opts = {})
  data, _status_code, _headers = create_token_with_http_info(authorization, x_yapstone_ip_address, opts)
  data
end

#create_token_with_http_info(authorization, x_yapstone_ip_address, opts = {}) ⇒ Array<(Token, Integer, Hash)>

Create a Token Create a token to make a payment. In your request you specify the type of instrument and you are returned a token for that instrument in the response.

Parameters:

  • authorization (String)

    Authorization

  • x_yapstone_ip_address (String)

    IP Address of the client

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

    the optional parameters

Options Hash (opts):

  • :x_yapstone_trace_id (String)

    Optionally provide a unique identifier for this request, for use later if you need to debug this request with Yapstone support. Can be any arbitrary string.

  • :x_yapstone_fpsid (String)

    Device Finger Print Id

  • :token_request (TokenRequest)

Returns:

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

    Token data, response status code and response headers



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/yapstone-payments/api/token_api.rb', line 45

def create_token_with_http_info(authorization, x_yapstone_ip_address, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: TokenApi.create_token ...'
  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 TokenApi.create_token"
  end
  # verify the required parameter 'x_yapstone_ip_address' is set
  if @api_client.config.client_side_validation && x_yapstone_ip_address.nil?
    fail ArgumentError, "Missing the required parameter 'x_yapstone_ip_address' when calling TokenApi.create_token"
  end
  # resource path
  local_var_path = '/v2/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/json'])
  header_params[:'Authorization'] = authorization
  header_params[:'X-Yapstone-IPAddress'] = x_yapstone_ip_address
  header_params[:'X-Yapstone-Trace-Id'] = opts[:'x_yapstone_trace_id'] if !opts[:'x_yapstone_trace_id'].nil?
  header_params[:'X-Yapstone-fpsid'] = opts[:'x_yapstone_fpsid'] if !opts[:'x_yapstone_fpsid'].nil?

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

  # http body (model)
  post_body = opts[:body] || @api_client.object_to_http_body(opts[:'token_request']) 

  # return_type
  return_type = opts[:return_type] || 'Token' 

  # auth_names
  auth_names = opts[:auth_names] || ['Bearer']

  new_options = 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, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: TokenApi#create_token\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#lookup_token(authorization, x_yapstone_ip_address, opts = {}) ⇒ TokenResponse

Lookup a Token Lookup a token to make a payment. Submit the token ID to retrieve details about the token.

Parameters:

  • authorization (String)

    Authorization

  • x_yapstone_ip_address (String)

    IP Address of the client

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

    the optional parameters

Options Hash (opts):

  • :x_yapstone_trace_id (String)

    Optionally provide a unique identifier for this request, for use later if you need to debug this request with Yapstone support. Can be any arbitrary string.

  • :x_yapstone_fpsid (String)

    Device Finger Print Id

  • :token (Token)

Returns:



111
112
113
114
# File 'lib/yapstone-payments/api/token_api.rb', line 111

def lookup_token(authorization, x_yapstone_ip_address, opts = {})
  data, _status_code, _headers = lookup_token_with_http_info(authorization, x_yapstone_ip_address, opts)
  data
end

#lookup_token_with_http_info(authorization, x_yapstone_ip_address, opts = {}) ⇒ Array<(TokenResponse, Integer, Hash)>

Lookup a Token Lookup a token to make a payment. Submit the token ID to retrieve details about the token.

Parameters:

  • authorization (String)

    Authorization

  • x_yapstone_ip_address (String)

    IP Address of the client

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

    the optional parameters

Options Hash (opts):

  • :x_yapstone_trace_id (String)

    Optionally provide a unique identifier for this request, for use later if you need to debug this request with Yapstone support. Can be any arbitrary string.

  • :x_yapstone_fpsid (String)

    Device Finger Print Id

  • :token (Token)

Returns:

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

    TokenResponse data, response status code and response headers



125
126
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
177
178
179
180
# File 'lib/yapstone-payments/api/token_api.rb', line 125

def lookup_token_with_http_info(authorization, x_yapstone_ip_address, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: TokenApi.lookup_token ...'
  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 TokenApi.lookup_token"
  end
  # verify the required parameter 'x_yapstone_ip_address' is set
  if @api_client.config.client_side_validation && x_yapstone_ip_address.nil?
    fail ArgumentError, "Missing the required parameter 'x_yapstone_ip_address' when calling TokenApi.lookup_token"
  end
  # resource path
  local_var_path = '/v2/token/lookup'

  # 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/json'])
  header_params[:'Authorization'] = authorization
  header_params[:'X-Yapstone-IPAddress'] = x_yapstone_ip_address
  header_params[:'X-Yapstone-Trace-Id'] = opts[:'x_yapstone_trace_id'] if !opts[:'x_yapstone_trace_id'].nil?
  header_params[:'X-Yapstone-fpsid'] = opts[:'x_yapstone_fpsid'] if !opts[:'x_yapstone_fpsid'].nil?

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

  # http body (model)
  post_body = opts[:body] || @api_client.object_to_http_body(opts[:'token']) 

  # return_type
  return_type = opts[:return_type] || 'TokenResponse' 

  # auth_names
  auth_names = opts[:auth_names] || ['Bearer']

  new_options = 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, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: TokenApi#lookup_token\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end