mono

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: May 11, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIError

type APIError struct {
	Description string `json:"errorDescription"`
}

APIError describes monobank API error.

func (*APIError) Error

func (err *APIError) Error() string

Error formats APIError to string.

type Account

type Account struct {
	ID           string `json:"id"`
	Balance      int64  `json:"balance"`
	CurrencyCode int16  `json:"currencyCode"`
}

Account describes monobank account.

type Client

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

Client implements monobank API client.

func NewClient

func NewClient(baseURL, apiKey string) *Client

NewClient creates new instance of Client. todo: add tests with mock http server.

func (*Client) GetTransactions

func (c *Client) GetTransactions(ctx context.Context, query GetTransactionsQuery) ([]Transaction, error)

GetTransactions loads transactions from monobank with specified query parameters.

func (*Client) GetUserInfo

func (c *Client) GetUserInfo(ctx context.Context) ([]Account, error)

GetUserInfo loads user accounts list.

type GetTransactionsQuery

type GetTransactionsQuery struct {
	Account string
	From    time.Time
	To      time.Time
}

GetTransactionsQuery describes parameters for GetTransactions monobank request.

type Time

type Time time.Time

Time defines a timestamp encoded as epoch seconds in JSON.

func (Time) MarshalJSON

func (t Time) MarshalJSON() ([]byte, error)

MarshalJSON is used to convert the timestamp to JSON.

func (*Time) UnmarshalJSON

func (t *Time) UnmarshalJSON(s []byte) (err error)

UnmarshalJSON is used to convert the timestamp from JSON.

type Transaction

type Transaction struct {
	ID          string `json:"id"`
	Time        Time   `json:"time"`
	Description string `json:"description"`
	MCC         int32  `json:"mcc"`
	Hold        bool   `json:"hold"`
	Amount      int64  `json:"amount"`
}

Transaction describes monobank transaction.

Jump to

Keyboard shortcuts

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