Documentation
¶
Overview ¶
Package triple is a Go client for the Triple (https://jointriple.com) transaction data enrichment API.
Quick start ¶
client, err := triple.NewClient(os.Getenv("TRIPLE_API_KEY"))
if err != nil {
log.Fatal(err)
}
enriched, err := client.Enrich.Transaction(ctx, v1.Request{
MerchantName: "AMZN MKTP UK",
TransactionType: v1.TransactionTypeCardTransaction,
TransactionID: idgen.GenerateTransactionID(),
TransactionAmount: ptr(24.99),
TransactionCurrency: "GBP",
})
A *Client is safe for concurrent use by multiple goroutines, and safe to build more than one of (e.g. one per tenant, or one for sandbox and one for production) side by side in the same process — there's no global or package-level state.
Configuration ¶
Every option is passed to NewClient as a functional Option — see WithEnvironment, WithBaseURL, WithReceiveTimeout, WithMaxRetries, WithRateLimiter, WithHooks, and so on.
Error handling ¶
Every call returns (result, error). On failure, error is always an *apierror.Error — use errors.As to inspect its Type, Status, Errors (field-level validation messages), and RetryAfter fields.
Domain services ¶
Every resource has its own service, reachable as a field on *Client: Enrich, Brands, Feedback, Stocks, Cryptos, TLS. Each is also usable standalone (e.g. enrich.New(transportClient)) if you want to compose your own client.
Index ¶
Constants ¶
const ( EnvironmentProduction = transport.EnvironmentProduction EnvironmentSandbox = transport.EnvironmentSandbox )
The recognized Environment values, re-exported from package transport.
Variables ¶
var ( WithEnvironment = transport.WithEnvironment WithBaseURL = transport.WithBaseURL WithControlBaseURL = transport.WithControlBaseURL WithReceiveTimeout = transport.WithReceiveTimeout WithConnectTimeout = transport.WithConnectTimeout WithShouldRetry = transport.WithShouldRetry WithMaxRetries = transport.WithMaxRetries WithHTTPClient = transport.WithHTTPClient WithHooks = transport.WithHooks WithRateLimiter = transport.WithRateLimiter WithUserAgent = transport.WithUserAgent WithLogger = transport.WithLogger )
Functional options, re-exported from package transport for convenience.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// Enrich enriches structured and unstructured transactions.
Enrich *enrich.Service
// Brands looks up brands by id.
Brands *brands.Service
// Feedback reports incorrect or missing enrichment data.
Feedback *feedback.Service
// Stocks looks up brokerage products (stocks/funds) by ISIN.
Stocks *stocks.Service
// Cryptos looks up cryptocurrencies by slug.
Cryptos *cryptos.Service
// TLS issues mTLS client certificates.
TLS *tlscert.Service
// contains filtered or unexported fields
}
Client is the entry point to the Triple API. Build one with NewClient.
func NewClient ¶
NewClient builds a Client for the given API key, applying any Options. Environment is inferred from the key's prefix ("tr_test_" for sandbox, "tr_live_" for production) unless overridden with WithEnvironment.
It returns an error if apiKey is empty, or if the environment can't be inferred and wasn't set explicitly.
func NewClientFromConfig ¶
NewClientFromConfig builds a Client from a fully-constructed transport.Config, bypassing NewClient's validation and defaulting. Most callers should use NewClient instead; this is exposed for advanced use (e.g. tests that need full control over the config).
type Environment ¶
type Environment = transport.Environment
Environment selects which Triple host a Client talks to.
type Option ¶
type Option = transport.ConfigOption
Option configures optional Client settings via NewClient.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package apierror defines the structured error type returned by every call in the triple-go SDK: local validation failures, Triple API error responses, and transport-level failures all surface as an *Error.
|
Package apierror defines the structured error type returned by every call in the triple-go SDK: local validation failures, Triple API error responses, and transport-level failures all surface as an *Error. |
|
Package brands provides brand lookups — fetch a brand's canonical name/logo by id.
|
Package brands provides brand lookups — fetch a brand's canonical name/logo by id. |
|
Package cryptos provides cryptocurrency lookups by slug.
|
Package cryptos provides cryptocurrency lookups by slug. |
|
Package enrich implements transaction enrichment — the core of the Triple API.
|
Package enrich implements transaction enrichment — the core of the Triple API. |
|
v1
Package v1 holds the request/response types for the v1 (structured) transaction enrichment endpoint: POST /v1/enrich-transaction/.
|
Package v1 holds the request/response types for the v1 (structured) transaction enrichment endpoint: POST /v1/enrich-transaction/. |
|
v2
Package v2 holds the request/response types for the v2 (unstructured) transaction enrichment endpoint: POST /v2/enrich-unstructured-transaction/.
|
Package v2 holds the request/response types for the v2 (unstructured) transaction enrichment endpoint: POST /v2/enrich-unstructured-transaction/. |
|
Package feedback reports incorrect or missing enrichment data back to Triple, helping its models improve over time.
|
Package feedback reports incorrect or missing enrichment data back to Triple, helping its models improve over time. |
|
Package idgen provides small stateless ID-generation helpers shared across the triple-go SDK.
|
Package idgen provides small stateless ID-generation helpers shared across the triple-go SDK. |
|
Package ratelimiter provides optional, opt-in client-side rate limiting for the triple-go SDK.
|
Package ratelimiter provides optional, opt-in client-side rate limiting for the triple-go SDK. |
|
Package resource defines the visual-asset type shared by the stocks and cryptos domains.
|
Package resource defines the visual-asset type shared by the stocks and cryptos domains. |
|
Package stocks provides brokerage product (stock/fund) lookups by ISIN.
|
Package stocks provides brokerage product (stock/fund) lookups by ISIN. |
|
Package telemetry defines the observability hooks emitted by the transport around each HTTP call.
|
Package telemetry defines the observability hooks emitted by the transport around each HTTP call. |
|
Package tlscert issues mTLS client certificates against Triple's control-plane host (a different host from the main enrichment/data API — see transport.Config.ControlBaseURL).
|
Package tlscert issues mTLS client certificates against Triple's control-plane host (a different host from the main enrichment/data API — see transport.Config.ControlBaseURL). |
|
Package transport provides the low-level HTTP plumbing shared by every domain package in the triple-go SDK: request building, authentication, timeouts, retries with backoff, an optional client-side rate limiter, and telemetry hooks.
|
Package transport provides the low-level HTTP plumbing shared by every domain package in the triple-go SDK: request building, authentication, timeouts, retries with backoff, an optional client-side rate limiter, and telemetry hooks. |
|
Package validate provides small, composable field validators used by the request types in each domain package.
|
Package validate provides small, composable field validators used by the request types in each domain package. |