Class: LinkedIn::AccessToken

Inherits:
Object
  • Object
show all
Defined in:
lib/linked_in/access_token.rb

Overview

A simple data object to contain the token string and expiration data.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(token = nil, expires_in = nil, expires_at = nil) ⇒ AccessToken

Creates a simple data wrapper for an access token.

LinkedIn returns only an ‘expires_in` value. This calculates and sets and `expires_at` field for convenience.

Parameters:

  • token (String) (defaults to: nil)

    the access token

  • expires_in (FixNum) (defaults to: nil)

    number of seconds the token lasts for

  • expires_at (Time) (defaults to: nil)

    when the token will expire.



14
15
16
17
18
19
20
21
22
# File 'lib/linked_in/access_token.rb', line 14

def initialize(token=nil, expires_in=nil, expires_at=nil)
  self.token = token
  self.expires_in = expires_in
  if expires_at.nil? and not self.expires_in.nil?
    self.expires_at = Time.now + expires_in
  else
    self.expires_at = expires_at
  end
end

Instance Attribute Details

#expires_atObject

Returns the value of attribute expires_at.



4
5
6
# File 'lib/linked_in/access_token.rb', line 4

def expires_at
  @expires_at
end

#expires_inObject

Returns the value of attribute expires_in.



4
5
6
# File 'lib/linked_in/access_token.rb', line 4

def expires_in
  @expires_in
end

#tokenObject

Returns the value of attribute token.



4
5
6
# File 'lib/linked_in/access_token.rb', line 4

def token
  @token
end