monzo

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(httpClient *http.Client, opts ...Option) *client

func UnmarshalError

func UnmarshalError(status int, body []byte) error

Types

type Account

type Account struct {
	ID                AccountID `json:"id"`
	Description       string    `json:"description"`
	CreatedAt         time.Time `json:"created"`
	Closed            bool      `json:"closed"`
	Currency          string    `json:"currency"`
	Type              string    `json:"type"`
	OwnerType         string    `json:"owner_type"`
	CountryCode       string    `json:"country_code"`
	CountryCodeAlpha3 string    `json:"country_code_alpha3"`
	AccountNumber     string    `json:"account_number"`
	SortCode          string    `json:"sort_code"`
	Owners            []*Owner  `json:"owners"`
}

type AccountID

type AccountID string

type Client

type Client interface {
	FetchAccounts(ctx context.Context) ([]*Account, error)
	FetchPots(ctx context.Context, accountID AccountID) ([]*Pot, error)
	FetchTransaction(ctx context.Context, transactionID TransactionID) (*Transaction, error)
	FetchTransactionsSince(ctx context.Context, opts FetchTransactionOptions) ([]*Transaction, error)
}

type CounterParty

type CounterParty struct {
	AccountNumber string `json:"account_number"`
	Name          string `json:"name"`
	SortCode      string `json:"sort_code"`
	UserID        UserID `json:"user_id"`
}

type Error

type Error struct {
	HTTPStatus int
	Code       string `json:"code"`
	Message    string `json:"message"`
}

func (Error) Error

func (err Error) Error() string

Error (statusCode=400, code=bad_request.bad_time_range, message=Error listing hydrated transactions by account) Error (statusCode=400, code=bad_request.invalid_time_range, message=The time range you have requested is too large, please use the `since` and `before` parameters to request smaller ranges. Learn more in our community post: https://community.monzo.com/t/changes-when-listing-with-our-api/158676) Error (statusCode=403, code=forbidden.verification_required, message=Verification required) when requesting old transactions.

type FetchTransactionOptions

type FetchTransactionOptions struct {
	AccountID AccountID
	Start     time.Time
	End       time.Time
	SinceID   TransactionID
	Limit     int
}

func (*FetchTransactionOptions) Validate

func (fto *FetchTransactionOptions) Validate(ctx context.Context) error

type Merchant

type Merchant struct {
	ID       MerchantID `json:"id"`
	Name     string     `json:"name"`
	Category string     `json:"category"`
	Online   bool       `json:"online"`
	Atm      bool       `json:"atm"`
}

type MerchantID

type MerchantID string

type Option

type Option func(*client)

func WithAuthToken

func WithAuthToken(authToken string) Option

func WithBaseURL

func WithBaseURL(baseURL string) Option

type Owner

type Owner struct {
	UserID             UserID `json:"user_id"`
	PreferredName      string `json:"preferred_name"`
	PreferredFirstName string `json:"preferred_first_name"`
}

type Pot

type Pot struct {
	ID       PotID  `json:"id"`
	Name     string `json:"name"`
	Deleted  bool   `json:"deleted"`
	Currency string `json:"currency"`
}

type PotID

type PotID string

type Transaction

type Transaction struct {
	ID              TransactionID `json:"id"`
	Description     string        `json:"description"`
	CreatedAt       time.Time     `json:"created"`
	Amount          domain.Money  `json:"amount"`
	UserNotes       string        `json:"notes"`
	CategoryName    string        `json:"category"`
	SettledAt       *time.Time    `json:"settled"`
	LocalAmount     domain.Money  `json:"local_money"`
	UpdatedAt       time.Time     `json:"updated"`
	AccountID       AccountID     `json:"account_id"`
	AmountIsPending bool          `json:"amount_is_pending"`
	Scheme          string        `json:"scheme"`
	Merchant        *Merchant     `json:"merchant"`
	CounterParty    *CounterParty `json:"counterparty"`
	DeclineReason   string        `json:"decline_reason"`
	Metadata        map[string]string
}

func (*Transaction) UnmarshalJSON

func (t *Transaction) UnmarshalJSON(data []byte) error

type TransactionID

type TransactionID string

type UserID

type UserID string

Jump to

Keyboard shortcuts

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