Skip to content

Mixins

ApiMixin

Mixin for models that require an API instance to be set.

This allows us to create model methods such as cancel, book, etc., that require an API instance to function. The API instance is set using the set_api method, and it can be accessed via the _api attribute. If the API instance is not set, calling methods that require it will raise a ValueError.

set_api

set_api(api)

Set the API instance for this model.

create classmethod

create(api, **kwargs)

Creates a new instance of the model with the given keyword arguments.

raise_if_api_not_set

raise_if_api_not_set()

Raises an error if the API instance is not set.

PhoneLongitudeLatitudeMixin

Mixin for models that require phone number, latitude, and longitude fields.

This mixin exists to make it easier to handle the various names these fields can have in different APIs.

AddressMixin

Mixin for models that require address fields.

This mixin exists to make it easier to handle the various names these fields can have in different APIs. Keep alias lists in sync with _ADDRESS_ALIAS_TO_CANONICAL in anonymize/anonymizer.py.

validate_model classmethod

validate_model(values)

Validates address fields and country format, handling specific cases.

clean_strings classmethod

clean_strings(value, **_kwargs)

Clean strings by stripping whitespace and returning None if empty.