class PayU::OAuth::Authorization

Constants

ENDPOINT
GRANT_TYPE

Public Class Methods

new(http_client, client_id, client_secret) click to toggle source
# File lib/pay_u/o_auth/authorization.rb, line 11
def initialize(http_client, client_id, client_secret)
  @http_client = http_client
  @client_id = client_id
  @client_secret = client_secret
end

Public Instance Methods

access_token() click to toggle source
# File lib/pay_u/o_auth/authorization.rb, line 17
def access_token
  response = authorize
  raise UnauthorizedError unless response.success?
  authorize.access_token
end
authorize() click to toggle source
# File lib/pay_u/o_auth/authorization.rb, line 23
def authorize
  OAuth::Response.new(fetch_response)
end

Private Instance Methods

authorization_options() click to toggle source
# File lib/pay_u/o_auth/authorization.rb, line 33
def authorization_options
  { grant_type: GRANT_TYPE, client_id: @client_id, client_secret: @client_secret }
end
fetch_response() click to toggle source
# File lib/pay_u/o_auth/authorization.rb, line 29
def fetch_response
  @http_client.post_form(ENDPOINT, authorization_options)
end