Monzo.Attachments (monzo_client v1.0.0)

Copy Markdown View Source

The Attachments resource: the three-step flow of requesting an upload URL, uploading raw bytes to storage, and registering the file against a transaction.

Summary

Functions

Removes a previously registered attachment.

Step 3: registers a file_url (from request_upload/2, or an externally-hosted image) against a transaction so it appears in the Monzo app's transaction detail screen.

Step 1: obtains a temporary, pre-signed URL to upload the attachment to, and the resulting public URL of the file once uploaded.

Step 2: uploads raw file bytes directly to a pre-signed URL returned by request_upload/2. This talks directly to Monzo's file storage, not the Monzo API, so it does not use the client's bearer auth or retry policy.

Types

register_params()

@type register_params() :: %{
  external_id: String.t(),
  file_url: String.t(),
  file_type: String.t()
}

upload_params()

@type upload_params() :: %{
  file_name: String.t(),
  file_type: String.t(),
  content_length: non_neg_integer()
}

upload_result()

@type upload_result() :: %{file_url: String.t(), upload_url: String.t()}

Functions

deregister(client, attachment_id)

@spec deregister(Monzo.Client.t(), String.t()) :: :ok | {:error, Exception.t()}

Removes a previously registered attachment.

register(client, arg2)

@spec register(Monzo.Client.t(), register_params()) ::
  {:ok, Monzo.Attachment.t()} | {:error, Exception.t()}

Step 3: registers a file_url (from request_upload/2, or an externally-hosted image) against a transaction so it appears in the Monzo app's transaction detail screen.

request_upload(client, arg2)

@spec request_upload(Monzo.Client.t(), upload_params()) ::
  {:ok, upload_result()} | {:error, Exception.t()}

Step 1: obtains a temporary, pre-signed URL to upload the attachment to, and the resulting public URL of the file once uploaded.

upload_bytes(client, upload_url, content, content_type)

@spec upload_bytes(Monzo.Client.t(), String.t(), iodata(), String.t()) ::
  :ok | {:error, Exception.t()}

Step 2: uploads raw file bytes directly to a pre-signed URL returned by request_upload/2. This talks directly to Monzo's file storage, not the Monzo API, so it does not use the client's bearer auth or retry policy.