Module: Einvoicing::Connect::FR::Pennylane::Credentials
- Defined in:
- lib/einvoicing/connect/fr/pennylane/credentials.rb
Overview
Encapsulates Pennylane API authentication credentials.
Two modes are supported:
-
Static API key — for Companies and Firms using a personal access token:
creds = Pennylane::Credentials.api_key("tok_xxx") -
OAuth2 — for Integration Partners using the authorization code flow:
creds = Pennylane::Credentials.oauth( access_token: "...", refresh_token: "...", client_id: "...", client_secret: "...", expires_at: Time.now + 3600 # optional )
OAuth credentials are mutable: when the Client refreshes an expired access token it updates the object in place. The calling application can read back the updated tokens after any API call and persist them.
Defined Under Namespace
Class Method Summary collapse
- .api_key(key) ⇒ Object
- .oauth(access_token:, refresh_token:, client_id:, client_secret:, expires_at: nil) ⇒ Object
Class Method Details
.api_key(key) ⇒ Object
27 28 29 |
# File 'lib/einvoicing/connect/fr/pennylane/credentials.rb', line 27 def self.api_key(key) ApiKey.new(key) end |
.oauth(access_token:, refresh_token:, client_id:, client_secret:, expires_at: nil) ⇒ Object
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/einvoicing/connect/fr/pennylane/credentials.rb', line 31 def self.oauth(access_token:, refresh_token:, client_id:, client_secret:, expires_at: nil) OAuth.new( access_token: access_token, refresh_token: refresh_token, client_id: client_id, client_secret: client_secret, expires_at: expires_at ) end |