Documentation ¶
Index ¶
- Constants
- Variables
- func NewUUID() string
- type Account
- type Ledger
- func (ledger *Ledger) CreateAccount(account *Account) error
- func (ledger *Ledger) CreateTransaction(transaction *Transaction) error
- func (l *Ledger) DoRequest(method, url string, body io.Reader) (*http.Response, error)
- func (ledger *Ledger) GetAccount(accountID string) (*Account, error)
- func (l *Ledger) GetEndpoint() string
- func (ledger *Ledger) GetTransaction(txnID string) (*Transaction, error)
- func (ledger *Ledger) SearchAccounts(searchQuery map[string]interface{}) ([]*Account, error)
- func (ledger *Ledger) SearchTransactions(searchQuery map[string]interface{}) ([]*Transaction, error)
- func (ledger *Ledger) UpdateAccount(account *Account) error
- func (ledger *Ledger) UpdateTransaction(txn *Transaction) error
- type Transaction
- type TransactionLine
Constants ¶
const ( // AccountsAPI is the endpoint for creating and updating accounts AccountsAPI = "/v1/accounts" // AccountsSearchAPI is the endpoint for searching accounts AccountsSearchAPI = "/v1/accounts/_search" )
const ( // TransactionsAPI is the endpoint for creating and updating transactions TransactionsAPI = "/v1/transactions" // TransactionsSearchAPI is the endpoint for searching transactions TransactionsSearchAPI = "/v1/transactions/_search" )
Variables ¶
var ( ErrTransactionDuplicate = errors.New("Transaction is duplicate") ErrTransactionConflict = errors.New("Transaction ID conflict") ErrTransactionInvalid = errors.New("Transaction invalid") ErrTransactionNotfound = errors.New("Transaction not found") ErrAccountConflict = errors.New("Account ID conflict") ErrAccountInvalid = errors.New("Account invalid") ErrAccountNotfound = errors.New("Account not found") ErrInternalServer = errors.New("Ledger internal server error") )
Functions ¶
Types ¶
type Account ¶
type Account struct { ID string `json:"id"` Balance int `json:"balance"` Data map[string]interface{} `json:"data"` }
Account holds information such as account ID, balance and search data
type Ledger ¶
type Ledger struct {
// contains filtered or unexported fields
}
Ledger is the interface to all ledger API calls
func (*Ledger) CreateAccount ¶
CreateAccount creates a new account to QLedger
func (*Ledger) CreateTransaction ¶
func (ledger *Ledger) CreateTransaction(transaction *Transaction) error
CreateTransaction makes a new transaction to QLedger
func (*Ledger) GetAccount ¶
GetAccount returns an account in the Ledger which matches the given ID
func (*Ledger) GetEndpoint ¶
GetEndpoint returns the enpoint of the ledger
func (*Ledger) GetTransaction ¶
func (ledger *Ledger) GetTransaction(txnID string) (*Transaction, error)
GetTransaction returns a transaction in the Ledger which matches the given ID
func (*Ledger) SearchAccounts ¶
SearchAccounts returns all account in the Ledger which satisfies the given search query
func (*Ledger) SearchTransactions ¶
func (ledger *Ledger) SearchTransactions(searchQuery map[string]interface{}) ([]*Transaction, error)
SearchTransactions returns all transactions in the Ledger which satisfies the given search query
func (*Ledger) UpdateAccount ¶
UpdateAccount creates a new account to QLedger
func (*Ledger) UpdateTransaction ¶
func (ledger *Ledger) UpdateTransaction(txn *Transaction) error
UpdateTransaction updates `data` of existing transaction in QLedger
type Transaction ¶
type Transaction struct { ID string `json:"id"` Data map[string]interface{} `json:"data"` Timestamp string `json:"timestamp"` Lines []*TransactionLine `json:"lines"` }
Transaction holds information such as transaction ID, timestamp, movement of money between accounts and search data
type TransactionLine ¶
TransactionLine holds information about the account and amount transferred