Class: BeyondApi::Token
- Inherits:
-
Object
- Object
- BeyondApi::Token
- Includes:
- Utils
- Defined in:
- lib/beyond_api/resources/token.rb
Defined Under Namespace
Classes: InvalidSessionError
Instance Attribute Summary collapse
-
#session ⇒ Object
readonly
Returns the value of attribute session.
Instance Method Summary collapse
- #authorization_code(code) ⇒ Object (also: #create)
- #client_credentials ⇒ Object
-
#initialize(session) ⇒ Token
constructor
A new instance of Token.
- #refresh_token ⇒ Object (also: #refresh)
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
#session ⇒ Object (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 (code) handle_token_call("authorization_code", code: code) end |
#client_credentials ⇒ Object
28 29 30 |
# File 'lib/beyond_api/resources/token.rb', line 28 def client_credentials handle_token_call("client_credentials") end |
#refresh_token ⇒ Object 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 |