Codat.Platform.Companies (codat v1.0.0)

Copy Markdown View Source

Manage Codat companies (your customers).

A company represents a customer's business entity. Every piece of financial data is scoped to a company.

Example

{:ok, company} = Codat.Platform.Companies.create(client, %{name: "Acme Corp"})
redirect_to(company["redirect"])

Summary

Functions

Permanently deletes a company and all its data.

Fetches a single company by ID.

Generates a short-lived access token for the Link flow.

Returns a paginated list of companies.

Returns a lazy Stream of all companies.

Updates a company's name, description, or tags.

Functions

create(client_or_body, body_or_opts \\ [])

@spec create(Codat.Client.t() | map(), map() | keyword()) ::
  {:ok, map()} | {:error, Codat.Error.t()}

Creates a new company.

Example

{:ok, company} = Codat.Platform.Companies.create(client, %{
  name: "Acme Corp",
  tags: %{"tenant_id" => "t_123"}
})

delete(client_or_id, id_or_opts \\ [])

@spec delete(Codat.Client.t() | String.t(), String.t() | keyword()) ::
  {:ok, nil} | {:error, Codat.Error.t()}

Permanently deletes a company and all its data.

get(client_or_id, id_or_opts \\ [])

@spec get(Codat.Client.t() | String.t(), String.t() | keyword()) ::
  {:ok, map()} | {:error, Codat.Error.t()}

Fetches a single company by ID.

get_access_token(client_or_id, id_or_opts \\ [])

@spec get_access_token(Codat.Client.t() | String.t(), String.t() | keyword()) ::
  {:ok, map()} | {:error, Codat.Error.t()}

Generates a short-lived access token for the Link flow.

list(client_or_opts \\ [], opts \\ [])

@spec list(
  Codat.Client.t() | keyword(),
  keyword()
) :: {:ok, Codat.Pagination.t()} | {:error, Codat.Error.t()}

Returns a paginated list of companies.

Options

  • :page, :page_size — pagination
  • :query — filter string
  • :order_by — sort field
  • :tags — filter by tag, e.g. "region:us-east-1"

stream(client_or_opts \\ [], opts \\ [])

@spec stream(
  Codat.Client.t() | keyword(),
  keyword()
) :: Enumerable.t()

Returns a lazy Stream of all companies.

update(client_or_id, id_or_body, body_or_opts \\ [])

@spec update(Codat.Client.t() | String.t(), String.t() | map(), map() | keyword()) ::
  {:ok, map()} | {:error, Codat.Error.t()}

Updates a company's name, description, or tags.

Warning: Always include all tags you wish to retain. An empty tags map removes all existing tags.