casheerapi

package
v0.0.0-...-eddb447 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const DebtType = "debt"
View Source
const EntryType = "entry"
View Source
const ExpenseType = "expense"
View Source
const TotalType = "total"

Variables

This section is empty.

Functions

This section is empty.

Types

type CreateDebtAttributes

type CreateDebtAttributes struct {
	Value   MonetaryValueCreationAttributes `json:"value"`
	Person  string                          `json:"person"`
	Details string                          `json:"details"`
}

type CreateDebtData

type CreateDebtData struct {
	Type       string               `json:"type"`
	Attributes CreateDebtAttributes `json:"attributes"`
}

type CreateDebtRequest

type CreateDebtRequest struct {
	Data CreateDebtData `json:"data"`
}

type CreateDebtResponse

type CreateDebtResponse struct {
	Data  DebtData     `json:"data"`
	Links DefaultLinks `json:"links"`
}

type CreateEntryAttributes

type CreateEntryAttributes struct {
	Month         *int                            `json:"month,omitempty"`
	Year          *int                            `json:"year,omitempty"`
	Category      string                          `json:"category"  `
	Subcategory   string                          `json:"subcategory"  `
	ExpectedTotal MonetaryValueCreationAttributes `json:"expected_total"  `
	Recurring     bool                            `json:"recurring"`
}

type CreateEntryData

type CreateEntryData struct {
	Type       string                `json:"type"  `
	Attributes CreateEntryAttributes `json:"attributes"`
}

type CreateEntryRequest

type CreateEntryRequest struct {
	Data CreateEntryData `json:"data"`
}

type CreateEntryResponse

type CreateEntryResponse struct {
	Data EntryData `json:"data"`
}

type CreateExpenseAttributes

type CreateExpenseAttributes struct {
	Value         MonetaryValueCreationAttributes `json:"value"`
	Name          string                          `json:"name"`
	Description   *string                         `json:"description,omitempty"`
	PaymentMethod *string                         `json:"payment_method,omitempty"`
}

type CreateExpenseData

type CreateExpenseData struct {
	Type       string                  `json:"type"`
	Attributes CreateExpenseAttributes `json:"attributes"`
}

type CreateExpenseRequest

type CreateExpenseRequest struct {
	Data CreateExpenseData `json:"data"`
}

type CreateExpenseResponse

type CreateExpenseResponse struct {
	Data ExpenseData `json:"data"`
}

type DebtAtrributes

type DebtAtrributes struct {
	Person  string                  `json:"person"`
	Value   MonetaryValueAttributes `json:"value"`
	Details string                  `json:"details"`
	Timestamps
}

type DebtData

type DebtData struct {
	ResourceID
	Attributes DebtAtrributes `json:"attributes"`
	Links      DebtLinks      `json:"links"`
}
type DebtLinks struct {
	Self string `json:"self,omitempty"`
}

type DebtListItemData

type DebtListItemData struct {
	ResourceID
	Attributes DebtAtrributes    `json:"attributes"`
	Links      DebtListItemLinks `json:"links"`
}
type DebtListItemLinks struct {
	Self string `json:"self"`
}
type DefaultLinks struct {
	Home string `json:"home"`
}

DefaultLinks allow the user to navigate back to the home page of the API.

type DeleteDebtRequest

type DeleteDebtRequest struct {
}

type DeleteDebtResponse

type DeleteDebtResponse struct {
	Data DebtData `json:"data"`
}

type DeleteEntryRequest

type DeleteEntryRequest struct {
}

type DeleteEntryResponse

type DeleteEntryResponse struct {
	Data EntryData `json:"data"`
}

type DeleteExpenseRequest

type DeleteExpenseRequest struct {
}

type DeleteExpenseResponse

type DeleteExpenseResponse struct {
	Data ExpenseData `json:"data"`
}

type EntryAtrributes

type EntryAtrributes struct {
	Month         int                     `json:"month"`
	Year          int                     `json:"year"`
	Category      string                  `json:"category"`
	Subcategory   string                  `json:"subcategory"`
	ExpectedTotal MonetaryValueAttributes `json:"expected_total"`
	Recurring     bool                    `json:"recurring"`
	Timestamps
}

type EntryData

type EntryData struct {
	ResourceID
	Attributes    EntryAtrributes    `json:"attributes"`
	Meta          EntryMeta          `json:"meta"`
	Links         EntryLinks         `json:"links"`
	Relationships EntryRelationships `json:"relationships"`
}

type EntryExpenseRelationship

type EntryExpenseRelationship struct {
	Links EntryExpenseRelationshipLinks `json:"links"`
}
type EntryExpenseRelationshipLinks struct {
	Related string `json:"related"`
}
type EntryLinks struct {
	Self string `json:"self"`
}

type EntryListItemData

type EntryListItemData struct {
	ResourceID
	Attributes    EntryAtrributes    `json:"attributes"`
	Meta          EntryMeta          `json:"meta"`
	Links         EntryListItemLinks `json:"links"`
	Relationships EntryRelationships `json:"relationships"`
}
type EntryListItemLinks struct {
	Self string `json:"self"`
}

type EntryMeta

type EntryMeta struct {
	RunningTotal int `json:"running_total"`
}

type EntryRelationships

type EntryRelationships struct {
	Expenses EntryExpenseRelationship `json:"expenses"`
}

type Error

type Error struct {
	Status int    `json:"status"`
	Title  string `json:"title"`
	Detail string `json:"detail"`
}

func (Error) Error

func (e Error) Error() string

Error implements the error interface for public errors. This has two benefits:

- Go clients of the casheer API can unwrap the error from an ErrorResponse to an actual error; - In handlers that contain operations such as transactions, a public error can be set directly inside the transaction. Callers can check if that operation return a public error directly, instead of having to build one based on some internal errors encountered in the transaction.

type ErrorResponse

type ErrorResponse struct {
	Err Error `json:"error"`
}

Error represents an error message that is sent to the client in case the HTTP request returns an error.

The error message is modelled after the jsonapi specification: https://jsonapi.org/format/#error-objects. Many of the suggested fields had not been included, since they were unnecessary for the size of this project. In production, however, it is generally a good idea to stick to a well-defined standard.

See the Error struct below for the actual error content.

func (ErrorResponse) Error

func (e ErrorResponse) Error() string

Error implements the error interface for error responses. It allows go clients to treat error responses as actual errors, if desired.

func (ErrorResponse) Unwrap

func (e ErrorResponse) Unwrap() error

Unwrap is useful for go API clients, allowing to retrieve the underlying public error directly from the error response.

type ExpenseAttributes

type ExpenseAttributes struct {
	Value         MonetaryValueAttributes `json:"value"`
	Name          string                  `json:"name"`
	Description   string                  `json:"description"`
	PaymentMethod string                  `json:"payment_method"`
	Timestamps
}

type ExpenseData

type ExpenseData struct {
	ResourceID
	Attributes    ExpenseAttributes    `json:"attributes"`
	Links         ExpenseLinks         `json:"links"`
	Relationships ExpenseRelationships `json:"relationships"`
}

type ExpenseEntryRelationship

type ExpenseEntryRelationship struct {
	Links ExpenseEntryRelationshipLinks `json:"links"`
}
type ExpenseEntryRelationshipLinks struct {
	Related string `json:"related"`
}
type ExpenseLinks struct {
	Self string `json:"self"`
}

type ExpenseListItemData

type ExpenseListItemData struct {
	ResourceID
	Attributes ExpenseAttributes    `json:"attributes"`
	Links      ExpenseListItemLinks `json:"links"`
}
type ExpenseListItemLinks struct {
	Self string `json:"self"`
}

type ExpenseRelationships

type ExpenseRelationships struct {
	Entries ExpenseEntryRelationship `json:"entries"`
}

type GetDebtRequest

type GetDebtRequest struct {
}

type GetDebtResponse

type GetDebtResponse struct {
	Data DebtData `json:"data"`
}

type GetEntryRequest

type GetEntryRequest struct {
}

type GetEntryResponse

type GetEntryResponse struct {
	Data EntryData `json:"data"`
}

type GetExpenseRequest

type GetExpenseRequest struct {
}

type GetExpenseResponse

type GetExpenseResponse struct {
	Data ExpenseData `json:"data"`
}

type GetTotalParams

type GetTotalParams struct {
	Month *int `json:"month,omitempty"`
	Year  *int `json:"year,omitempty"`
}

type GetTotalResponse

type GetTotalResponse struct {
	Data TotalData `json:"data"`
}
type HomeLink struct {
	Href  string `json:"href"`
	Title string `json:"title"`
}

type LinkWithDetails

type LinkWithDetails struct {
	Href    string `json:"href"`
	Details string `json:"details"`
}
type ListDebtLinks struct {
	Self string   `json:"self"`
	Home HomeLink `json:"home"`
}

type ListDebtParams

type ListDebtParams struct {
	Person *string `form:"person,omitempty"`
}

type ListDebtResponse

type ListDebtResponse struct {
	Data  []DebtListItemData `json:"data"`
	Links ListDebtLinks      `json:"links"`
}
type ListEntryLinks struct {
	Self string   `json:"self"`
	Home HomeLink `json:"home"`
}

type ListEntryParams

type ListEntryParams struct {
	Month       *int    `form:"month,omitempty"`
	Year        *int    `form:"year,omitempty"`
	Category    *string `form:"category,omitempty"`
	Subcategory *string `form:"subcategory,omitempty"`
}

type ListEntryResponse

type ListEntryResponse struct {
	Data  []EntryListItemData `json:"data"`
	Links ListEntryLinks      `json:"links"`
}
type ListExpenseItemLinks struct {
	Self string `json:"self"`
}
type ListExpenseLinks struct {
	Self string   `json:"self"`
	Home HomeLink `json:"home"`
}

type ListExpenseParams

type ListExpenseParams struct {
	AmountGt      *int    `json:"amount[gt],omitempty"`
	AmountLt      *int    `json:"amount[lt],omitempty"`
	Currency      *string `json:"currency,omitempty"`
	Name          *string `json:"name,omitempty"`
	Description   *string `json:"description,omitempty"`
	PaymentMethod *string `json:"payment_method,omitempty"`
}

type ListExpenseResponse

type ListExpenseResponse struct {
	Data  []ExpenseListItemData `json:"data"`
	Links ListExpenseLinks      `json:"links"`
}

type MonetaryMutableValueAttributes

type MonetaryMutableValueAttributes struct {
	Amount   *int    `json:"amount,omitempty"`
	Currency *string `json:"currency,omitempty"`
	Exponent *int    `json:"exponent,omitempty"`
}

MonetaryMutableValueAttributes is the same as MonetaryValueAttributes, except that it holds the fields that are mutable.

type MonetaryValueAttributes

type MonetaryValueAttributes struct {
	Amount   int    `json:"amount"`
	Currency string `json:"currency"`
	Exponent int    `json:"exponent"`
}

MonetaryValueAttributes are used to define the "value" of something in a currency agnostic manner.

type MonetaryValueCreationAttributes

type MonetaryValueCreationAttributes struct {
	Amount   int    `json:"amount"`
	Currency string `json:"currency"`
	Exponent *int   `json:"exponent,omitempty"`
}

MonetaryValueCreationAttributes is the same as MonetaryValueAttributes, but it is used when creating such an object to highlight the optional fields.

type PingLinks struct {
	Entries LinkWithDetails `json:"entries"`
	Debts   LinkWithDetails `json:"debts"`
	Totals  LinkWithDetails `json:"totals"`
}

type PingResponse

type PingResponse struct {
	Info  string    `json:"info"`
	Links PingLinks `json:"links"`
}

type ResourceID

type ResourceID struct {
	Id   string `json:"id"`
	Type string `json:"type"`
}

type Timestamps

type Timestamps struct {
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

type TotalData

type TotalData struct {
	ResourceID
	Month          int `json:"month"`
	Year           int `json:"year"`
	ExpectedIncome int `json:"expected_income"`
	RunningIncome  int `json:"running_income"`
	ExpectedTotal  int `json:"expected_total"`
	RunningTotal   int `json:"running_total"`
}

type UpdateDebtAttributes

type UpdateDebtAttributes struct {
	MonetaryMutableValueAttributes
	Person  *string `json:"person,omitempty"`
	Details *string `json:"details,omitempty"`
}

type UpdateDebtData

type UpdateDebtData struct {
	Type       string               `json:"type"`
	Attributes UpdateDebtAttributes `json:"attributes"`
}

type UpdateDebtRequest

type UpdateDebtRequest struct {
	Data UpdateDebtData `json:"data"  `
}

type UpdateDebtResponse

type UpdateDebtResponse struct {
	Data DebtData `json:"data"`
}

type UpdateEntryAttributes

type UpdateEntryAttributes struct {
	Month         *int                           `json:"month,omitempty"`
	Year          *int                           `json:"year,omitempty"`
	Category      *string                        `json:"category,omitempty"`
	Subcategory   *string                        `json:"subcategory,omitempty"`
	Recurring     *bool                          `json:"recurring,omitempty"`
	ExpectedTotal MonetaryMutableValueAttributes `json:"expected_total,omitempty"`
}

type UpdateEntryData

type UpdateEntryData struct {
	Type       string                `json:"type"`
	Attributes UpdateEntryAttributes `json:"attributes"`
}

type UpdateEntryRequest

type UpdateEntryRequest struct {
	Data UpdateEntryData `json:"data"`
}

type UpdateEntryResponse

type UpdateEntryResponse struct {
	Data EntryData `json:"data"`
}

type UpdateExpenseAttributes

type UpdateExpenseAttributes struct {
	Value         MonetaryMutableValueAttributes `json:"value"`
	Name          *string                        `json:"name,omitempty"`
	Description   *string                        `json:"description,omitempty"`
	PaymentMethod *string                        `json:"payment_method,omitempty"`
}

type UpdateExpenseData

type UpdateExpenseData struct {
	Type       string                  `json:"type"`
	Attributes UpdateExpenseAttributes `json:"attributes"`
}

type UpdateExpenseRequest

type UpdateExpenseRequest struct {
	Data UpdateExpenseData `json:"data"  `
}

type UpdateExpenseResponse

type UpdateExpenseResponse struct {
	Data ExpenseData `json:"data"`
}

Jump to

Keyboard shortcuts

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