Currently seeking new career opportunities in web development, particularly with Laravel, Hire Me
Laravel Xero

Contacts

Xero provides a clean way of working with Xero contacts.

To work with contacts first call ->contacts() followed by a method.

Xero::contacts();

List Contacts

To list contacts call the contacts()->get() method.

Xero docs for listing contacts - https://developer.xero.com/documentation/api/contacts#GET

The optional parameters are $page and $where. $page defaults to 1 which means being back on the first page, for additional pages enter higher page numbers until there are no pages left to return. The API does not offer a count to determine how many pages there are.

Xero::contacts()->get(int $page = 1, string $where = null);

$where allows for filter options to be passed, the most common filters have been optimised to ensure performance across organisations of all sizes. We recommend you restrict your filtering to the following optimised parameters.

Filter by name:

Xero::contacts()->get(1, 'Name="ABC limited"');

Filter by email:

Xero::contacts()->get(1, 'EmailAddress="email@example.com"');

Filter by account number:

Xero::contacts()->get(1, 'AccountNumber="ABC-100"');

View Contacts

To view a single contact a find method can be called passing in the contact id

Xero::contacts()->find(string $contactId);

Create Contacts

To create a contact call a store method passing in an array of contact data:

See https://developer.xero.com/documentation/api/contacts#POST for the array contents specifications

Xero::contacts()->store($data);

Update Contacts

To update a contact 2 params are required the contact Id and an array of data to be updated:

See https://developer.xero.com/documentation/api/contacts#POST for details on the fields that can be updated.

Xero::contacts()->update($contactId, $data);
Laravel Modules Your Logo Your Logo Your Logo

Become a sponsor

Help support the blog so that I can continue creating new content!

Sponsor

My Latest Book

Modular Laravel Book - Laravel: The Modular way

Learn how to build modular applications with Laravel Find out more

Subscribe to my newsletter

Subscribe and get my books and product announcements.

Learn Laravel with Laracasts

Faster Laravel Hosting

© 2006 - 2024 DC Blog. All code MIT license. All rights reserved.