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
- Variables
- func ParseCustomECPrivateKey(der []byte) (key *ecdsa.PrivateKey, err error)
- type Account
- type Authorizer
- type CashBackType
- type Corporate
- func (c *Corporate) Auth(callback string, permissions ...byte) (*TokenRequest, error)
- func (c *Corporate) CheckAuth(reqID string) (bool, error)
- func (c *Corporate) GetJSON(endpoint string, headers map[string]string) ([]byte, int, error)
- func (c *Corporate) PostJSON(endpoint string, headers map[string]string, payload io.Reader) ([]byte, int, error)
- func (c *Corporate) Rates() ([]Exchange, error)
- func (c *Corporate) Transactions(reqID string, account string, from, to time.Time) ([]Transaction, error)
- func (c *Corporate) User(reqID string) (*UserInfo, error)
- type Currency
- type CurveParams
- type Error
- type Exchange
- type Personal
- func (ac *Personal) GetJSON(endpoint string, headers map[string]string) ([]byte, int, error)
- func (ac *Personal) PostJSON(endpoint string, headers map[string]string, payload io.Reader) ([]byte, int, error)
- func (p *Personal) Rates() ([]Exchange, error)
- func (p *Personal) SetWebHook(url string) ([]byte, error)
- func (p *Personal) Transactions(account string, from, to time.Time) ([]Transaction, error)
- func (p *Personal) User() (*UserInfo, error)
- type Public
- 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 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 ( // None is cash-back type for foreign currencies accounts. None = "None" // UAH is default cash-back type for almost all accounts. UAH = "UAH" // Miles available only on Iron Card. Miles = "Miles" )
const DefaultBaseURL = "https://api.monobank.ua"
DefaultBaseURL is production URL of Monobank API.
Variables ¶
var BaseURL = DefaultBaseURL
BaseURL is a customizable URL of API.
Functions ¶
func ParseCustomECPrivateKey ¶ added in v0.0.14
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. }
Account is simple representation of bank account.
type Authorizer ¶ added in v0.0.3
Authorizer is an interface for different types of MonoBank API authorization.
type CashBackType ¶ added in v0.0.14
type CashBackType string
CashBackType is type of cash-back that credits to the account.
type Corporate ¶ added in v0.0.14
type Corporate struct {
// contains filtered or unexported fields
}
Corporate gives access to corporate methods.
func NewCorporate ¶ added in v0.0.14
NewCorporate returns new client of MonoBank Corporate API.
func (*Corporate) Auth ¶ added in v0.0.14
func (c *Corporate) Auth(callback string, permissions ...byte) (*TokenRequest, error)
Auth initializes access.
func (*Corporate) CheckAuth ¶ added in v0.0.14
CheckAuth checks status of request for client's personal data.
func (*Corporate) GetJSON ¶ added in v0.0.14
GetJSON builds the full endpoint path and gets the raw JSON.
func (*Corporate) PostJSON ¶ added in v0.0.14
func (c *Corporate) PostJSON(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.14
func (c *Corporate) Transactions(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.14
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.14
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.14
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.14
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.14
type Personal struct {
// contains filtered or unexported fields
}
Personal gives access to personal methods.
func NewPersonal ¶ added in v0.0.14
NewPersonal returns new client of MonoBank Personal API.
func (*Personal) GetJSON ¶ added in v0.0.14
GetJSON builds the full endpoint path and gets the raw JSON.
func (*Personal) PostJSON ¶ added in v0.0.14
func (ac *Personal) PostJSON( 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.14
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.14
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.14
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.14
type Public struct {
// contains filtered or unexported fields
}
Public gives access to public methods.
func NewPublic ¶ added in v0.0.14
func NewPublic() *Public
NewPublic returns new client of MonoBank Public API.
func (*Public) GetJSON ¶ added in v0.0.14
GetJSON builds the full endpoint path and gets the raw JSON.
func (*Public) PostJSON ¶ added in v0.0.14
func (c *Public) PostJSON( 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.14
Rates returns list of currencies rates from MonoBank API. See https://api.monobank.ua/docs/#/definitions/CurrencyInfo for details.
type SignTool ¶ added in v0.0.14
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.14
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.14
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 TokenRequest ¶ added in v0.0.14
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.14
type Transaction struct { ID string `json:"id"` // Unique transaction ID. Time int32 `json:"time"` // Unix 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.