Class: TokenPair

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

Overview

Set up our token store

Instance Method Summary collapse

Constructor Details

#initialize(hash) ⇒ TokenPair

Returns a new instance of TokenPair.



13
14
15
16
17
18
19
20
# File 'lib/google_exporter.rb', line 13

def initialize(hash)
  if hash != nil
    @access_token = hash[:access_token]
    @expires_in   = hash[:expires_in]
    @issued_at    = hash[:issued_at]
    @refresh_token= hash[:refresh_token]
  end
end

Instance Method Details

#set?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/google_exporter.rb', line 29

def set?
  @refresh_token != nil
end

#to_hashObject



33
34
35
36
37
38
39
40
# File 'lib/google_exporter.rb', line 33

def to_hash
  return {
    :refresh_token  => @refresh_token,
    :access_token   => @access_token,
    :expires_in     => @expires_in,
    :issued_at      => Time.at(@issued_at)
  }
end

#update_token!(object) ⇒ Object



22
23
24
25
26
27
# File 'lib/google_exporter.rb', line 22

def update_token!(object)
  @refresh_token  = object.refresh_token
  @access_token   = object.access_token
  @expires_in     = object.expires_in
  @issued_at      = object.issued_at
end