LeadBuilder
The `LeadBuilder` is a simple tool for creating the JSON payload needed to create new Lead records with the `LeadsService`. It provides a fluent, chainable interface for setting the most common fields of a lead record.
Importing the Builder
To get started, import the `LeadBuilder` from the `easy_acumatica.models` module.
from easy_acumatica.models.lead_builder import LeadBuilder
Builder Methods
Shortcut Methods
For the most common lead fields, you can use one of the built-in shortcut methods.
lead_payload = (
LeadBuilder()
.first_name("Brent")
.last_name("Edds")
.email("brent.edds.test@example.com")
)
.set(field_name, value)
This is the general-purpose method for setting any other field on the lead record that may not have a dedicated shortcut.
# Use .set() to add other fields like CompanyName
lead_payload = (
LeadBuilder()
.first_name("Maria")
.set("CompanyName", "Global Innovations")
)
.to_body()
Once you have set all the required fields, call `.to_body()` to generate the final dictionary, ready to be sent as the JSON body in your API request.
# Build the lead payload
lead_payload = (
LeadBuilder()
.first_name("Maria")
.last_name("Sanchez")
.email("maria.s@example.com")
)
# Get the final dictionary
json_body = lead_payload.to_body()
# Use with the LeadsService
# client.leads.create_lead("24.200.001", builder=lead_payload)
ON THIS PAGE
Introduction
Importing Builder
Builder Methods
- Shortcut Methods
- .set()
- .to_body()