Class: Makeleaps::Response::TokenStore

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ TokenStore

Returns a new instance of TokenStore.



6
7
8
9
10
11
# File 'lib/makeleaps/response/access_token.rb', line 6

def initialize(response)
  @response      = response
  @body = JSON.parse(response.body)
rescue JSON::JSONError
  @body = nil
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



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

def body
  @body
end

#responseObject (readonly)

Returns the value of attribute response.



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

def response
  @response
end

Instance Method Details

#access_tokenObject



13
14
15
# File 'lib/makeleaps/response/access_token.rb', line 13

def access_token
  @access_token ||= body['access_token']
end

#valid?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/makeleaps/response/access_token.rb', line 17

def valid?
  response && response.status == 200 && !expired?
end