Class: Fullscriptapi::AccessToken

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ AccessToken

Returns a new instance of AccessToken.



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/fullscriptapi/access_token.rb', line 8

def initialize(opts = {})
  opts = opts.dup

  %i[access_token refresh_token expires_in expires_at expires_latency].each do |arg|
    instance_variable_set("@#{arg}", opts.delete(arg) || opts.delete(arg.to_s))
  end

  @expires_in ||= opts.delete('expires')
  @expires_in &&= @expires_in.to_i
  @expires_at &&= convert_expires_at(@expires_at)
  @expires_at ||= Time.now.to_i + @expires_in if @expires_in
end

Instance Attribute Details

#access_tokenObject (readonly)

Returns the value of attribute access_token.



5
6
7
# File 'lib/fullscriptapi/access_token.rb', line 5

def access_token
  @access_token
end

#clientObject (readonly)

Returns the value of attribute client.



5
6
7
# File 'lib/fullscriptapi/access_token.rb', line 5

def client
  @client
end

#expires_atObject (readonly)

Returns the value of attribute expires_at.



5
6
7
# File 'lib/fullscriptapi/access_token.rb', line 5

def expires_at
  @expires_at
end

#expires_inObject (readonly)

Returns the value of attribute expires_in.



5
6
7
# File 'lib/fullscriptapi/access_token.rb', line 5

def expires_in
  @expires_in
end

#refresh_tokenObject

Returns the value of attribute refresh_token.



6
7
8
# File 'lib/fullscriptapi/access_token.rb', line 6

def refresh_token
  @refresh_token
end

Instance Method Details

#expired?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/fullscriptapi/access_token.rb', line 21

def expired?
  expires_at <= Time.now.to_i
end