api

package
v0.0.0-...-c193e84 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CurrencyCodeEuro currencyCode = "EUR"
)
View Source
const (
	TransactionTypeExpense transactionType = "expense"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type APIConfig

type APIConfig struct {
	BaseURL string
	Key     string

	SettleUpConf SettleUpConfig
}

type Client

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

func New

func New(c Config) *Client

func (*Client) AllMembersInGroup

func (c *Client) AllMembersInGroup(ctx context.Context) ([]Member, error)

func (*Client) AllTransactionsInGroup

func (c *Client) AllTransactionsInGroup(ctx context.Context) ([]Transaction, error)

func (*Client) AuthedRequest

func (c *Client) AuthedRequest(req *http.Request) ([]byte, error)

func (*Client) CreateTransactionInGroup

func (c *Client) CreateTransactionInGroup(ctx context.Context, t Transaction) (*CreateTransactionRes, error)

func (*Client) Login

func (c *Client) Login(ctx context.Context) (string, error)

func (*Client) Request

func (c *Client) Request(req *http.Request) ([]byte, error)

type Config

type Config struct {
	Logger *slog.Logger

	HTTPClient *http.Client

	APIConf APIConfig
}

type CreateTransactionRes

type CreateTransactionRes struct {
	ID string `json:"name"`
}

type Item

type Item struct {
	Amount  float32      `json:"amount,string"`
	ForWhom []PayingUser `json:"forWhom"`
}

type Member

type Member struct {
	ID *string `json:"id,omitempty"`

	Name          string  `json:"name"`
	Active        bool    `json:"active"`
	DefaultWeight float32 `json:"defaultWeight,string"`
}

type PayingUser

type PayingUser struct {
	MemberID string  `json:"memberId"`
	Weight   float32 `json:"weight,string"`
}

type SettleUpConfig

type SettleUpConfig struct {
	Username string
	Password string

	GroupID string
}

type SettleUpTime

type SettleUpTime struct {
	time.Time
}

func (SettleUpTime) MarshalJSON

func (sut SettleUpTime) MarshalJSON() ([]byte, error)

func (*SettleUpTime) UnmarshalJSON

func (sut *SettleUpTime) UnmarshalJSON(b []byte) error

type Transaction

type Transaction struct {
	ID *string `json:"id,omitempty"`

	Category          *string         `json:"category,omitempty"`
	CurrencyCode      currencyCode    `json:"currencyCode"`
	DateTime          SettleUpTime    `json:"dateTime"`
	ExchangeRates     any             `json:"exchangeRates"`
	FixedExchangeRate bool            `json:"fixedExchangeRate"`
	Items             []Item          `json:"items"`
	Purpose           string          `json:"purpose"`
	ReceiptURL        *string         `json:"receiptUrl,omitempty"`
	Type              transactionType `json:"type"`
	WhoPaid           []PayingUser    `json:"whoPaid"`
}

Jump to

Keyboard shortcuts

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