ORM Model Classes

class pypipedrive.orm.model.Model(**fields)[source]

Model class. custom_ is a reserved keyword for Pipedrive entity custom fields that map to field api key.

classmethod batch_delete(ids: List[str | int] = [], models: List[Self] = [], version: str = None) ApiResponse[source]

Marks multiple entities as deleted. After 30 days, the entities will be permanently deleted. ids and models are mutually exclusive.

Args:

ids: A list of model IDs to delete. models: A list of model instances to delete.

delete() bool[source]

Marks the record as deleted. After 30 days, the record will be permanently deleted.

exists() bool[source]

Check if the instance exists in Pipedrive.

fetch() None[source]

Fetch field values from the API and resets instance field values.

classmethod from_record(**record: Dict)[source]

Build an internal instance from the Pipedrive object.

save(*, force: bool = False, additional_params: Dict = {}) SaveResult[source]

Create/Save the resource into Pipedrive.

If the instance does not exist already, it will be created. Otherwise, the existing record will be updated, using only the fields which have been modified since it was retrieved.

Args:

force: If True, all fields will be saved, even if they have not changed. additional_params: Additional parameters for saving the resource.

to_record(only_writable: bool = False) Dict[source]

This method converts internal field values into values expected by Pipedrive. For example, a datetime value is converted into an ISO 8601 string.

Warning: A limitation of this method is that field keys are the attributes names and not the Pipedrive field names. Some work need to be done in order to correctly map those fields as well as set the custom fields properly under the custom_fields key.

Args:
only_writable: If True, the result will exclude any

values which are associated with readonly fields.

class pypipedrive.orm.model.SaveResult(*, id: int | str, created: bool = False, updated: bool = False, forced: bool = False, field_names: ~typing.Set[str] = <factory>)[source]

Represents the result of saving a record to the API. The result’s attributes contain more granular information about the save operation:

>>> result = model.save()
>>> result.id
123
>>> result.created
False
>>> result.updated
True
>>> result.forced
False
>>> result.field_names
{'Name', 'Email'}

If none of the model’s fields have changed, calling save() will not perform any API requests and will return a SaveResult with no changes.

>>> model = Model()
>>> result = model.save()
>>> result.saved
True
>>> second_result = model.save()
>>> second_result.saved
False
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

property saved: bool

Whether the record was saved to the API. If False, this indicates there were no changes to the model and the save() operation was not forced.