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);

Copyright © 2024 Laravel - All rights reserved.