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

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client_id, client_secret, access_token, expires_at) ⇒ AccessToken

Constructor



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

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

Instance Attribute Details

#access_tokenObject

Returns the value of attribute access_token.



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

def access_token
  @access_token
end

#client_idObject

Returns the value of attribute client_id.



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

def client_id
  @client_id
end

#client_secretObject

Returns the value of attribute client_secret.



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

def client_secret
  @client_secret
end

#expires_atObject

Returns the value of attribute expires_at.



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

def expires_at
  @expires_at
end

Instance Method Details

#has_expiredObject

Has this AccessToken expired?



40
41
42
# File 'lib/zara4/api/communication/access_token/access_token.rb', line 40

def has_expired
  return Time.now > @expires_at
end

#refreshObject

Refresh this AccessToken



32
33
34
# File 'lib/zara4/api/communication/access_token/access_token.rb', line 32

def refresh
  # Stub to be implemented
end

#tokenObject

Get the token



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

def token
  if has_expired()
    refresh()
  end
  return @access_token
end