Easy-Acumatica Docs

CustomerBuilder

The `CustomerBuilder` is your primary tool for creating the JSON payload needed to create or update Customer records with the `CustomersService`. It provides a fluent, chainable interface for setting the fields of a customer record.

Importing the Builder

To get started, import the `CustomerBuilder` from the `easy_acumatica.models` module.

python

from easy_acumatica.models.customer_builder import CustomerBuilder

Builder Methods

You can set fields using either the generic `.set()` method or one of the convenient shortcut methods.

Shortcut Methods

For common fields, you can use one of the built-in shortcut methods for a cleaner syntax.

python

customer_payload = (
    CustomerBuilder()
    .customer_id("CUST001")
    .customer_name("Global Tech Inc.")
    .customer_class("DEFAULT")
)
set(field_name, value)

This is the general-purpose method for setting any field on the customer record.

python

customer_payload = CustomerBuilder()

# Use the .set() method for any field not covered by a shortcut
customer_payload.set("CreditLimit", 5000.0)
customer_payload.set("Status", "Active")
to_body()

Once you have set all the required fields, call the `.to_body()` method to generate the final dictionary, which is formatted correctly and ready to be sent as the JSON body in your API request.

python

# Build the customer payload
customer_payload = (
    CustomerBuilder()
    .customer_id("CUST001")
    .customer_name("Global Tech Inc.")
    .set("Status", "Active")
)

# Get the final dictionary
json_body = customer_payload.to_body()

# Use with the CustomersService
# client.customers.create_customer("24.200.001", builder=customer_payload)
Easy-Acumatica v0.3.9 — Created and Developed by Matthew Hirstius (Nioron07).
Significant Contributions made by Chris Xu
Want to see the NPM version? See it here