upapi

package
v0.0.0-...-082a807 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AccountTypeSaver         = "SAVER"
	AccountTypeTransactional = "TRANSACTIONAL"
	AccountTypeHomeLoan      = "HOME_LOAN"
)
View Source
const (
	OwnershipTypeIndividual = "INDIVIDUAL"
	OwnershipTypeJoint      = "JOINT"
)
View Source
const DefaultHost = "https://api.up.com.au/api/v1"

Variables

This section is empty.

Functions

func WithHTTPClient

func WithHTTPClient(httpClient *http.Client) newClientOption

func WithHost

func WithHost(host string) newClientOption

func WithLogger

func WithLogger(logger *slog.Logger) newClientOption

func WithPageSize

func WithPageSize(pageSize int) newClientOption

func WithQuiet

func WithQuiet() newClientOption

Types

type Account

type Account struct {
	Type       string `json:"type"`
	ID         string `json:"id"`
	Attributes struct {
		DisplayName   string    `json:"displayName"`
		AccountType   string    `json:"accountType"`
		OwnershipType string    `json:"ownershipType"`
		Balance       Money     `json:"balance"`
		CreatedAt     time.Time `json:"createdAt"`
	} `json:"attributes"`
}

type Client

type Client struct {
	Token      string
	PageSize   int
	Host       string
	HTTPClient *http.Client
	Logger     *slog.Logger
}

func NewClient

func NewClient(token string, opts ...newClientOption) *Client

func (*Client) GetAccount

func (c *Client) GetAccount(ctx context.Context, id string) (*Response[Account], error)

func (*Client) ListAccounts

func (c *Client) ListAccounts(ctx context.Context, params ListAccountsParams) (*Response[[]Account], error)

func (*Client) ListTransactions

func (c *Client) ListTransactions(ctx context.Context, params ListTransactionsParams) (*Response[[]Transaction], error)

func (*Client) ListTransactionsForAccount

func (c *Client) ListTransactionsForAccount(ctx context.Context, accoundID string, params ListTransactionsParams) (*Response[[]Transaction], error)

func (*Client) PaginateAllAccounts

func (c *Client) PaginateAllAccounts(ctx context.Context, params ListAccountsParams) ([]Account, error)

func (*Client) PaginateAllTransactions

func (c *Client) PaginateAllTransactions(ctx context.Context, params ListTransactionsParams) ([]Transaction, error)

func (*Client) PaginateAllTransactionsForAccount

func (c *Client) PaginateAllTransactionsForAccount(ctx context.Context, accountID string, params ListTransactionsParams) ([]Transaction, error)

type ErrorResponse

type ErrorResponse struct {
	Errors []struct {
		Status string `json:"status"`
		Title  string `json:"title"`
		Detail string `json:"detail"`
		Source *struct {
			Parameter string `json:"parameter"`
			Pointer   string `json:"pointer"`
		} `json:"source,omitempty"`
	} `json:"errors"`
}

func (*ErrorResponse) Error

func (e *ErrorResponse) Error() string

type ListAccountsParams

type ListAccountsParams struct {
	AccountType string `qparam:"filter[accountType]"`
	Ownership   string `qparam:"filter[ownershipType]"`

	Before string `qparam:"page[before]"`
	After  string `qparam:"page[after]"`
}

type ListTransactionsParams

type ListTransactionsParams struct {
	Status   string    `qparam:"filter[status]"`
	Since    time.Time `qparam:"filter[since]"`
	Until    time.Time `qparam:"filter[until]"`
	Category string    `qparam:"filter[category]"`
	Tag      string    `qparam:"filter[tag]"`

	Before string `qparam:"page[before]"`
	After  string `qparam:"page[after]"`
}

type Money

type Money struct {
	CurrencyCode     string `json:"currencyCode"`
	Value            string `json:"value"`
	ValueInBaseUnits int    `json:"valueInBaseUnits"`
}

type Response

type Response[T any] struct {
	Data  T `json:"data"`
	Links struct {
		Prev *string `json:"prev"`
		Next *string `json:"next"`
	} `json:"links"`
}

type Transaction

type Transaction struct {
	Type       string `json:"type"`
	ID         string `json:"id"`
	Attributes struct {
		Status          string  `json:"status"`
		RawText         *string `json:"rawText,omitempty"`
		Description     string  `json:"description"`
		Message         *string `json:"message,omitempty"`
		IsCategorizable bool    `json:"isCategorizable"`

		HoldInfo *struct {
			Amount        Money  `json:"amount"`
			ForeignAmount *Money `json:"foreignAmount,omitempty"`
		} `json:"holdInfo,omitempty"`

		RoundUp *struct {
			Amount       Money  `json:"amount"`
			BoostPortion *Money `json:"boostPortion,omitempty"`
		} `json:"roundUp,omitempty"`

		Cashback *struct {
			Description string `json:"description"`
			Amount      Money  `json:"amount"`
		} `json:"cashback,omitempty"`

		Amount             Money  `json:"amount"`
		ForeignAmount      *Money `json:"foreignAmount,omitempty"`
		CardPurchaseMethod *struct {
			Method           string  `json:"method"`
			CardNumberSuffix *string `json:"cardNumberSuffix,omitempty"`
		} `json:"cardPurchaseMethod,omitempty"`

		SettledAt *time.Time `json:"settledAt,omitempty"`
		CreatedAt time.Time  `json:"createdAt"`
	} `json:"attributes"`
}

Jump to

Keyboard shortcuts

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