class CodePicnic::Token

Attributes

api_url[RW]
access_token[RW]
created_at[RW]
expires_in[RW]

Public Class Methods

new(client_id, client_secret) click to toggle source
# File lib/codepicnic/token.rb, line 12
def initialize(client_id, client_secret)
  response = RestClient.post Token.api_url, {
      grant_type: "client_credentials",
      client_id: client_id,
      client_secret: client_secret
  }

  parsed_response = JSON.parse(response)
  @access_token   = parsed_response["access_token"]
  @created_at     = parsed_response["created_at"].to_i
  @expires_in     = parsed_response["expires_in"].to_i
end

Public Instance Methods

expired?() click to toggle source
# File lib/codepicnic/token.rb, line 25
def expired?
  Time.now.to_i > (@created_at + @expires_in)
end