Mercury.Recipients (mercury_client v1.0.0)

Copy Markdown View Source

The Mercury Recipients API — payment recipients and their tax form attachments.

Summary

Functions

Creates a new recipient. attrs accepts snake_case keys, e.g.

Deletes a recipient. DELETE /recipients/{id}

Returns a single recipient by ID. GET /recipients/{id}

Returns one page of recipients. GET /recipients

Returns one page of org-wide recipient tax form attachments. GET /recipients/attachments

A lazy, auto-paginating stream of every recipient.

A lazy, auto-paginating stream of every org-wide recipient tax form attachment.

Updates an existing recipient. PUT /recipients/{id}

Uploads a tax form attachment for a recipient. POST /recipients/{id}/attachments

Functions

create(client, attrs)

@spec create(client :: Mercury.Client.t(), attrs :: map() | keyword()) ::
  {:ok, Mercury.Recipient.t()} | {:error, Exception.t()}

Creates a new recipient. attrs accepts snake_case keys, e.g.:

Mercury.Recipients.create(client, %{
  name: "Acme Inc",
  emails: ["ap@acme.com"],
  electronic_routing_info: %{
    account_number: "000123456789",
    routing_number: "021000021",
    electronic_account_type: :businessChecking,
    address: %{...}
  }
})

POST /recipients

create!(client, attrs)

@spec create!(client :: Mercury.Client.t(), attrs :: map() | keyword()) ::
  Mercury.Recipient.t()

delete(client, recipient_id)

@spec delete(client :: Mercury.Client.t(), recipient_id :: String.t()) ::
  :ok | {:error, Exception.t()}

Deletes a recipient. DELETE /recipients/{id}

delete!(client, recipient_id)

@spec delete!(client :: Mercury.Client.t(), recipient_id :: String.t()) :: :ok

get(client, recipient_id)

@spec get(client :: Mercury.Client.t(), recipient_id :: String.t()) ::
  {:ok, Mercury.Recipient.t()} | {:error, Exception.t()}

Returns a single recipient by ID. GET /recipients/{id}

get!(client, recipient_id)

@spec get!(client :: Mercury.Client.t(), recipient_id :: String.t()) ::
  Mercury.Recipient.t()

list(client, opts \\ [])

@spec list(client :: Mercury.Client.t(), opts :: keyword()) ::
  {:ok, Mercury.Page.t(Mercury.Recipient.t())} | {:error, Exception.t()}

Returns one page of recipients. GET /recipients

list!(client, opts \\ [])

@spec list!(client :: Mercury.Client.t(), opts :: keyword()) ::
  Mercury.Page.t(Mercury.Recipient.t())

list_attachments(client, opts \\ [])

@spec list_attachments(client :: Mercury.Client.t(), opts :: keyword()) ::
  {:ok, Mercury.Page.t(Mercury.RecipientAttachment.t())}
  | {:error, Exception.t()}

Returns one page of org-wide recipient tax form attachments. GET /recipients/attachments

list_attachments!(client, opts \\ [])

@spec list_attachments!(client :: Mercury.Client.t(), opts :: keyword()) ::
  Mercury.Page.t(Mercury.RecipientAttachment.t())

stream(client, opts \\ [])

@spec stream(client :: Mercury.Client.t(), opts :: keyword()) :: Enumerable.t()

A lazy, auto-paginating stream of every recipient.

stream_attachments(client, opts \\ [])

@spec stream_attachments(client :: Mercury.Client.t(), opts :: keyword()) ::
  Enumerable.t()

A lazy, auto-paginating stream of every org-wide recipient tax form attachment.

update(client, recipient_id, attrs)

@spec update(
  client :: Mercury.Client.t(),
  recipient_id :: String.t(),
  attrs :: map() | keyword()
) ::
  {:ok, Mercury.Recipient.t()} | {:error, Exception.t()}

Updates an existing recipient. PUT /recipients/{id}

update!(client, recipient_id, attrs)

@spec update!(
  client :: Mercury.Client.t(),
  recipient_id :: String.t(),
  attrs :: map() | keyword()
) ::
  Mercury.Recipient.t()

upload_attachment(client, recipient_id, filename, content)

@spec upload_attachment(
  client :: Mercury.Client.t(),
  recipient_id :: String.t(),
  filename :: String.t(),
  content :: binary()
) :: {:ok, Mercury.RecipientAttachment.t()} | {:error, Exception.t()}

Uploads a tax form attachment for a recipient. POST /recipients/{id}/attachments

upload_attachment!(client, recipient_id, filename, content)

@spec upload_attachment!(
  client :: Mercury.Client.t(),
  recipient_id :: String.t(),
  filename :: String.t(),
  content :: binary()
) :: Mercury.RecipientAttachment.t()