parseur¶
Submodules¶
Classes¶
Document resource providing class-based API access. |
|
Enumeration of supported document sorting keys. |
|
Enumeration of supported Parseur webhook event types. |
|
Enumeration of supported mailbox sorting keys. |
|
Enum for Parseur document processing statuses. |
|
Functions¶
|
Serialize a Python object to a JSON-formatted string with ISO datetime support. |
Package Contents¶
- class parseur.Document[source]¶
Document resource providing class-based API access.
- classmethod from_response(data: Dict) Dict[source]¶
Validate and deserialize a single document dict.
- classmethod log_from_response(data: Dict) Dict[source]¶
Validate and deserialize a single document log dict.
- classmethod upload_from_response(data: Dict) Dict[source]¶
Validate and deserialize a single document log dict.
- classmethod iter(mailbox_id: int, *, search: str | None = None, order_by: DocumentOrderKey | None = None, ascending: bool = True, received_after: datetime.datetime | None = None, received_before: datetime.datetime | None = None, with_result: bool = False) Iterable[Dict][source]¶
Yield all documents in a mailbox with pagination and filtering.
- Parameters:
mailbox_id – The mailbox ID to retrieve documents from.
search (str) –
Search string to filter documents. The search query parameter searches the following properties:
document id (exact match)
document name
template name
from, to, cc, and bcc email addresses
document metadata header
order_by (DocumentOrderKey) – Enum value specifying the sorting field.
ascending (bool) – Whether to sort in ascending order (True) or descending order (False).
received_after (datetime.datetime) – Filter for documents received after this date (converted to UTC YYYY-MM-DD).
received_before (datetime.datetime) – Filter for documents received before this date (converted to UTC YYYY-MM-DD).
with_result (bool) – Whether to include the parsed result in the returned documents.
- Yield dict:
Each yielded dictionary represents a document.
- classmethod list(mailbox_id: int, *, search: str | None = None, order_by: DocumentOrderKey | None = None, ascending: bool = True, received_after: datetime.datetime | None = None, received_before: datetime.datetime | None = None, with_result: bool = False) List[Dict][source]¶
- class parseur.DocumentOrderKey[source]¶
Bases:
str,enum.EnumEnumeration of supported document sorting keys.
Used with the order_by parameter to specify sorting in list_documents and yield_documents.
Members:
NAME: Sort by document name.
CREATED: Sort by created/received date.
PROCESSED: Sort by processed date.
STATUS: Sort by document status.
- NAME = 'name'¶
- CREATED = 'created'¶
- PROCESSED = 'processed'¶
- STATUS = 'status'¶
- class parseur.ParseurEvent[source]¶
Bases:
str,enum.EnumEnumeration of supported Parseur webhook event types.
Use these values when registering webhooks to specify which event to listen for.
Members:
DOCUMENT_PROCESSED: Document processed successfully.
DOCUMENT_PROCESSED_FLATTENED: Document processed as flat data.
DOCUMENT_TEMPLATE_NEEDED: Document processing failed (template needed).
DOCUMENT_EXPORT_FAILED: Export of the document failed.
TABLE_PROCESSED: A table field row was processed.
TABLE_PROCESSED_FLATTENED: A table field row (flattened) was processed.
- DOCUMENT_PROCESSED = 'document.processed'¶
- DOCUMENT_PROCESSED_FLATTENED = 'document.processed.flattened'¶
- DOCUMENT_TEMPLATE_NEEDED = 'document.template_needed'¶
- DOCUMENT_EXPORT_FAILED = 'document.export_failed'¶
- TABLE_PROCESSED = 'table.processed'¶
- TABLE_PROCESSED_FLATTENED = 'table.processed.flattened'¶
- class parseur.Mailbox[source]¶
- classmethod from_response(data: Dict) Dict[source]¶
Deserialize a single mailbox API response.
- Parameters:
data – Raw API response dictionary.
- Returns:
Validated and transformed mailbox dictionary.
- classmethod iter(*, search: str | None = None, order_by: MailboxOrderKey | None = None, ascending: bool = True) Iterable[Dict][source]¶
Yield all mailboxes with pagination and optional filtering or sorting.
- classmethod list(*, search: str | None = None, order_by: MailboxOrderKey | None = None, ascending: bool = True) List[Dict[str, Any]][source]¶
Retrieve all mailboxes as a list.
- class parseur.MailboxOrderKey[source]¶
Bases:
str,enum.EnumEnumeration of supported mailbox sorting keys.
Used with the order_by parameter to specify sorting in Mailbox.list() and Mailbox.iter().
- NAME = 'name'¶
- DOCUMENT_COUNT = 'document_count'¶
- TEMPLATE_COUNT = 'template_count'¶
- PARSEDOK_COUNT = 'PARSEDOK_count'¶
- PARSEDKO_COUNT = 'PARSEDKO_count'¶
- QUOTAEXC_COUNT = 'QUOTAEXC_count'¶
- EXPORTKO_COUNT = 'EXPORTKO_count'¶
- class parseur.DocumentStatus[source]¶
Bases:
str,enum.EnumEnum for Parseur document processing statuses.
- INCOMING = 'INCOMING'¶
- ANALYZING = 'ANALYZING'¶
- DELETED = 'DELETED'¶
- PROGRESS = 'PROGRESS'¶
- PARSEDOK = 'PARSEDOK'¶
- PARSEDKO = 'PARSEDKO'¶
- QUOTAEXC = 'QUOTAEXC'¶
- SKIPPED = 'SKIPPED'¶
- SPLIT = 'SPLIT'¶
- EXPORTKO = 'EXPORTKO'¶
- TRANSKO = 'TRANSKO'¶
- INVALID = 'INVALID'¶
- parseur.to_json(data, indent=2, sort_keys=True, ensure_ascii=False)[source]¶
Serialize a Python object to a JSON-formatted string with ISO datetime support.
This function uses the custom ISODateJSONEncoder to automatically convert datetime.datetime objects to ISO 8601 strings.
- Parameters:
data – The data to serialize (dict, list, etc.).
indent – Number of spaces to indent in the output JSON. Default is 2.
sort_keys – Whether to sort the dictionary keys in the output. Default is True.
ensure_ascii – Whether to escape non-ASCII characters. Default is False.
- Returns:
A JSON-formatted string.
- class parseur.Webhook[source]¶
- classmethod from_response(data: Dict) Dict[source]¶
Deserialize a webhook API response.
- Parameters:
data – Raw API response dictionary.
- Returns:
Deserialized webhook dictionary.
- classmethod create(event: parseur.event.ParseurEvent, target_url: str, mailbox_id: int | None = None, table_field_id: str | None = None, headers: Dict[str, str] | None = None, name: str | None = None) Dict[str, Any][source]¶
Create a new custom webhook for Parseur.
- Parameters:
event – Webhook event type (document or table event).
target_url – The URL to send webhook POSTs to.
mailbox_id – Mailbox ID (required for document events).
table_field_id – Table field ID (required for table events, e.g. “PF12345”).
headers – Optional custom HTTP headers.
name – Optional custom name for the webhook.
- Returns:
The created webhook object as a dictionary.
- classmethod retrieve(webhook_id: int) Dict[str, Any][source]¶
Retrieve a webhook from the account.
- Parameters:
webhook_id – ID of the webhook to delete.
- Returns:
The updated mailbox object as a dictionary.
- classmethod delete(webhook_id: int) bool[source]¶
Delete a webhook from the account.
- Parameters:
webhook_id – ID of the webhook to delete.
- Returns:
True if deletion was successful.
- classmethod enable(mailbox_id: int, webhook_id: int) Dict[str, Any][source]¶
Enable an existing webhook for a given mailbox.
- Parameters:
mailbox_id – ID of the mailbox.
webhook_id – ID of the webhook to enable.
- Returns:
The updated mailbox object as a dictionary.