paperap.resources.correspondents module

Correspondent resource module for interacting with Paperless-NgX correspondent endpoints.

This module provides the CorrespondentResource class which handles all API interactions related to correspondents in a Paperless-NgX system. Correspondents represent people or organizations that send or receive documents.

Typical usage example:
>>> # Get all correspondents
>>> correspondents = client.correspondents.all()
>>>
>>> # Create a new correspondent
>>> new_correspondent = client.correspondents.create(name="Electric Company")
>>>
>>> # Get a specific correspondent
>>> electric = client.correspondents.get(3)
class paperap.resources.correspondents.CorrespondentResource(client)[source]

Bases: StandardResource[Correspondent, CorrespondentQuerySet], BulkEditing

Resource for managing correspondents in Paperless-NgX.

This resource provides methods for creating, retrieving, updating, and deleting correspondent objects via the Paperless-NgX API. It extends the standard resource methods and incorporates bulk editing capabilities for efficient processing of multiple correspondent records.

Correspondents represent people or organizations that send or receive documents in a Paperless-NgX system. They can be used to automatically categorize documents based on matching rules.

Parameters:

client (PaperlessClient) – The PaperlessClient instance this resource is attached to.

model_class

Reference to the Correspondent model class.

Type:

Type[Correspondent]

queryset_class

Reference to the query set class for correspondents.

Type:

Type[CorrespondentQuerySet]

name

The API endpoint name for managing correspondents.

Type:

str

Examples

Create a new correspondent:

>>> new_correspondent = client.correspondents.create(
...     name="Electric Company",
...     matching_algorithm="auto",
...     match="electric"
... )

Retrieve a correspondent by ID:

>>> correspondent = client.correspondents.get(3)
>>> print(correspondent.name)

Update a correspondent:

>>> correspondent = client.correspondents.get(3)
>>> correspondent.name = "Updated Name"
>>> correspondent.save()

Delete a correspondent:

>>> correspondent = client.correspondents.get(3)
>>> correspondent.delete()

Filter correspondents:

>>> electric_correspondents = client.correspondents().filter(
...     name__icontains="electric"
... )

Bulk operations on correspondents:

>>> # Get all correspondents with "Company" in the name
>>> company_correspondents = client.correspondents().filter(name__icontains="Company")
>>> # Update all of them at once
>>> company_correspondents.update(matching_algorithm="auto")
model_class

alias of Correspondent

queryset_class

alias of CorrespondentQuerySet

name: str = 'correspondents'
endpoints: ClassVar[Endpoints] = {'create': <string.Template object>, 'delete': <string.Template object>, 'detail': <string.Template object>, 'list': <string.Template object>, 'update': <string.Template object>}