Class: BeyondApi::Token

Inherits:
Object
  • Object
show all
Includes:
Utils
Defined in:
lib/beyond_api/resources/token.rb

Defined Under Namespace

Classes: InvalidSessionError

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Utils

#file_content_type, #handle_all_request, #handle_error, #sanitize_key, #sanitize_response, #to_object_struct

Constructor Details

#initialize(session) ⇒ Token

Returns a new instance of Token.



13
14
15
16
17
18
# File 'lib/beyond_api/resources/token.rb', line 13

def initialize(session)
  @session = session

  raise InvalidSessionError, "Invalid session" unless session.is_a? BeyondApi::Session
  raise InvalidSessionError, "Session api_url cannot be nil" if session.api_url.nil?
end

Instance Attribute Details

#sessionObject (readonly)

Returns the value of attribute session.



11
12
13
# File 'lib/beyond_api/resources/token.rb', line 11

def session
  @session
end

Instance Method Details

#authorization_code(code) ⇒ Object Also known as: create



20
21
22
# File 'lib/beyond_api/resources/token.rb', line 20

def authorization_code(code)
  handle_token_call("authorization_code", code: code)
end

#client_credentialsObject



28
29
30
# File 'lib/beyond_api/resources/token.rb', line 28

def client_credentials
  handle_token_call("client_credentials")
end

#refresh_tokenObject Also known as: refresh



24
25
26
# File 'lib/beyond_api/resources/token.rb', line 24

def refresh_token
  handle_token_call("refresh_token", refresh_token: @session.refresh_token)
end