Skip to content

Latest commit

 

History

History
259 lines (181 loc) · 24.9 KB

File metadata and controls

259 lines (181 loc) · 24.9 KB

Customers

(customers)

Overview

Available Operations

  • list - List all customers
  • create - Create customer
  • get - Retrieve a customer
  • delete - Delete a customer
  • update - Update a customer

list

Retrieve a list of customers for the authenticated team.

Example Usage

from midday import Midday


with Midday(
    token="MIDDAY_API_KEY",
) as m_client:

    res = m_client.customers.list(q="acme", sort=[
        "name",
        "asc",
    ], cursor="eyJpZCI6IjEyMyJ9", page_size=20)

    # Handle response
    print(res)

Parameters

Parameter Type Required Description Example
q OptionalNullable[str] N/A acme
sort List[str] N/A [
"name",
"asc"
]
cursor Optional[str] N/A eyJpZCI6IjEyMyJ9
page_size Optional[float] N/A 20
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.ListCustomersResponse

Errors

Error Type Status Code Content Type
errors.APIError 4XX, 5XX */*

create

Create a new customer for the authenticated team.

Example Usage

from midday import Midday


with Midday(
    token="MIDDAY_API_KEY",
) as m_client:

    res = m_client.customers.create(request={
        "id": "b3b7c1e2-4c2a-4e7a-9c1a-2b7c1e24c2a4",
        "name": "Acme Corporation",
        "email": "contact@acme.com",
        "country": "United States",
        "address_line1": "123 Main Street",
        "address_line2": "Suite 400",
        "city": "San Francisco",
        "state": "California",
        "zip": "94105",
        "phone": "+1-555-123-4567",
        "website": "https://acme.com",
        "note": "Preferred contact method is email. Large enterprise client.",
        "vat_number": "US123456789",
        "country_code": "US",
        "contact": "John Smith",
        "tags": [
            {
                "id": "e7a9c1a2-4c2a-4e7a-9c1a-2b7c1e24c2a4",
                "name": "VIP",
            },
            {
                "id": "f1b2c3d4-5678-4e7a-9c1a-2b7c1e24c2a4",
                "name": "Enterprise",
            },
        ],
    })

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
request models.CreateCustomerRequest ✔️ The request object to use for the request.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.CreateCustomerResponse

Errors

Error Type Status Code Content Type
errors.APIError 4XX, 5XX */*

get

Retrieve a customer by ID for the authenticated team.

Example Usage

from midday import Midday


with Midday(
    token="MIDDAY_API_KEY",
) as m_client:

    res = m_client.customers.get(id="b3b7c1e2-4c2a-4e7a-9c1a-2b7c1e24c2a4")

    # Handle response
    print(res)

Parameters

Parameter Type Required Description Example
id str ✔️ N/A b3b7c1e2-4c2a-4e7a-9c1a-2b7c1e24c2a4
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.GetCustomerByIDResponse

Errors

Error Type Status Code Content Type
errors.APIError 4XX, 5XX */*

delete

Delete a customer by ID for the authenticated team.

Example Usage

from midday import Midday


with Midday(
    token="MIDDAY_API_KEY",
) as m_client:

    res = m_client.customers.delete(id="b3b7c1e2-4c2a-4e7a-9c1a-2b7c1e24c2a4")

    # Handle response
    print(res)

Parameters

Parameter Type Required Description Example
id str ✔️ N/A b3b7c1e2-4c2a-4e7a-9c1a-2b7c1e24c2a4
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.DeleteCustomerResponse

Errors

Error Type Status Code Content Type
errors.APIError 4XX, 5XX */*

update

Update a customer by ID for the authenticated team.

Example Usage

from midday import Midday


with Midday(
    token="MIDDAY_API_KEY",
) as m_client:

    res = m_client.customers.update(id_param="b3b7c1e2-4c2a-4e7a-9c1a-2b7c1e24c2a4", name="Acme Corporation", email="contact@acme.com", id="b3b7c1e2-4c2a-4e7a-9c1a-2b7c1e24c2a4", country="United States", address_line1="123 Main Street", address_line2="Suite 400", city="San Francisco", state="California", zip="94105", phone="+1-555-123-4567", website="https://acme.com", note="Preferred contact method is email. Large enterprise client.", vat_number="US123456789", country_code="US", contact="John Smith", tags=[
        {
            "id": "e7a9c1a2-4c2a-4e7a-9c1a-2b7c1e24c2a4",
            "name": "VIP",
        },
        {
            "id": "f1b2c3d4-5678-4e7a-9c1a-2b7c1e24c2a4",
            "name": "Enterprise",
        },
    ])

    # Handle response
    print(res)

Parameters

Parameter Type Required Description Example
id_param str ✔️ N/A b3b7c1e2-4c2a-4e7a-9c1a-2b7c1e24c2a4
name str ✔️ Name of the customer or organization Acme Corporation
email str ✔️ Primary email address of the customer contact@acme.com
id Optional[str] Unique identifier of the customer. Required for updates, omit for new customers b3b7c1e2-4c2a-4e7a-9c1a-2b7c1e24c2a4
country OptionalNullable[str] Country name where the customer is located United States
address_line1 OptionalNullable[str] First line of the customer's address 123 Main Street
address_line2 OptionalNullable[str] Second line of the customer's address (suite, apartment, etc.) Suite 400
city OptionalNullable[str] City where the customer is located San Francisco
state OptionalNullable[str] State or province where the customer is located California
zip OptionalNullable[str] ZIP or postal code of the customer's address 94105
phone OptionalNullable[str] Primary phone number of the customer +1-555-123-4567
website OptionalNullable[str] Website URL of the customer https://acme.com
note OptionalNullable[str] Internal notes about the customer for team reference Preferred contact method is email. Large enterprise client.
vat_number OptionalNullable[str] VAT (Value Added Tax) number of the customer US123456789
country_code OptionalNullable[str] Country code in ISO 3166-1 alpha-2 format US
contact OptionalNullable[str] Primary contact person's name at the customer organization John Smith
tags List[models.UpdateCustomerTagRequest] Array of tags to associate with the customer for categorization [
{
"id": "e7a9c1a2-4c2a-4e7a-9c1a-2b7c1e24c2a4",
"name": "VIP"
},
{
"id": "f1b2c3d4-5678-4e7a-9c1a-2b7c1e24c2a4",
"name": "Enterprise"
}
]
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.UpdateCustomerResponse

Errors

Error Type Status Code Content Type
errors.APIError 4XX, 5XX */*