Class: Snapshot::Token

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Serialization
Defined in:
lib/snapshot/token.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#expires_inObject

Returns the value of attribute expires_in.



3
4
5
# File 'lib/snapshot/token.rb', line 3

def expires_in
  @expires_in
end

#tokenObject

Returns the value of attribute token.



3
4
5
# File 'lib/snapshot/token.rb', line 3

def token
  @token
end

Class Method Details

.createObject



5
6
7
8
9
10
11
12
13
# File 'lib/snapshot/token.rb', line 5

def self.create
  result = Snapshot.connection.post('/token')
  info = JSON.parse(result)
  
  self.new.tap do |t|
    t.expires_in = info['expires_in']
    t.token      = info['token']
  end
end

Instance Method Details

#attributesObject



23
24
25
# File 'lib/snapshot/token.rb', line 23

def attributes
  { expires_in: expires_in, token: token }
end

#to_sObject



15
16
17
# File 'lib/snapshot/token.rb', line 15

def to_s
  token
end