Documentation ¶
Overview ¶
Package mono implements bindings to MonoBank Developer API.
This package support 3 types of authentication:
- Public API provides access to public endpoints with rate limitations.
- Personal API provides access by token to your own monobank account.
- Corporate API provides access for enterprise partners of Monobank.
The name mono stands for "MonoBank". It is short and clear.
Index ¶
- Constants
- func ParseCustomECPrivateKey(der []byte) (key *ecdsa.PrivateKey, err error)
- type Account
- type AccountType
- type Authorizer
- type CashBackType
- type Corporate
- func (c *Corporate) Auth(ctx context.Context, callback string, permissions ...byte) (*TokenRequest, error)
- func (c *Corporate) CheckAuth(ctx context.Context, reqID string) (bool, error)
- func (c *Corporate) GetJSON(ctx context.Context, endpoint string, headers map[string]string) ([]byte, int, error)
- func (c *Corporate) PostJSON(ctx context.Context, endpoint string, headers map[string]string, ...) ([]byte, int, error)
- func (c *Corporate) Rates(ctx context.Context) ([]Exchange, error)
- func (c *Corporate) Transactions(ctx context.Context, reqID string, account string, from, to time.Time) ([]Transaction, error)
- func (c *Corporate) User(ctx context.Context, reqID string) (*UserInfo, error)
- type Currency
- type CurveParams
- type Error
- type Exchange
- type Personal
- func (ac *Personal) GetJSON(ctx context.Context, endpoint string, headers map[string]string) ([]byte, int, error)
- func (ac *Personal) PostJSON(ctx context.Context, endpoint string, headers map[string]string, ...) ([]byte, int, error)
- func (p *Personal) Rates(ctx context.Context) ([]Exchange, error)
- func (p *Personal) SetWebHook(ctx context.Context, url string) ([]byte, error)
- func (p *Personal) Transactions(ctx context.Context, account string, from, to time.Time) ([]Transaction, error)
- func (p *Personal) User(ctx context.Context) (*UserInfo, error)
- type Public
- func (c *Public) GetJSON(ctx context.Context, endpoint string, headers map[string]string) ([]byte, int, error)
- func (c *Public) PostJSON(ctx context.Context, endpoint string, headers map[string]string, ...) ([]byte, int, error)
- func (c *Public) Rates(ctx context.Context) ([]Exchange, error)
- func (c *Public) SetBaseURL(url string)
- type SignTool
- func (t *SignTool) DecodePrivateKey(b []byte) (*ecdsa.PrivateKey, error)
- func (t *SignTool) Sign(key *ecdsa.PrivateKey, str string) (string, error)
- func (t *SignTool) VerifyBytes(pubkey *ecdsa.PublicKey, b []byte, s string) error
- func (t *SignTool) VerifyBytesN(pubkeys []*ecdsa.PublicKey, b []byte, s string) error
- type Time
- type TokenRequest
- type Transaction
- type UserInfo
Constants ¶
const ( // StatementPermission provides access to balance and statement itself. StatementPermission byte = 's' // PersonalPermission provides access to client's name and surname. PersonalPermission byte = 'p' )
const DefaultBaseURL = "https://api.monobank.ua"
DefaultBaseURL is production URL of Monobank API.
Variables ¶
This section is empty.
Functions ¶
func ParseCustomECPrivateKey ¶ added in v0.0.11
func ParseCustomECPrivateKey(der []byte) (key *ecdsa.PrivateKey, err error)
ParseCustomECPrivateKey returns Elliptic Curve Digital Signature Algorithm private key from file content.
Types ¶
type Account ¶
type Account struct { ID string `json:"id"` // Account identifier. Balance int `json:"balance"` // Balance is minimal units (cents). CreditLimit int `json:"creditLimit"` // Credit limit. CurrencyCode int32 `json:"currencyCode"` // Currency code in ISO4217. CashBackType CashBackType `json:"cashbackType"` // Type of cash-back. Type AccountType `json:"type"` // Type of card. IBAN string `json:"iban"` // IBAN. MaskedPan []string `json:"maskedPan"` }
Account is simple representation of bank account.
type AccountType ¶ added in v0.2.2
type AccountType string
AccountType is type of the account.
const ( Platinum AccountType = "platinum" White AccountType = "white" Black AccountType = "black" FOP AccountType = "fop" )
type Authorizer ¶ added in v0.0.3
Authorizer is an interface for different types of MonoBank API authorization.
type CashBackType ¶ added in v0.0.11
type CashBackType string
CashBackType is type of cash-back that credits to the account.
const ( // None is cash-back type for foreign currencies accounts. None CashBackType = "None" // UAH is default cash-back type for almost all accounts. UAH CashBackType = "UAH" // Miles available only on Iron Card. Miles CashBackType = "Miles" )
type Corporate ¶ added in v0.0.11
type Corporate struct {
// contains filtered or unexported fields
}
Corporate gives access to corporate methods.
func NewCorporate ¶ added in v0.0.11
NewCorporate returns new client of MonoBank Corporate API.
func (*Corporate) Auth ¶ added in v0.0.11
func (c *Corporate) Auth(ctx context.Context, callback string, permissions ...byte) (*TokenRequest, error)
Auth initializes access.
func (*Corporate) CheckAuth ¶ added in v0.0.11
CheckAuth checks status of request for client's personal data.
func (*Corporate) GetJSON ¶ added in v0.0.11
func (c *Corporate) GetJSON(ctx context.Context, endpoint string, headers map[string]string) ([]byte, int, error)
GetJSON builds the full endpoint path and gets the raw JSON.
func (*Corporate) PostJSON ¶ added in v0.0.11
func (c *Corporate) PostJSON(ctx context.Context, endpoint string, headers map[string]string, payload io.Reader) ([]byte, int, error)
PostJSON builds the full endpoint path and gets the raw JSON.
func (*Corporate) Rates ¶ added in v0.0.14
Rates returns list of currencies rates from MonoBank API. See https://api.monobank.ua/docs/#/definitions/CurrencyInfo for details.
func (*Corporate) Transactions ¶ added in v0.0.11
func (c *Corporate) Transactions(ctx context.Context, reqID string, account string, from, to time.Time) ([]Transaction, error)
Transactions returns list of transactions from {from} till {to} time. See https://api.monobank.ua/docs/#/definitions/StatementItems for details.
type Currency ¶
Currency is internal representation of fiat currencies.
func CurrencyFromISO4217 ¶
CurrencyFromISO4217 converts ISO4217 to matching currency.
type CurveParams ¶ added in v0.0.11
type CurveParams struct {
elliptic.CurveParams
}
CurveParams contains the parameters of an elliptic curve and also provides a generic, non-constant time implementation of Curve.
func (*CurveParams) IsOnCurve ¶ added in v0.0.11
func (curve *CurveParams) IsOnCurve(x, y *big.Int) bool
IsOnCurve returns boolean if the point (x,y) is on the curve. Part of the elliptic.Curve interface.
func (*CurveParams) ScalarBaseMult ¶ added in v0.0.11
ScalarBaseMult returns k*G where G is the base point of the group and k is a big endian integer. Part of the elliptic.Curve interface.
func (*CurveParams) ScalarMult ¶ added in v0.0.11
ScalarMult returns k*(Bx, By) where k is a big endian integer. Part of the elliptic.Curve interface.
type Error ¶ added in v0.0.4
type Error struct {
ErrorDescription string `json:"errorDescription"`
}
Error is a simple representation of MonoBank API error.
type Exchange ¶
type Exchange struct { CodeA int32 `json:"CurrencyCodeA"` CodeB int32 `json:"CurrencyCodeB"` Date int32 `json:"Date"` RateSell float64 `json:"RateSell"` RateBuy float64 `json:"RateBuy"` RateCross float64 `json:"RateCross"` }
Exchange contains market buy/sell rates. See https://api.monobank.ua/docs/#/definitions/CurrencyInfo for details.
type Personal ¶ added in v0.0.11
type Personal struct {
// contains filtered or unexported fields
}
Personal gives access to personal methods.
func NewPersonal ¶ added in v0.0.11
NewPersonal returns new client of MonoBank Personal API.
func (*Personal) GetJSON ¶ added in v0.0.11
func (ac *Personal) GetJSON(ctx context.Context, endpoint string, headers map[string]string) ([]byte, int, error)
GetJSON builds the full endpoint path and gets the raw JSON.
func (*Personal) PostJSON ¶ added in v0.0.11
func (ac *Personal) PostJSON( ctx context.Context, endpoint string, headers map[string]string, payload io.Reader, ) ([]byte, int, error)
PostJSON builds the full endpoint path and gets the raw JSON.
func (*Personal) Rates ¶ added in v0.0.11
Rates returns list of currencies rates from MonoBank API. See https://api.monobank.ua/docs/#/definitions/CurrencyInfo for details.
func (*Personal) SetWebHook ¶ added in v0.0.11
SetWebHook sets WebHook URL for authorized user. See https://api.monobank.ua/docs#operation--personal-webhook-post for details.
func (*Personal) Transactions ¶ added in v0.0.11
func (p *Personal) Transactions(ctx context.Context, account string, from, to time.Time) ([]Transaction, error)
Transactions returns list of transactions from {from} till {to} time. See https://api.monobank.ua/docs/#/definitions/StatementItems for details.
type Public ¶ added in v0.0.11
type Public struct {
// contains filtered or unexported fields
}
Public gives access to public methods.
func NewPublic ¶ added in v0.0.11
func NewPublic() *Public
NewPublic returns new client of MonoBank Public API.
func (*Public) GetJSON ¶ added in v0.0.11
func (c *Public) GetJSON(ctx context.Context, endpoint string, headers map[string]string) ([]byte, int, error)
GetJSON builds the full endpoint path and gets the raw JSON.
func (*Public) PostJSON ¶ added in v0.0.11
func (c *Public) PostJSON( ctx context.Context, endpoint string, headers map[string]string, payload io.Reader, ) ([]byte, int, error)
PostJSON builds the full endpoint path and gets the raw JSON.
func (*Public) Rates ¶ added in v0.0.11
Rates returns list of currencies rates from MonoBank API. See https://api.monobank.ua/docs/#/definitions/CurrencyInfo for details.
func (*Public) SetBaseURL ¶ added in v0.2.1
func (c *Public) SetBaseURL(url string)
SetBaseURL set baseURL to the new specified URL.
type SignTool ¶ added in v0.0.11
SignTool it utility, which helps to sign message.
func DefaultSignTool ¶ added in v0.0.14
func DefaultSignTool() *SignTool
DefaultSignTool returns new instance of SignTool SignTool with default encoding parameters.
func (*SignTool) DecodePrivateKey ¶ added in v0.0.11
func (t *SignTool) DecodePrivateKey(b []byte) (*ecdsa.PrivateKey, error)
DecodePrivateKey decodes privage key into Elliptic Curve Digital Signature Algorithm private key.
func (*SignTool) VerifyBytes ¶ added in v0.0.11
VerifyBytes verifies a digital signature. Returns nil if all is well or an error indicating what went wrong. The equivalent command at the command line is: echo -n 'Make America Great Again!' | openssl dgst -verify pub1.pem -signature signature.dat
type Time ¶ added in v0.2.3
Time defines a timestamp encoded as epoch seconds in JSON Most of it's code taken from https://github.com/pieterclaerhout/example-json-unixtimestamp/blob/master/cmd/example-json-timestamp/time.go
func (Time) MarshalJSON ¶ added in v0.2.3
MarshalJSON is used to convert the timestamp to JSON
func (*Time) UnmarshalJSON ¶ added in v0.2.3
UnmarshalJSON is used to convert the timestamp from JSON
type TokenRequest ¶ added in v0.0.11
type TokenRequest struct { TokenRequestID string `json:"tokenRequestId"` // Unique token request ID. AcceptURL string `json:"acceptUrl"` // URL to redirect client or build QR on top of it. }
TokenRequest is representation of payload, received on corporate auth.
type Transaction ¶ added in v0.0.11
type Transaction struct { ID string `json:"id"` // Unique transaction ID. Time Time `json:"time"` // UTC time of transaction. Description string `json:"description"` // Message attached to transaction. MCC int32 `json:"mcc"` // Merchant Category Code using ISO18245. Hold bool `json:"hold"` // Authorization hold. Amount int64 `json:"amount"` // Amount in account currency (cents). OperationAmount int64 `json:"operationAmount"` // Amount in transaction currency (cents). CurrencyCode int32 `json:"currencyCode"` // Currency code using ISO4217. CommissionRate int64 `json:"commissionRate"` // Amount of commission in account currency. CashBackAmount int64 `json:"cashbackAmount"` // Amount of cash-back in account currency. Balance int64 `json:"balance"` // Balance in account currency. }
Transaction is a banking transaction.