Documentation
¶
Overview ¶
Package unit is a complete, production-grade Go client for the Unit (unit.co) embedded banking API. It follows a domain-driven design: each bounded context (applications, customers, accounts, cards, payments, transactions, counterparties, repayments, recurring payments, check deposits, check payments, stop payments, chargebacks, statements, webhooks, events, tokens, institutions, authorizations, sandbox) is its own package under domain/, built on the shared transport and JSON:API infrastructure in internal/.
Construction is always explicit -- there is no global client or package level state:
client, err := unit.New(unit.Config{Token: os.Getenv("UNIT_TOKEN")})
if err != nil {
log.Fatal(err)
}
acc, err := client.Accounts.Get(ctx, "12345")
For production, set Config.BaseURL to "https://api.unit.co"; the default points at Unit's sandbox host.
Index ¶
Constants ¶
const DefaultBaseURL = transport.DefaultBaseURL
DefaultBaseURL is Unit's sandbox API host.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
Applications application.Service
Customers customer.Service
Accounts account.Service
Cards card.Service
Payments payment.Service
Transactions transaction.Service
Counterparties counterparty.Service
Repayments repayment.Service
RecurringPayments recurringpayment.Service
CheckDeposits checkdeposit.Service
CheckPayments checkpayment.Service
StopPayments stoppayment.Service
Chargebacks chargeback.Service
Statements statement.Service
Webhooks webhook.Service
Events event.Service
Tokens token.Service
Institutions institution.Service
Authorizations authorization.Service
Sandbox sandbox.Service
// contains filtered or unexported fields
}
Client is the complete Unit API surface, organized as one field per bounded context. Every field is a Service interface, which makes each context independently mockable in tests -- callers needing to unit test code that depends on, say, Client.Accounts can substitute a fake account.Service without touching the rest of Client.
type Error ¶
Error is the typed error returned for every failed API call. See transport.Error for field docs.
type RetryPolicy ¶
type RetryPolicy = transport.RetryPolicy
RetryPolicy configures automatic retry behaviour. See transport.RetryPolicy for field docs.
func DefaultRetryPolicy ¶
func DefaultRetryPolicy() RetryPolicy
DefaultRetryPolicy returns unit-go's default exponential-backoff retry policy (see transport.DefaultRetryPolicy).
func NoRetry ¶
func NoRetry() RetryPolicy
NoRetry returns a RetryPolicy that disables automatic retries.
Directories
¶
| Path | Synopsis |
|---|---|
|
domain
|
|
|
account
Package account is the Accounts bounded context: deposit account lifecycle (create, freeze/unfreeze, close), limits, and balance history.
|
Package account is the Accounts bounded context: deposit account lifecycle (create, freeze/unfreeze, close), limits, and balance history. |
|
application
Package application is the Applications bounded context: creating and tracking individual (KYC) and business (KYB) onboarding applications, and uploading supporting documents.
|
Package application is the Applications bounded context: creating and tracking individual (KYC) and business (KYB) onboarding applications, and uploading supporting documents. |
|
authorization
Package authorization is the Authorizations bounded context: reading pending card authorizations, which settle into purchaseTransactions or are reversed if declined/expired.
|
Package authorization is the Authorizations bounded context: reading pending card authorizations, which settle into purchaseTransactions or are reversed if declined/expired. |
|
card
Package card is the Cards bounded context: issuing individual/business, debit/credit, virtual/physical cards, and managing their lifecycle (freeze, report lost/stolen, activate, replace).
|
Package card is the Cards bounded context: issuing individual/business, debit/credit, virtual/physical cards, and managing their lifecycle (freeze, report lost/stolen, activate, replace). |
|
chargeback
Package chargeback is the Chargebacks bounded context: disputing card transactions on behalf of a customer.
|
Package chargeback is the Chargebacks bounded context: disputing card transactions on behalf of a customer. |
|
checkdeposit
Package checkdeposit is the Check Deposits bounded context: mobile remote check deposit, including front/back image upload.
|
Package checkdeposit is the Check Deposits bounded context: mobile remote check deposit, including front/back image upload. |
|
checkpayment
Package checkpayment is the Check Payments bounded context: print-and-mail outgoing check payments, cancellation, returns, and retrieving the rendered check image.
|
Package checkpayment is the Check Payments bounded context: print-and-mail outgoing check payments, cancellation, returns, and retrieving the rendered check image. |
|
counterparty
Package counterparty is the Counterparties bounded context: saved external bank accounts used as the destination for ACH payments.
|
Package counterparty is the Counterparties bounded context: saved external bank accounts used as the destination for ACH payments. |
|
customer
Package customer is the Customers bounded context: reading, updating, archiving customers, and managing authorized users on individual customers.
|
Package customer is the Customers bounded context: reading, updating, archiving customers, and managing authorized users on individual customers. |
|
event
Package event is the Events bounded context: querying the last 90 days of account/webhook events and requesting redelivery ("fire") for replay.
|
Package event is the Events bounded context: querying the last 90 days of account/webhook events and requesting redelivery ("fire") for replay. |
|
institution
Package institution is the Institutions bounded context: looking up receiving-bank details by ACH/wire routing number.
|
Package institution is the Institutions bounded context: looking up receiving-bank details by ACH/wire routing number. |
|
payment
Package payment is the Payments bounded context: originating ACH (same- day and standard), Wire, Book, and Bulk payments, and managing received ACH payments.
|
Package payment is the Payments bounded context: originating ACH (same- day and standard), Wire, Book, and Bulk payments, and managing received ACH payments. |
|
recurringpayment
Package recurringpayment is the Recurring Payments bounded context: scheduled recurring ACH/book payments and recurring credit-account repayments on a configurable interval.
|
Package recurringpayment is the Recurring Payments bounded context: scheduled recurring ACH/book payments and recurring credit-account repayments on a configurable interval. |
|
repayment
Package repayment is the Repayments bounded context: one-off book/ACH repayments toward a credit account, including the capital-partner variants used in partner-funded credit programs.
|
Package repayment is the Repayments bounded context: one-off book/ACH repayments toward a credit account, including the capital-partner variants used in partner-funded credit programs. |
|
sandbox
Package sandbox is the Sandbox bounded context: simulating inbound events (received ACH/wire, card transactions, chargebacks, check deposit clearing, application document review) against Unit's sandbox environment.
|
Package sandbox is the Sandbox bounded context: simulating inbound events (received ACH/wire, card transactions, chargebacks, check deposit clearing, application document review) against Unit's sandbox environment. |
|
statement
Package statement is the Statements bounded context: listing account statements and retrieving them as HTML or PDF (including bank-branded PDF).
|
Package statement is the Statements bounded context: listing account statements and retrieving them as HTML or PDF (including bank-branded PDF). |
|
stoppayment
Package stoppayment is the Stop Payments bounded context: placing ACH and check stop-payment orders on an account.
|
Package stoppayment is the Stop Payments bounded context: placing ACH and check stop-payment orders on an account. |
|
token
Package token is the Tokens bounded context: issuing scoped bearer tokens for customers, cardholders, and org-level service accounts, and verifying two-factor codes to elevate a customer token's scope.
|
Package token is the Tokens bounded context: issuing scoped bearer tokens for customers, cardholders, and org-level service accounts, and verifying two-factor codes to elevate a customer token's scope. |
|
transaction
Package transaction is the Transactions bounded context: reading the full transaction ledger for an account (purchases, ACH, wire, book, fees, interest, dishonored/return transactions, and more) and tagging them.
|
Package transaction is the Transactions bounded context: reading the full transaction ledger for an account (purchases, ACH, wire, book, fees, interest, dishonored/return transactions, and more) and tagging them. |
|
webhook
Package webhook is the Webhooks bounded context: managing subscription lifecycle for Unit's event webhooks, and verifying inbound webhook signatures.
|
Package webhook is the Webhooks bounded context: managing subscription lifecycle for Unit's event webhooks, and verifying inbound webhook signatures. |
|
internal
|
|
|
jsonapi
Package jsonapi implements just enough of the JSON:API specification (https://jsonapi.org) to speak Unit's wire protocol: resource objects, to-one/to-many relationships, top-level documents, included resources, and cursor-based pagination links.
|
Package jsonapi implements just enough of the JSON:API specification (https://jsonapi.org) to speak Unit's wire protocol: resource objects, to-one/to-many relationships, top-level documents, included resources, and cursor-based pagination links. |
|
transport
Package transport is the infrastructure layer shared by every domain package: it owns the HTTP round trip, authentication, retry/backoff, idempotency key injection, and JSON:API (de)serialization.
|
Package transport is the infrastructure layer shared by every domain package: it owns the HTTP round trip, authentication, retry/backoff, idempotency key injection, and JSON:API (de)serialization. |
|
Package shared contains the shared-kernel value objects used across every bounded context in unit-go: money, addresses, names, phone numbers, tags, and JSON:API relationship pointers.
|
Package shared contains the shared-kernel value objects used across every bounded context in unit-go: money, addresses, names, phone numbers, tags, and JSON:API relationship pointers. |
|
Package telemetry defines the instrumentation hooks unit-go emits around every outbound request, mirroring the [:unit, :request, :start/:stop/ :exception] and retry events from the Elixir `unit` package.
|
Package telemetry defines the instrumentation hooks unit-go emits around every outbound request, mirroring the [:unit, :request, :start/:stop/ :exception] and retry events from the Elixir `unit` package. |