Documentation
¶
Overview ¶
Package ranjit defines the public API types and Go client.
Index ¶
- Variables
- func NewID(prefix string) string
- func StableID(prefix, owner, externalID string) string
- func ValidIdempotencyKey(key string) bool
- type APIError
- type Account
- type CertificateStatus
- type Client
- func (c *Client) Accounts(ctx context.Context, connectionID, cursor string, limit int) (Page[Account], error)
- func (c *Client) Connect(ctx context.Context, input ConnectRequest) (ConnectResponse, error)
- func (c *Client) ConnectWithKey(ctx context.Context, input ConnectRequest, key string) (ConnectResponse, error)
- func (c *Client) Connection(ctx context.Context, id string) (Connection, error)
- func (c *Client) Connections(ctx context.Context, customer, cursor string, limit int) (Page[Connection], error)
- func (c *Client) Diagnostics(ctx context.Context) (Diagnostics, error)
- func (c *Client) Health(ctx context.Context) error
- func (c *Client) Import(ctx context.Context, input io.Reader, opts ImportOptions) (ImportResult, error)
- func (c *Client) Institutions(ctx context.Context) (Page[Institution], error)
- func (c *Client) IterAccounts(ctx context.Context, connectionID string, limit int) iter.Seq2[Account, error]
- func (c *Client) IterConnections(ctx context.Context, customer string, limit int) iter.Seq2[Connection, error]
- func (c *Client) IterSearchTransactions(ctx context.Context, filter TransactionFilter) iter.Seq2[Transaction, error]
- func (c *Client) IterTransactions(ctx context.Context, accountID string, limit int) iter.Seq2[Transaction, error]
- func (c *Client) Job(ctx context.Context, id string) (Job, error)
- func (c *Client) Pause(ctx context.Context, id string) error
- func (c *Client) PreviewImport(ctx context.Context, input io.Reader, opts ImportOptions) (ImportPreview, error)
- func (c *Client) Ready(ctx context.Context) error
- func (c *Client) Renew(ctx context.Context, id string) (Connection, error)
- func (c *Client) RetryWebhook(ctx context.Context, eventID string) error
- func (c *Client) Revoke(ctx context.Context, connectionID string) error
- func (c *Client) SearchTransactions(ctx context.Context, f TransactionFilter) (Page[Transaction], error)
- func (c *Client) Status(ctx context.Context, connectionID string) (ConnectionStatus, error)
- func (c *Client) Sync(ctx context.Context, connectionID string) (Job, error)
- func (c *Client) Transactions(ctx context.Context, accountID, cursor string, limit int) (Page[Transaction], error)
- func (c *Client) WebhookDeliveries(ctx context.Context, cursor string, limit int) (Page[WebhookDelivery], error)
- type ConnectRequest
- type ConnectResponse
- type Connection
- type ConnectionStatus
- type Diagnostics
- type ImportOptions
- type ImportPreview
- type ImportResult
- type ImportSample
- type Institution
- type Job
- type Money
- type OperationsStatus
- type Page
- type QueueStatus
- type RetryPolicy
- type Transaction
- type TransactionFilter
- type WebhookData
- type WebhookDelivery
- type WebhookEvent
- type WorkerStatus
Constants ¶
This section is empty.
Variables ¶
var ( ErrRateLimited = errors.New("rate limited") ErrResponseTooLarge = errors.New("response exceeds 1 MiB") ErrInvalidResponse = errors.New("invalid response") ErrWebhookState = errors.New("webhook is not failed or does not belong to the configured endpoint") ErrIdempotency = errors.New("idempotency key was already used with a different request") ErrNotFound = errors.New("not found") ErrConflict = errors.New("connection is not active") ErrInvalid = errors.New("invalid input") ErrConsent = errors.New("authorization link is invalid, expired or already used") ErrLease = errors.New("job lease is no longer valid") ErrProviderCredentials = errors.New("provider credentials are invalid, missing required scopes or have changed") )
Functions ¶
func ValidIdempotencyKey ¶ added in v0.4.0
Types ¶
type CertificateStatus ¶ added in v0.4.0
type Client ¶
type Client struct {
ReadRetries RetryPolicy
HTTPClient *http.Client
// contains filtered or unexported fields
}
func NewClientFromEnv ¶ added in v0.3.0
NewClientFromEnv reads the service address and key from backend configuration. The key belongs on the server; never expose it in a browser or mobile client.
func (*Client) Connect ¶
func (c *Client) Connect(ctx context.Context, input ConnectRequest) (ConnectResponse, error)
func (*Client) ConnectWithKey ¶ added in v0.4.0
func (c *Client) ConnectWithKey(ctx context.Context, input ConnectRequest, key string) (ConnectResponse, error)
ConnectWithKey retries a logical creation safely for 24 hours. Persist a random key per operation in your backend and reuse it with the same request on retry.
func (*Client) Connection ¶
func (*Client) Connections ¶
func (*Client) Diagnostics ¶ added in v0.4.0
func (c *Client) Diagnostics(ctx context.Context) (Diagnostics, error)
func (*Client) Import ¶
func (c *Client) Import(ctx context.Context, input io.Reader, opts ImportOptions) (ImportResult, error)
Import uploads a local OFX/CSV export. Requests are limited to 8 MiB.
func (*Client) Institutions ¶
func (*Client) IterAccounts ¶ added in v0.4.0
func (*Client) IterConnections ¶ added in v0.4.0
func (c *Client) IterConnections(ctx context.Context, customer string, limit int) iter.Seq2[Connection, error]
IterConnections fetches pages lazily. Breaking the loop stops further requests.
func (*Client) IterSearchTransactions ¶ added in v0.4.0
func (c *Client) IterSearchTransactions(ctx context.Context, filter TransactionFilter) iter.Seq2[Transaction, error]
func (*Client) IterTransactions ¶ added in v0.4.0
func (*Client) PreviewImport ¶ added in v0.2.0
func (c *Client) PreviewImport(ctx context.Context, input io.Reader, opts ImportOptions) (ImportPreview, error)
func (*Client) RetryWebhook ¶ added in v0.4.0
func (*Client) SearchTransactions ¶ added in v0.2.0
func (c *Client) SearchTransactions(ctx context.Context, f TransactionFilter) (Page[Transaction], error)
func (*Client) Transactions ¶
func (*Client) WebhookDeliveries ¶ added in v0.4.0
type ConnectRequest ¶
type ConnectResponse ¶
type ConnectResponse struct {
Connection Connection `json:"connection"`
AuthorizationURL string `json:"authorization_url,omitempty"`
AuthorizationExpiresAt time.Time `json:"authorization_expires_at,omitzero"`
}
type Connection ¶
type Connection struct {
ID string `json:"id"`
CustomerID string `json:"customer_id"`
InstitutionID string `json:"institution_id"`
Provider string `json:"provider"`
Status string `json:"status"`
CreatedAt time.Time `json:"created_at"`
ConsentExpiresAt time.Time `json:"consent_expires_at,omitzero"`
LastSyncedAt *time.Time `json:"last_synced_at,omitempty"`
AuthorizationMode string `json:"authorization_mode"`
CredentialID string `json:"-"`
}
func (Connection) HistoryAvailable ¶ added in v0.2.0
func (c Connection) HistoryAvailable() bool
type ConnectionStatus ¶
type Diagnostics ¶ added in v0.4.0
type Diagnostics struct {
Version string `json:"version"`
Certificates []CertificateStatus `json:"certificates"`
Operations *OperationsStatus `json:"operations,omitempty"`
}
type ImportOptions ¶
type ImportPreview ¶ added in v0.2.0
type ImportPreview struct {
Result ImportResult `json:"result"`
From string `json:"from"`
Through string `json:"through"`
Sample []ImportSample `json:"sample"`
}
ImportPreview describes a dry run. Its connection ID may not exist yet.
type ImportResult ¶
type ImportResult struct {
New int `json:"new"`
Updated int `json:"updated"`
Unchanged int `json:"unchanged"`
ConnectionID string `json:"connection_id"`
Accounts int `json:"accounts"`
Transactions int `json:"transactions"`
Duplicate bool `json:"duplicate"`
Deduplication string `json:"deduplication"`
}
type ImportSample ¶ added in v0.2.0
type Institution ¶
type Institution struct {
ID string `json:"id"`
Name string `json:"name"`
Provider string `json:"provider"`
Sandbox bool `json:"sandbox"`
ConnectionMode string `json:"connection_mode"`
DataCoverage []string `json:"data_coverage"`
Validation string `json:"validation"`
Profile string `json:"profile,omitempty"`
}
type Job ¶
type Job struct {
ID string `json:"id"`
ConnectionID string `json:"connection_id"`
Status string `json:"status"`
Attempts int `json:"attempts"`
ErrorCode string `json:"error_code,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
LeaseToken string `json:"-"`
RequestsCompleted int `json:"requests_completed"`
}
type Money ¶
Money uses signed minor units. BRL 12.34 is 1234; debits are negative. Values are restricted to the exact integer range supported by JSON clients.
type OperationsStatus ¶ added in v0.4.0
type OperationsStatus struct {
ObservedAt time.Time `json:"observed_at"`
Database string `json:"database"`
Workers map[string]WorkerStatus `json:"workers"`
SyncQueue QueueStatus `json:"sync_queue"`
WebhookQueue QueueStatus `json:"webhook_queue"`
}
type QueueStatus ¶ added in v0.4.0
type QueueStatus struct {
Counts map[string]int64 `json:"counts"`
OldestDueAt *time.Time `json:"oldest_due_at,omitempty"`
LastSucceededAt *time.Time `json:"last_succeeded_at,omitempty"`
LastFailedAt *time.Time `json:"last_failed_at,omitempty"`
RecentSucceeded int64 `json:"recent_succeeded"`
RecentFailed int64 `json:"recent_failed"`
}
QueueStatus is a database snapshot. Recent outcomes cover the last 24 hours; worker step counters are process-local and reset on restart.
type RetryPolicy ¶ added in v0.4.0
type RetryPolicy struct {
MaxAttempts int
MaxElapsedTime time.Duration
BaseDelay time.Duration
MaxDelay time.Duration
}
RetryPolicy applies only to GET requests. Configure it before sharing a Client. The zero value makes one attempt, preserving the default client behavior.
type Transaction ¶
type TransactionFilter ¶ added in v0.2.0
type WebhookData ¶ added in v0.4.0
type WebhookDelivery ¶ added in v0.4.0
type WebhookDelivery struct {
Event WebhookEvent `json:"event"`
Status string `json:"status"`
Attempts int `json:"attempts"`
HTTPStatus int `json:"http_status,omitempty"`
ErrorCode string `json:"error_code,omitempty"`
UpdatedAt time.Time `json:"updated_at"`
NextAttemptAt *time.Time `json:"next_attempt_at,omitempty"`
}
type WebhookEvent ¶ added in v0.4.0
type WebhookEvent struct {
ID string `json:"id"`
Type string `json:"type"`
CreatedAt time.Time `json:"created_at"`
Data WebhookData `json:"data"`
}
func VerifyWebhook ¶ added in v0.4.0
VerifyWebhook authenticates the unmodified request body and rejects signatures older than five minutes. The receiver must also deduplicate event IDs durably.
type WorkerStatus ¶ added in v0.4.0
type WorkerStatus struct {
State string `json:"state"`
Healthy bool `json:"healthy"`
LastStartedAt *time.Time `json:"last_started_at,omitempty"`
LastFinishedAt *time.Time `json:"last_finished_at,omitempty"`
LastSuccessAt *time.Time `json:"last_success_at,omitempty"`
Steps uint64 `json:"steps"`
Errors uint64 `json:"errors"`
}
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
ranjit
command
|
|
|
examples
|
|
|
backend
command
A single-customer backend example.
|
A single-customer backend example. |
|
connect
command
Run with make example.
|
Run with make example. |
|
quickstart
command
Local demo tooling.
|
Local demo tooling. |
|
webhook
command
This receiver commits authenticated events to an inbox before acknowledging delivery.
|
This receiver commits authenticated events to an inbox before acknowledging delivery. |
|
internal
|
|
|
app
Package app assembles configured providers without exposing credentials to the API.
|
Package app assembles configured providers without exposing credentials to the API. |
|
autostart
Package autostart installs a service for the current user, without elevation.
|
Package autostart installs a service for the current user, without elevation. |
|
filelock
Package filelock coordinates Ranjit processes during offline maintenance.
|
Package filelock coordinates Ranjit processes during offline maintenance. |
|
provider
Package provider is the boundary for fetching normalized financial data.
|
Package provider is the boundary for fetching normalized financial data. |
|
provider/c6
Package c6 reads the operator's own C6 Empresas statement using the bank's own API.
|
Package c6 reads the operator's own C6 Empresas statement using the bank's own API. |
|
provider/efi
Package efi connects to the operator's own Efí account through the official Pix API.
|
Package efi connects to the operator's own Efí account through the official Pix API. |
|
provider/inter
Package inter reads the operator's own Inter Empresas account using the Banking API.
|
Package inter reads the operator's own Inter Empresas account using the Banking API. |
|
provider/santander
Package santander reads the operator's own Santander Empresas account using Bank Account Information.
|
Package santander reads the operator's own Santander Empresas account using Bank Account Information. |
|
provider/sicoob
Package sicoob reads the operator's own Sicoob account using the Conta Corrente API.
|
Package sicoob reads the operator's own Sicoob account using the Conta Corrente API. |
|
statement
Package statement reads local bank exports.
|
Package statement reads local bank exports. |
|
updater
Package updater installs only stable release assets from the Ranjit repository.
|
Package updater installs only stable release assets from the Ranjit repository. |
|
validation
Package validation checks a connector without adding data to the personal database.
|
Package validation checks a connector without adding data to the personal database. |