Skip to content

Customers

Customer resource, it includes the class Resource and two request classes to create and update the resource.

Classes

facturapi.resources.customers.Customer dataclass

Customer resource

Resource for a Customer. It inherits from Creatable, Queryable, Retrievable and Updatable.

Attributes:

Name Type Description
created_at datetime.datetime

The datetime in which the resource was created.

livemode bool

If the resource was created in test or live mode.

legal_name str

Name of the customer.

tax_id str

RFC of the customer.

email str

Email of the customer.

address CustomerAddress

Address data of the model. Optional.

phone str

Phone of the customer. Defaults to None.

Methods

facturapi.resources.customers.Customer.create(data) classmethod

Create a customer.

Parameters:

Name Type Description Default
data CustomerRequest

All the request data to create a customer.

required

Returns:

Type Description
Customer

Customer: The created customer resource.

Source code in facturapi/resources/customers.py
@classmethod
def create(cls, data: CustomerRequest) -> 'Customer':
    """Create a customer.

    Args:
        data: All the request data to create a customer.

    Returns:
        Customer: The created customer resource.

    """
    cleaned_data = data.dict(exclude_unset=True, exclude_none=True)
    return cast('Customer', cls._create(**cleaned_data))
facturapi.resources.customers.Customer.update(id, data) classmethod

Update a customer.

Parameters:

Name Type Description Default
id str

ID of the customer to be updated.

required
data CustomerUpdateRequest

Data to be updated.

required

Returns:

Type Description
Customer

Customer: The udpated customer resource.

Source code in facturapi/resources/customers.py
@classmethod
def update(cls, id: str, data: CustomerUpdateRequest) -> 'Customer':
    """Update a customer.

    Args:
        id: ID of the customer to be updated.
        data: Data to be updated.

    Returns:
        Customer: The udpated customer resource.

    """
    cleaned_data = data.dict(exclude_unset=True, exclude_none=True)
    return cast('Customer', cls._update(id=id, **cleaned_data))

facturapi.resources.customers.CustomerRequest pydantic-model

This request must be filled to create a Customer. It contains all information necessary to create this resource.

Attributes:

Name Type Description
legal_name str

Full name of the customer.

tax_id str

RFC of the customer.

email str

Email of the customer.

phone str

Phone of the customer. Optional.

address CustomerAddress

Address object of the customer. Optional.

facturapi.resources.customers.CustomerUpdateRequest pydantic-model

This request must be filled to update a Customer. It contains all information necessary to update this resource.

Attributes:

Name Type Description
legal_name str

Full name of the customer. Optional.

tax_id str

RFC of the customer. Optional.

email str

Email of the customer. Optional.

phone str

Phone of the customer. Optional.

address CustomerAddress

Address object of the customer. Optional.