Class: Zara4::API::Communication::AccessToken::ReissuableAccessToken

Inherits:
AccessToken
  • Object
show all
Defined in:
lib/zara4/api/communication/access_token/reissuable_access_token.rb

Instance Attribute Summary collapse

Attributes inherited from AccessToken

#access_token, #client_id, #client_secret, #expires_at

Instance Method Summary collapse

Methods inherited from AccessToken

#has_expired, #token

Constructor Details

#initialize(client_id, client_secret, access_token, expires_at, scopes) ⇒ ReissuableAccessToken

Constructor



10
11
12
13
# File 'lib/zara4/api/communication/access_token/reissuable_access_token.rb', line 10

def initialize(client_id, client_secret, access_token, expires_at, scopes)
  super(client_id, client_secret, access_token, expires_at)
  @scopes = scopes
end

Instance Attribute Details

#scopesObject

Returns the value of attribute scopes.



4
5
6
# File 'lib/zara4/api/communication/access_token/reissuable_access_token.rb', line 4

def scopes
  @scopes
end

Instance Method Details

#refreshObject

Refresh this ReissuableAccessToken



19
20
21
22
23
24
25
# File 'lib/zara4/api/communication/access_token/reissuable_access_token.rb', line 19

def refresh
  grant = ClientCredentialsGrantRequest.new(@client_id, @client_secret, @scopes)
  tokens = grant.get_tokens()
  
  @access_token = tokens['access_token']
  @expires_at   = tokens['expires_in']
end