class AbsorbApi::Authorize
Attributes
created_at[RW]
Public Class Methods
new()
click to toggle source
# File lib/absorb_api/authorize.rb, line 6 def initialize token end
Public Instance Methods
expired?()
click to toggle source
# File lib/absorb_api/authorize.rb, line 10 def expired? return true if created_at.blank? DateTime.now >= created_at + 4.hours end
token()
click to toggle source
# File lib/absorb_api/authorize.rb, line 16 def token return @token unless expired? @token = ActiveSupport::JSON.decode(connection.post do |req| req.url "Authenticate" req.headers["Content-Type"] = "application/json" req.headers["accept"] = "json" req.body = payload.to_json end.body) @created_at = DateTime.now end