Elixir client for the Triple transaction data enrichment API.
Quick start
client = Triple.new(api_key: System.fetch_env!("TRIPLE_API_KEY"))
{:ok, enriched} =
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"
})client is a plain Triple.Config struct — pass it explicitly
everywhere. There's no global or process-dictionary state, which keeps
the library safe to use with multiple Triple accounts/environments
(e.g. sandbox and production) side by side in the same application.
Configuration
Every option can be passed to new/1 directly, or set application-wide:
config :triple, api_key: System.fetch_env!("TRIPLE_API_KEY")See Triple.Config for the full list of options (timeouts, retries,
custom Req options, an optional client-side rate limiter, etc).
Error handling
Every call returns {:ok, result} | {:error, %Triple.Error{}}. Each
function also has a ! counterpart that raises Triple.Error instead —
e.g. enrich_transaction!/2. See Triple.Error for the fields available
on failure (HTTP status, field-level validation errors, retry-after,
etc).
Context modules
Every resource also has its own module if you'd rather call it directly:
Triple.Enrich, Triple.Brands, Triple.Feedback, Triple.Stocks,
Triple.Cryptos, Triple.TLS.
Summary
Functions
Builds a client (a Triple.Config struct). See Triple.Config.new/1 for all options.
Types
@type client() :: Triple.Config.t()
Functions
@spec enrich_transaction(client(), map() | keyword()) :: {:ok, Triple.Types.Enrich.V1.Response.t()} | {:error, Triple.Error.t()}
@spec enrich_transaction!(client(), map() | keyword()) :: Triple.Types.Enrich.V1.Response.t()
@spec enrich_unstructured_transaction(client(), map() | keyword()) :: {:ok, Triple.Types.Enrich.V2.Response.t()} | {:error, Triple.Error.t()}
@spec enrich_unstructured_transaction!(client(), map() | keyword()) :: Triple.Types.Enrich.V2.Response.t()
@spec fetch_brand(client(), String.t()) :: {:ok, Triple.Types.Brand.t()} | {:error, Triple.Error.t()}
@spec fetch_brand!(client(), String.t()) :: Triple.Types.Brand.t()
@spec fetch_crypto(client(), String.t()) :: {:ok, Triple.Types.Crypto.t()} | {:error, Triple.Error.t()}
@spec fetch_crypto!(client(), String.t()) :: Triple.Types.Crypto.t()
@spec fetch_stock(client(), String.t(), keyword()) :: {:ok, Triple.Types.Stock.t()} | {:error, Triple.Error.t()}
@spec fetch_stock!(client(), String.t(), keyword()) :: Triple.Types.Stock.t()
@spec issue_tls_certificate(client(), map() | keyword()) :: {:ok, Triple.Types.TLSCertificate.t()} | {:error, Triple.Error.t()}
@spec issue_tls_certificate!(client(), map() | keyword()) :: Triple.Types.TLSCertificate.t()
Builds a client (a Triple.Config struct). See Triple.Config.new/1 for all options.
@spec report_feedback(client(), map() | keyword()) :: {:ok, :no_content} | {:error, Triple.Error.t()}