Documentation
¶
Overview ¶
Package swile is a read-only client for the endpoints the Swile web app uses.
Read-only is a hard rule, not a default: this package must never gain a method that writes. No orders, no card operations, no banking mutations. A bug in a tool people run from a shell should never be able to spend money.
Index ¶
- Constants
- type Address
- type Cents
- type Client
- func (c *Client) Filters(ctx context.Context) (*FilterSet, error)
- func (c *Client) Merchants(ctx context.Context, origin geo.Point, box geo.BBox, filters []Filter) (*MerchantResult, error)
- func (c *Client) Operations(ctx context.Context, n int, since time.Time) ([]Operation, error)
- func (c *Client) Session() *auth.Session
- func (c *Client) Wallets(ctx context.Context) ([]Wallet, error)
- type Currency
- type Filter
- type FilterSet
- type Merchant
- type MerchantResult
- type Money
- type Operation
- type Wallet
Constants ¶
const ( // MaxRadius caps how wide a single search may reach. cantine answers "where // do I eat around here"; it is deliberately unable to sweep a region. MaxRadius = 10000 // metres )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Address ¶
type Address struct {
Address1 string `json:"address1"`
Address2 string `json:"address2"`
City string `json:"city"`
Country string `json:"country"`
Postcode string `json:"postal_code"`
Formatted string `json:"formatted_address"`
}
Address is a merchant's postal address, already normalised by Swile.
type Cents ¶
Cents is an amount in minor units. neobank-api reports operations this way — -2150 means -21,50 €.
Money and Cents are separate types on purpose: the two services really do disagree about scale, and a shared type would let one be printed as the other without the compiler noticing.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client talks to Swile on behalf of one session.
func (*Client) Filters ¶
Filters returns the caller's default wallet filters and the category catalogue.
func (*Client) Merchants ¶
func (c *Client) Merchants(ctx context.Context, origin geo.Point, box geo.BBox, filters []Filter) (*MerchantResult, error)
Merchants finds places around origin within the given box.
func (*Client) Operations ¶
Operations walks the account history from newest to oldest, stopping once it has n entries or reaches an entry older than since (zero time means no floor).
type Currency ¶
type Currency struct {
ISO3 string `json:"iso3"`
ISO3Alt string `json:"iso_3"`
Symbol string `json:"symbol"`
Title string `json:"title"`
}
Currency is Swile's currency object — a nested object, not a plain ISO string. The two services disagree on how to spell the ISO field: the BFF sends iso3, neobank sends iso_3. Both are accepted here.
type Filter ¶
type Filter struct {
ID string `json:"id"`
Name string `json:"name"`
Operator string `json:"operator"`
Property string `json:"property"`
Value string `json:"value"`
}
Filter is one criterion accepted by the merchants endpoint. Only payment_networks and merchant_category_aggregated_code are valid properties; there is no name or text property, which is why searching by name can only happen locally.
type FilterSet ¶
type FilterSet struct {
DefaultFilters []Filter `json:"default_filters"`
Sections []struct {
ID string `json:"id"`
Name string `json:"name"`
Filters []Filter `json:"filters"`
} `json:"sections"`
}
FilterSet is what /user/filters returns: the caller's default wallet filters plus the catalogue of merchant categories.
func (*FilterSet) Categories ¶
Categories flattens every category filter across sections.
type Merchant ¶
type Merchant struct {
UUID string `json:"uuid"`
Name string `json:"name"`
Position geo.Point `json:"position"`
Address Address `json:"address"`
PaymentNetworks []string `json:"payment_networks"`
MerchantCategory struct {
AggregatedCode string `json:"aggregated_code"`
Code string `json:"code"`
Description string `json:"description"`
} `json:"merchant_category"`
IsFavorite bool `json:"is_favorite"`
IsClosed bool `json:"is_closed"`
IsBlacklisted bool `json:"is_blacklisted"`
// DistanceM is computed locally from the search origin, not returned by the API.
DistanceM float64 `json:"distance_m"`
}
Merchant is a place that accepts the caller's wallets.
type MerchantResult ¶
MerchantResult carries the merchants found plus how complete that answer is.
TotalInBox is what Swile says exists in the box; len(Merchants) is what it actually handed over. The two diverge badly in dense areas — 178 of 4304 in central Paris — so callers must surface the gap rather than present a partial answer as exhaustive.
func (*MerchantResult) Complete ¶
func (r *MerchantResult) Complete() bool
Complete reports whether every merchant in the box was returned.