Class: BRL::Auth::TokenService
- Inherits:
-
Object
- Object
- BRL::Auth::TokenService
- Defined in:
- lib/brl/auth/token_service.rb
Instance Method Summary collapse
-
#initialize(connection: Connection.new) ⇒ TokenService
constructor
A new instance of TokenService.
- #retrieve ⇒ Object
Constructor Details
#initialize(connection: Connection.new) ⇒ TokenService
Returns a new instance of TokenService.
6 7 8 |
# File 'lib/brl/auth/token_service.rb', line 6 def initialize(connection: Connection.new) @connection = connection end |
Instance Method Details
#retrieve ⇒ Object
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/brl/auth/token_service.rb', line 10 def retrieve res = @connection.post(url: BRL::Auth::TOKEN_ENDPOINT, body: BRL::Auth::TokenService.login_body) return parse_response(res.body) if res.status == 200 raise BRL::Auth::BadRequestError if res.status == 400 raise BRL::Auth::InvalidCredentialsError if res.status == 401 raise BRL::Auth::ServerError if res.status == 500 raise BRL::Auth::UnexpectedError end |