class Lifen::UserAuthenticatedClient
Attributes
token[R]
Public Class Methods
new(token)
click to toggle source
# File lib/lifen/user_authenticated_client.rb, line 4 def initialize(token) @token = token end
Private Instance Methods
bearer()
click to toggle source
# File lib/lifen/user_authenticated_client.rb, line 30 def bearer token.value end
before_request()
click to toggle source
# File lib/lifen/user_authenticated_client.rb, line 34 def before_request token.refresh_once_if_needed end
handle_errors(response, params)
click to toggle source
Calls superclass method
Lifen::Client#handle_errors
# File lib/lifen/user_authenticated_client.rb, line 12 def handle_errors(response, params) super(response, params) case response.status when 400 raise InvalidParamsError, "Error 400, Invalid params, #{response_error(response, params)}" when 401 raise UnauthorizedError, "Error 401, Token is not valid, #{response_error(response, params)}" when 403 raise Error, "Error 403, Action is forbidden, #{response_error(response, params)}" end end
response_error(response, params)
click to toggle source
# File lib/lifen/user_authenticated_client.rb, line 26 def response_error(response, params) "User Client, #{super(response, params)}" end