rest

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2023 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrResourceNotFound = datastore.ErrRecordNotFound
)

Functions

func NewErrBadRequestOrNil

func NewErrBadRequestOrNil(err error) error

func NewErrorResponse

func NewErrorResponse(err any) gin.H

func NewHandler

func NewHandler(
	cfg *Config,
	auth *auth.Service,
	accounts *accounts.Service,
	categories *categories.Service,
	transactions *transactions.Service,
	spendings *spendings.Service,
) http.Handler

Types

type AccountAmountInput

type AccountAmountInput struct {
	Currency accounts.Currency `json:"currency" binding:"required"`
	Amount   float64           `json:"amount"`
}

func (*AccountAmountInput) Bind

func (i *AccountAmountInput) Bind(c *gin.Context) error

type AccountAmountMonthInput

type AccountAmountMonthInput struct {
	Month string `uri:"month" binding:"yearmonth"`
}

func (*AccountAmountMonthInput) Bind

type AccountResponse

type AccountResponse struct {
	UUID string `json:"uuid"`
	Name string `json:"name"`
}

func NewAccountResponse

func NewAccountResponse(acc *accounts.Account) *AccountResponse

func NewListAccountsResponse

func NewListAccountsResponse(accs []*accounts.Account) []*AccountResponse

type BadRequestError

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

func NewErrBadRequest

func NewErrBadRequest(err error) BadRequestError

func (BadRequestError) Error

func (err BadRequestError) Error() string

func (BadRequestError) Unwrap

func (err BadRequestError) Unwrap() error

type CategoryResponse

type CategoryResponse struct {
	UUID      string `json:"uuid"`
	Name      string `json:"name"`
	CreatedAt string `json:"created_at"`
}

func NewCategoryResponse

func NewCategoryResponse(cat *categories.Category) *CategoryResponse

func NewListCategoriesResponse

func NewListCategoriesResponse(cats []*categories.Category) []*CategoryResponse

type Config added in v0.6.0

type Config struct {
	AllowedOrigins []string `env:"CORS_ALLOWED_ORIGINS"`
}

func NewConfig added in v0.6.0

func NewConfig() *Config

type CreateAccountInput

type CreateAccountInput struct {
	Name string `json:"name" binding:"required"`
}

func (*CreateAccountInput) Bind

func (i *CreateAccountInput) Bind(c *gin.Context) error

type CreateCategoryInput

type CreateCategoryInput struct {
	Name string `json:"name" binding:"required"`
}

func (*CreateCategoryInput) Bind

func (i *CreateCategoryInput) Bind(c *gin.Context) error

type CreateTransactionInput

type CreateTransactionInput struct {
	Month        string            `json:"month" binding:"required,yearmonth"`
	Currency     accounts.Currency `json:"currency" binding:"required"`
	Amount       float64           `json:"amount" binding:"required"`
	Description  string            `json:"description"`
	CategoryUUID *string           `json:"category_uuid"`
}

func (*CreateTransactionInput) Bind

type GetAccountInput

type GetAccountInput struct {
	UUID string `uri:"uuid" binding:"required,uuid"`
}

func (*GetAccountInput) Bind

func (i *GetAccountInput) Bind(c *gin.Context) error

type GetCategoryInput

type GetCategoryInput struct {
	UUID string `uri:"uuid" binding:"required,uuid"`
}

func (*GetCategoryInput) Bind

func (i *GetCategoryInput) Bind(c *gin.Context) error

type GetMonthTransactionsInput

type GetMonthTransactionsInput struct {
	Month string `uri:"month" binding:"required,yearmonth"`
}

func (*GetMonthTransactionsInput) Bind

type GetSpendingsInput

type GetSpendingsInput struct {
	Month string `uri:"month" binding:"required,yearmonth"`
}

func (*GetSpendingsInput) Bind

func (i *GetSpendingsInput) Bind(c *gin.Context) error

type GetTransactionInput

type GetTransactionInput struct {
	UUID string `uri:"uuid" binding:"required,uuid"`
}

func (*GetTransactionInput) Bind

func (i *GetTransactionInput) Bind(c *gin.Context) error

type SpendingsResponse

type SpendingsResponse map[string]accounts.CurrencyAmounts

func NewSpendingsResponse

func NewSpendingsResponse(spent spendings.Spendings, cats []*categories.Category) SpendingsResponse

type TransactionResponse

type TransactionResponse struct {
	UUID        string            `json:"uuid"`
	Month       string            `json:"month"`
	Currency    accounts.Currency `json:"currency"`
	Amount      float64           `json:"amount"`
	Description string            `json:"description"`
	Category    string            `json:"category_uuid"`
}

func NewListTransactionsResponse

func NewListTransactionsResponse(txs []*transactions.Transaction) []*TransactionResponse

func NewTransactionResponse

func NewTransactionResponse(tx *transactions.Transaction) *TransactionResponse

Jump to

Keyboard shortcuts

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