coins

package module
v0.0.0-...-bffa35e Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2019 License: MIT Imports: 3 Imported by: 0

README

Coins

This is generic Wallet service with a RESTful API. Users can send money from their wallets to another.

Set up

Requires Docker.

	docker-compose up -d

Tests

make runtests to run a unit-tests.

cd tests/ && make test to run integrations tests into docker container.

If you want to write new tests - you can call make up to set up services from docker-compose.yml and call make runtests to run local tests.

API

Please see API: Payments, Accounts.

Godocs

[GoDoc](https://godoc.org/github.com/krpst/coins)

Contributing

Please see CONTRIBUTING.md.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotEnoughMoney    = errors.New("you don't have enough money")
	ErrDifferentCurrency = errors.New("receiver has a different currency")
)

Functions

This section is empty.

Types

type Account

type Account struct {
	AccountID AccountID
	Balance   decimal.Decimal
	Currency  string
}

Account represents user account.

func (*Account) Transfer

func (from *Account) Transfer(to *Account, sum decimal.Decimal) (*Payment, error)

type AccountID

type AccountID string

func (AccountID) String

func (a AccountID) String() string

type AccountRepository

type AccountRepository interface {
	Add(account *Account, tx transactions.ITransaction) error
	Get() ([]*Account, error)
	GetWithLock(id AccountID, tx transactions.ITransaction) (*Account, error)
	Update(account *Account, tx transactions.ITransaction) error
}

AccountRepository provides access to account.

type Payment

type Payment struct {
	ID            int
	FromAccountID AccountID
	ToAccountID   AccountID
	Sum           decimal.Decimal
}

Payment represents history of payments.

type PaymentRepository

type PaymentRepository interface {
	Add(payment *Payment, tx transactions.ITransaction) error
	Get() ([]*Payment, error)
}

PaymentRepository provides access to payments.

Directories

Path Synopsis
Package account provides the use-case of users accounts and it manipulations.
Package account provides the use-case of users accounts and it manipulations.
cmd
implementation
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
Package payments provides the use-case of history of accounts payments.
Package payments provides the use-case of history of accounts payments.
pkg
transactions/mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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