provider

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 7, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package provider is the boundary for fetching normalized financial data. Consent protocols belong to each integration; this interface does not implement OAuth.

Index

Constants

View Source
const MaxResponseBytes = 2 << 20

Variables

This section is empty.

Functions

func NewMTLSClient

func NewMTLSClient(certificateFile, keyFile string) (*http.Client, error)

NewMTLSClient uses system roots, a client certificate and bounded network timeouts. Redirects are refused so bank credentials never follow a different destination.

func NewTLSClient

func NewTLSClient() *http.Client

NewTLSClient is used by bank sandboxes that issue a static access token. It has the same timeouts and redirect policy as the mTLS transport.

func ParseBRL

func ParseBRL(raw json.RawMessage) (ranjit.Money, error)

ParseBRL reads decimal JSON numbers or strings without rounding through float64.

func ReadSecretFile

func ReadSecretFile(path string) (string, error)

ReadSecretFile keeps credentials out of environment values and error messages.

func RequestJSON

func RequestJSON(client *http.Client, req *http.Request, result any, now time.Time) (int, error)

func SyncTime

func SyncTime(ctx context.Context, fallback time.Time) time.Time

SyncTime freezes the requested period across retries, including at midnight. Authentication and consent checks continue to use the actual clock.

func WithCheckpoint

func WithCheckpoint(ctx context.Context, c Checkpoint, at time.Time) context.Context

Types

type Account

type Account struct {
	ExternalID     string
	Name           string
	Type           string
	Balance        ranjit.Money
	BalanceUnknown bool
	BalanceAt      time.Time
}

type Checkpoint

type Checkpoint interface {
	Load(context.Context, string) ([]byte, error)
	Save(context.Context, string, []byte) error
}

Checkpoint retains successful read responses for one leased job. OAuth responses, headers and credentials never enter this boundary.

type CredentialSource

type CredentialSource interface {
	Source
	CredentialID() string
	Verify(context.Context) error
}

CredentialSource accesses the operator's own account using credentials installed locally. CredentialID binds connections to an application and environment without persisting secrets.

type OAuth

type OAuth struct {
	// contains filtered or unexported fields
}

OAuth owns the token cache for exactly one installed bank application. The request function retains each bank's transport and pacing policy.

func (*OAuth) Get

func (a *OAuth) Get(ctx context.Context, o OAuthOptions, endpoint string, headers http.Header, result any) error

type OAuthOptions

type OAuthOptions struct {
	TokenURL, ClientID, ClientSecret, StaticToken string
	Scopes                                        []string
	OptionalScope                                 bool
	JSONBasic                                     bool
	Now                                           func() time.Time
	Request                                       func(*http.Request, any) (int, error)
}

type Registry

type Registry struct {
	// contains filtered or unexported fields
}

Registry routes each profile to its own credentials and account. Profile names are part of persisted institution IDs; renaming one requires a new connection.

func NewRegistry

func NewRegistry() *Registry

func (*Registry) Add

func (r *Registry) Add(name string, source Source) error

func (*Registry) Close

func (r *Registry) Close()

func (*Registry) Fetch

func (r *Registry) Fetch(ctx context.Context, c ranjit.Connection) (Snapshot, error)

func (*Registry) Institutions

func (r *Registry) Institutions() []ranjit.Institution

func (*Registry) Resolve

func (r *Registry) Resolve(id string) (Source, string, error)

type RetryError

type RetryError struct{ After time.Duration }

RetryError lets the worker defer a rate-limited request without holding a lease open.

func (*RetryError) Error

func (*RetryError) Error() string

func (*RetryError) Unwrap

func (*RetryError) Unwrap() error

type Snapshot

type Snapshot struct {
	Accounts     []Account
	Transactions []Transaction
}

func (Snapshot) Validate

func (s Snapshot) Validate() error

Validate rejects a whole batch before any write. A partial import must not advance a sync.

type Source

type Source interface {
	Institutions() []ranjit.Institution
	Fetch(context.Context, ranjit.Connection) (Snapshot, error)
}

type Transaction

type Transaction struct {
	ExternalID        string
	AccountExternalID string
	Description       string
	Amount            ranjit.Money
	PostedOn          string
	Status            string
}

Directories

Path Synopsis
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.
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.
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.
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.
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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL