handler

package
v0.0.0-...-43d2b9d Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2019 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewError

func NewError(message string, kind ErrorKind) error

NewError creates new custom handler error

func WrapError

func WrapError(err error, message string, kind ErrorKind) error

WrapError creates new wrapped handler error

Types

type Account

type Account struct {
	UID       string    `json:"uid"`
	Currency  string    `json:"currency"`
	Balance   float64   `json:"balance"`
	CreatedAt time.Time `json:"created_at"`
}

Account define account description

type AccountBuilder

type AccountBuilder interface {
	// SetUID initializes UID for the new account
	SetUID(uid string) AccountBuilder
	// SetBalance initializes initial balance for the new account
	SetBalance(balance float64) AccountBuilder
	// SetCurrency initializes currency for the new account
	SetCurrency(currency string) AccountBuilder

	// Build actually creates new account
	Build(ctx context.Context) (*Account, error)
}

AccountBuilder declare interface to build new account

type AccountManager

type AccountManager interface {
	// AllAccounts return all available accounts in the system
	AllAccounts(ctx context.Context) ([]Account, error)
	// AllPayments return all available payments in the system
	AllPayments(ctx context.Context) ([]Payment, error)

	// AccountBuilder instantiate new account builder
	AccountBuilder() AccountBuilder
	// PaymentBuilder instantiate new payment builder
	PaymentBuilder() PaymentBuilder
}

AccountFactory declare interface to access accounts and payments information (kind of facade to simplify interface)

type AccountRequest

type AccountRequest struct {
	UID      string  `json:"uid"`
	Currency string  `json:"currency"`
	Balance  float64 `json:"balance"`
}

AccountRequest define request to create new account

type Error

type Error struct {
	Kind ErrorKind
	// contains filtered or unexported fields
}

Error define custom handler error

type ErrorKind

type ErrorKind int8

ErrorKind define kind of error, occurred

const (
	ServerError ErrorKind = iota + 1
	ClientError
)

type Payment

type Payment struct {
	UID       string    `json:"account"`
	SourceUID *string   `json:"from_account,omitempty"`
	TargetUID *string   `json:"to_account,omitempty"`
	Direction string    `json:"direction"`
	Amount    float64   `json:"amount"`
	CreatedAt time.Time `json:"created_at"`
}

Payment define payment description

type PaymentBuilder

type PaymentBuilder interface {
	// SetAmount initializes amount for the new payment
	SetAmount(amount float64) PaymentBuilder
	// SetPayer initializes payer for the new payment
	SetPayer(uid string) PaymentBuilder
	// SetRecipient initializes recipient for the new payment
	SetRecipient(uid string) PaymentBuilder

	// Build actually creates new payment
	Build(ctx context.Context) (*Payment, error)
}

PaymentBuilder declare interface to build new payment

type PaymentRequest

type PaymentRequest struct {
	RecipientUID string  `json:"recipient"`
	Amount       float64 `json:"amount"`
}

PaymentRequest define request to create new payment

type ServerStatusResponse

type ServerStatusResponse struct {
	IsAlive   bool   `json:"is_alive"`
	BuildTime string `json:"build_time"`
	Version   string `json:"version"`
}

ServerStatusResponse declare response for status request

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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