ds_provider_tripletex_py_lib.linked_service

File: __init__.py Region: ds_provider_tripletex_py_lib/linked_service

Description

Linked service package for the Tripletex provider.

Submodules

Classes

TripletexLinkedService

Linked service for connecting to the Tripletex API.

TripletexLinkedServiceSettings

Settings required to connect to the Tripletex API.

Package Contents

class ds_provider_tripletex_py_lib.linked_service.TripletexLinkedService[source]

Bases: ds_protocol_http_py_lib.HttpLinkedService[TripletexLinkedServiceSettingsType], Generic[TripletexLinkedServiceSettingsType]

Linked service for connecting to the Tripletex API.

Exposed (caller-configurable): id, name, description, version, settings. Internal (inherited from HttpLinkedService, init=False, never user-settable): _session, _http – runtime connection state populated by connect().

settings: TripletexLinkedServiceSettingsType
property type: ds_provider_tripletex_py_lib.enums.ResourceType

Return the resource type for the Tripletex linked service.

connect() → None[source]

Exchange consumer/employee tokens for a session token and build the auth header.

PUT``s ``{host}/token/session/:create with consumerToken/ employeeToken/expirationDate, reads the session token from value.token, then stores Basic base64(client_id:session_token) as the Authorization header. Idempotent – each call creates a fresh session token.

Raises:
  • AuthenticationError – If Tripletex responds but rejects the consumer/employee token (any non-2xx response other than 403, e.g. a revoked or malformed employee token returns 404/422, not 401 – Tripletex’s own message is included), or if the session token is missing from an otherwise-successful response.

  • AuthorizationError – If Tripletex returns 403 (authenticated but insufficient permission).

  • ConnectionError – If the request to Tripletex fails at the network level, or Tripletex never responds at all (e.g. a timeout) – distinct from a response that arrives but rejects the request.

test_connection() → tuple[bool, str][source]

Verify the Tripletex session by calling the lightweight identity endpoint.

Returns:

(True, "") on success, otherwise (False, error_message).

Return type:

tuple[bool, str]

class ds_provider_tripletex_py_lib.linked_service.TripletexLinkedServiceSettings[source]

Bases: ds_protocol_http_py_lib.HttpLinkedServiceSettings

Settings required to connect to the Tripletex API.

consumer_token

Long-lived consumer token issued to the integration. Masked in logs.

employee_token

Per-employee token issued by the Tripletex user. Masked in logs.

client_id

Client identifier combined with the session token to form the Basic auth header. Tripletex accepts "0" for the default/anonymous client.

host

API host. Defaults to the production host; pass host= explicitly to target a different environment.

session_token_ttl_days

Requested validity window, in days, for the session token created during connect().

auth_type

Unused by this provider – connect() is fully overridden and never dispatches through the base class’s auth handlers. Kept only for schema/dataclass alignment with HttpLinkedServiceSettings.

consumer_token: str

Long-lived consumer token issued to the integration.

employee_token: str

Per-employee token issued by the Tripletex user.

client_id: str = '0'

Client identifier combined with the session token to form the Basic auth header.

host: str = 'https://tripletex.no/v2'

API host. Defaults to the Tripletex production environment.

session_token_ttl_days: int = 1

Requested validity window, in days, for the session token.

auth_type: ds_protocol_http_py_lib.enums.AuthType

Unused – connect() is fully overridden. Kept for dataclass alignment.