Xero.Accounting.Contacts (Xero v1.0.0)

Copy Markdown View Source

Xero Accounting API – Contacts (customers and/or suppliers).

Key rules: Requests touching >100k contacts rejected (HTTP 400). Use page:, where:, and summary_only: true for large orgs.

Summary

Functions

Adds a note to a contact's history.

Lists attachments on a contact.

Returns CIS settings for a contact (UK only).

Creates one or more contacts. Requires :name (unique per org).

Retrieves a single contact by ID or account number.

Returns audit history for a contact.

Lists contacts. Options: :page, :ids, :account_number, :summary_only, :include_archived, :order, :where, :search_term, :if_modified_since

Lazy stream of all contacts.

Updates CIS settings for a contact (UK only).

Functions

add_note(token, tenant_id, contact_id, note)

@spec add_note(Xero.Auth.Token.t(), String.t(), String.t(), String.t()) ::
  {:ok, map()} | {:error, Xero.Error.t()}

Adds a note to a contact's history.

archive(token, tenant_id, contact_id)

@spec archive(Xero.Auth.Token.t(), String.t(), String.t()) ::
  {:ok, map()} | {:error, Xero.Error.t()}

Archives a contact.

attachments(token, tenant_id, contact_id)

@spec attachments(Xero.Auth.Token.t(), String.t(), String.t()) ::
  {:ok, map()} | {:error, Xero.Error.t()}

Lists attachments on a contact.

cis_settings(token, tenant_id, contact_id)

@spec cis_settings(Xero.Auth.Token.t(), String.t(), String.t()) ::
  {:ok, map()} | {:error, Xero.Error.t()}

Returns CIS settings for a contact (UK only).

create(token, tenant_id, contact_or_contacts)

@spec create(Xero.Auth.Token.t(), String.t(), map() | [map()]) ::
  {:ok, map()} | {:error, Xero.Error.t()}

Creates one or more contacts. Requires :name (unique per org).

get(token, tenant_id, contact_id)

@spec get(Xero.Auth.Token.t(), String.t(), String.t()) ::
  {:ok, map()} | {:error, Xero.Error.t()}

Retrieves a single contact by ID or account number.

history(token, tenant_id, contact_id)

@spec history(Xero.Auth.Token.t(), String.t(), String.t()) ::
  {:ok, map()} | {:error, Xero.Error.t()}

Returns audit history for a contact.

list(token, tenant_id, opts \\ [])

@spec list(Xero.Auth.Token.t(), String.t(), keyword()) ::
  {:ok, map()} | {:error, Xero.Error.t()}

Lists contacts. Options: :page, :ids, :account_number, :summary_only, :include_archived, :order, :where, :search_term, :if_modified_since

stream(token, tenant_id, opts \\ [])

@spec stream(Xero.Auth.Token.t(), String.t(), keyword()) :: Enumerable.t()

Lazy stream of all contacts.

update(token, tenant_id, contact_id, attrs)

@spec update(Xero.Auth.Token.t(), String.t(), String.t(), map()) ::
  {:ok, map()} | {:error, Xero.Error.t()}

Updates a contact.

update_cis_settings(token, tenant_id, contact_id, attrs)

@spec update_cis_settings(Xero.Auth.Token.t(), String.t(), String.t(), map()) ::
  {:ok, map()} | {:error, Xero.Error.t()}

Updates CIS settings for a contact (UK only).

upload_attachment(token, tenant_id, contact_id, filename, content, content_type)

@spec upload_attachment(
  Xero.Auth.Token.t(),
  String.t(),
  String.t(),
  String.t(),
  binary(),
  String.t()
) ::
  {:ok, map()} | {:error, Xero.Error.t()}

Uploads an attachment to a contact.