class Sentofu::Token

Public Class Methods

new(res) click to toggle source
# File lib/sentofu/http.rb, line 170
def initialize(res)

  @h = JSON.parse(res.body)
  @h[:_elapsed] = res._elapsed
  @h[:_proxy] = res._proxy

  @expires_at = @h['expires_in'] ? Time.now + @h['expires_in'] : 0
end

Public Instance Methods

errors() click to toggle source
# File lib/sentofu/http.rb, line 179
def errors

  @h['errors'] || []
end
header_value() click to toggle source
# File lib/sentofu/http.rb, line 194
def header_value

  "Bearer #{@h['access_token'] || 'SENTOFU_INVALID_TOKEN_:-('}"
end
not_expired?() click to toggle source
# File lib/sentofu/http.rb, line 189
def not_expired?

  Time.now < @expires_at
end
sound?() click to toggle source
# File lib/sentofu/http.rb, line 184
def sound?

  errors.empty?
end