Contacts Sub Service - Nioron07/Easy-Acumatica GitHub Wiki
This page provides a guide to using the ContactsService
sub-service in easy-acumatica. You’ll learn how to import it, explore its methods and parameters, and see examples of listing, creating, updating, deactivating, and linking contacts.
1. Importing the Sub-Service
from easy_acumatica import AcumaticaClient
The ContactsService
is exposed as the .contacts
property on an authenticated AcumaticaClient
instance; no direct import is required.
2. Available Methods
Once you have an AcumaticaClient
, access the contacts API via:
service = client.contacts
Method | Signature | Description |
---|---|---|
get_contacts |
(api_version: str, options: QueryOptions = None) -> Any |
Retrieve a list of contacts, with optional $filter , $expand , etc. |
create_contact |
(api_version: str, draft: ContactBuilder) -> Any |
Create a new contact using a fluent ContactBuilder payload. |
deactivate_contact |
(api_version: str, filter_: Union[Filter,str,QueryOptions], active: bool=False) -> Any |
Soft-delete or reactivate contacts via $filter . |
update_contact |
(api_version: str, filter_: Union[Filter,str,QueryOptions], payload: Union[dict,ContactBuilder]) -> Any |
Update fields on existing contacts selected by $filter . |
delete_contact |
(api_version: str, note_id: str) -> None |
Permanently delete a contact by NoteID . |
link_contact_to_customer |
(api_version: str, contact_id: int, business_account: str, payload: Optional[Union[dict,ContactBuilder]] = None) -> Any |
Associate an existing contact with a customer account. |
3. Usage Examples
First, instantiate and authenticate:
from easy_acumatica import AcumaticaClient, QueryOptions, Filter
from easy_acumatica.models.contact_builder import ContactBuilder
client = AcumaticaClient(
base_url="https://demo.acumatica.com",
username="admin",
password="Pa$$w0rd",
tenant="Company",
branch="HQ"
)
service = client.contacts
3.1 Listing Contacts
# List all contacts in version 24.200.001
all_contacts = service.get_contacts("24.200.001")
# Filter by ContactID
opts = QueryOptions(filter=Filter().eq("ContactID", 100073))
filtered = service.get_contacts("24.200.001", options=opts)
print(filtered)
3.2 Creating a New Contact
# Build contact payload
draft = (
ContactBuilder()
.first_name("Brent")
.last_name("Edds")
.email("[email protected]")
.contact_class("ENDCUST")
.add_attribute("INTEREST", "Jam,Maint")
)
# Create contact
created = service.create_contact("24.200.001", draft)
print(created["ContactID"]["value"])
3.3 Deactivating and Reactivating
# Deactivate leads older than ID 100000
resp = service.deactivate_contact(
"24.200.001",
Filter().lt("ContactID", 100000),
active=False
)
# Reactivate a specific contact
resp2 = service.deactivate_contact(
"24.200.001",
"ContactID eq 100123",
active=True
)
3.4 Updating Contacts
# Change email for ContactID 100200
resp = service.update_contact(
"24.200.001",
Filter().eq("ContactID", 100200),
{"Email": {"value": "[email protected]"}}
)
# Or using ContactBuilder
builder = ContactBuilder().email("[email protected]")
resp2 = service.update_contact(
"24.200.001",
"ContactID eq 100200",
builder
)
3.5 Deleting a Contact
# Permanently remove by NoteID GUID
service.delete_contact("24.200.001", note_id="123e4567-e89b-12d3-a456-426614174000")
3.6 Linking to a Customer
# Associate contact 104000 with business account ABAKERY
resp = service.link_contact_to_customer(
"24.200.001",
contact_id=104000,
business_account="ABAKERY"
)
print(resp)