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.



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

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.



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

def body
  @body
end

#responseObject (readonly)

Returns the value of attribute response.



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

def response
  @response
end

Instance Method Details

#access_tokenObject



15
16
17
# File 'lib/makeleaps/response/access_token.rb', line 15

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

#valid?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/makeleaps/response/access_token.rb', line 19

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