Aller au contenu principal

Credential & Collector states

Credential State

Credentials go through various states during their lifecycle. Understanding these states is crucial for providing appropriate UI feedback to your users.

Each credential object has a state field:

...
state: {
index: 3, // Number from -2 to 7
max: 7, // Always 7
title: "2FA code is required", // Title of the current state
message: "A 2FA code has been sent to ***@gmail.com" // Instructions for the current state
},
...
StateIndexDescriptionPossible actions
Unknown0Something went wrong - Unexpected state
Preparing collect1Initial preparation phase before collection starts
Authentication in progress2Authentication process is underway
2FA code required3Two-factor authentication code is needed from user
Performing 2FA4Processing the provided 2FA code
Collecting data5Gathering data from the collector source
Downloading invoices6Retrieving invoice files
Done7Collection completed successfully
Error-1An error occurred during the process
Disconnect-2Credential needs to be reconnected

credential_state_diagram

Collector State

In addition to the credential state, each credential has a collector object with its own state field. This is important to check before interpreting the credential state:

...
collector: {
state: "planned" // Can be "planned", "development", "active", etc.
},
...
StateDescription
PlannedThe collector is under development and not yet functional. Users can still see the collector in the UI, but no invoices will be collected until it becomes active.
DevelopmentThe collector is being developed but not yet ready for production. Invoices are not yet being collected.
ActiveThe collector is fully developed and operational. At least one invoice has been collected successfully.

collector_state_diagram

When displaying users credential status in your application, it's important to consider both the credential.state and collector.state to provide accurate and user-friendly feedback. To provide the best user experience and reduce support requests, we recommend the following UI label mapping:

ConditionSuggested UI LabelExplanation
credential.collector.state == "planned"Coming soonThe collector is under development. The user's request has been registered and will be processed once the collector is operational.
credential.collector.state != "planned" and credential.state.index < 0ErrorAn error occurred (index -1) or reconnection needed (index -2)
credential.collector.state != "planned" and credential.state.index == 0Scheduled collectionCollection is scheduled but not yet started
credential.collector.state != "planned" and (credential.state.index == 1 or credential.state.index == 2 or credential.state.index == 4)Connection in progressAuthentication or 2FA verification is in progress
credential.collector.state != "planned" and credential.state.index == 32FA requiredWaiting for user to provide 2FA code
credential.collector.state != "planned" and credential.state.index >= 5ActiveCollection is running or completed successfully
astuce

When displaying "Coming soon" status, consider adding an explanatory message such as: "This collector is currently under development. We will notify you as soon as it becomes operational."