Triple.Enrich (triple v1.0.0)

Copy Markdown View Source

Transaction enrichment — the core of the Triple API.

Two flavours:

  • transaction/2 — structured input (POST /v1/enrich-transaction/), for when you already have discrete fields (merchant name, MCC, amount, ...).
  • unstructured_transaction/2 — free-text input (POST /v2/enrich-unstructured-transaction/), for when all you have is a raw transaction description string.

Summary

Functions

Enriches a structured transaction.

Same as transaction/2, but raises Triple.Error instead of returning {:error, _}.

Enriches a raw, unstructured transaction description.

Same as unstructured_transaction/2, but raises instead of returning {:error, _}.

Functions

transaction(config, attrs)

@spec transaction(Triple.Config.t(), map() | keyword()) ::
  {:ok, Triple.Types.Enrich.V1.Response.t()} | {:error, Triple.Error.t()}

Enriches a structured transaction.

attrs is a map or keyword list matching Triple.Types.Enrich.V1.Request fields — merchant_name, transaction_type, and transaction_id are required. The payload is validated locally before any network call.

Examples

Triple.Enrich.transaction(client, %{
  merchant_name: "AMZN MKTP UK",
  transaction_type: :CARD_TRANSACTION,
  transaction_id: Triple.Util.generate_transaction_id(),
  transaction_amount: 24.99,
  transaction_currency: "GBP"
})
#=> {:ok, %Triple.Types.Enrich.V1.Response{...}}

transaction!(config, attrs)

@spec transaction!(Triple.Config.t(), map() | keyword()) ::
  Triple.Types.Enrich.V1.Response.t()

Same as transaction/2, but raises Triple.Error instead of returning {:error, _}.

unstructured_transaction(config, attrs)

@spec unstructured_transaction(Triple.Config.t(), map() | keyword()) ::
  {:ok, Triple.Types.Enrich.V2.Response.t()} | {:error, Triple.Error.t()}

Enriches a raw, unstructured transaction description.

Examples

Triple.Enrich.unstructured_transaction(client, %{
  transaction_id: Triple.Util.generate_transaction_id(),
  text: "CRD PUR 4321 NETFLIX.COM 866-5797172 CA",
  transaction_amount: 15.49,
  transaction_currency: "USD"
})
#=> {:ok, %Triple.Types.Enrich.V2.Response{...}}

unstructured_transaction!(config, attrs)

@spec unstructured_transaction!(Triple.Config.t(), map() | keyword()) ::
  Triple.Types.Enrich.V2.Response.t()

Same as unstructured_transaction/2, but raises instead of returning {:error, _}.