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:

  1. Static API key — for Companies and Firms using a personal access token:

    creds = Pennylane::Credentials.api_key("tok_xxx")
    
  2. 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

Classes: ApiKey, OAuth

Class Method Summary collapse

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