Class: Einvoicing::Connect::FR::Pennylane::Credentials::OAuth

Inherits:
Object
  • Object
show all
Defined in:
lib/einvoicing/connect/fr/pennylane/credentials.rb

Overview

OAuth2 access + refresh token pair. Mutable so the Client can update tokens in place after a refresh, making the new values available to the caller for persistence.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(access_token:, refresh_token:, client_id:, client_secret:, expires_at: nil) ⇒ OAuth

Returns a new instance of OAuth.



58
59
60
61
62
63
64
65
# File 'lib/einvoicing/connect/fr/pennylane/credentials.rb', line 58

def initialize(access_token:, refresh_token:, client_id:, client_secret:,
               expires_at: nil)
  @access_token  = access_token
  @refresh_token = refresh_token
  @client_id     = client_id
  @client_secret = client_secret
  @expires_at    = expires_at
end

Instance Attribute Details

#access_tokenObject

Returns the value of attribute access_token.



56
57
58
# File 'lib/einvoicing/connect/fr/pennylane/credentials.rb', line 56

def access_token
  @access_token
end

#client_idObject (readonly)

Returns the value of attribute client_id.



55
56
57
# File 'lib/einvoicing/connect/fr/pennylane/credentials.rb', line 55

def client_id
  @client_id
end

#client_secretObject (readonly)

Returns the value of attribute client_secret.



55
56
57
# File 'lib/einvoicing/connect/fr/pennylane/credentials.rb', line 55

def client_secret
  @client_secret
end

#expires_atObject

Returns the value of attribute expires_at.



56
57
58
# File 'lib/einvoicing/connect/fr/pennylane/credentials.rb', line 56

def expires_at
  @expires_at
end

#refresh_tokenObject

Returns the value of attribute refresh_token.



56
57
58
# File 'lib/einvoicing/connect/fr/pennylane/credentials.rb', line 56

def refresh_token
  @refresh_token
end

Instance Method Details

#expired?Boolean

Returns:

  • (Boolean)


67
68
69
# File 'lib/einvoicing/connect/fr/pennylane/credentials.rb', line 67

def expired?
  expires_at.nil? || Time.now >= expires_at
end