service

package
v0.0.0-...-5e9bb57 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2018 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type InputError

type InputError struct {
	// contains filtered or unexported fields
}

InputError indicates that there was something wrong with the input.

func NewInputError

func NewInputError(message string) *InputError

NewInputError creates a new InputError instance

func (*InputError) Error

func (e *InputError) Error() string

type NotFoundError

type NotFoundError struct {
	// contains filtered or unexported fields
}

NotFoundError indicates that the request failed because element was not found.

func NewNotFoundError

func NewNotFoundError(message string) *NotFoundError

NewNotFoundError creates a new NotFoundError.

func (*NotFoundError) Error

func (e *NotFoundError) Error() string

type PaymentsRepository

type PaymentsRepository interface {
	Add(*domain.Payment) (string, error)
	GetAll() ([]*domain.Payment, error)
	Update(*domain.Payment) error
	Get(string) (*domain.Payment, error)
	Delete(string) error
	Exists(string) bool
}

PaymentsRepository is an interface that any repository that should be used by the service for Payments storage need to implement.

type PaymentsService

type PaymentsService struct {
	// contains filtered or unexported fields
}

PaymentsService implements all use cases of the Payments API.

func NewPaymentsService

func NewPaymentsService(repo PaymentsRepository) *PaymentsService

NewPaymentsService creates a new instance of PaymentsService with the provided repository.

func (*PaymentsService) Add

func (ps *PaymentsService) Add(payment *domain.Payment) (string, error)

Add adds a new payment to the service. Before that, it validates the argument.

func (*PaymentsService) Delete

func (ps *PaymentsService) Delete(id string) error

Delete deletes payment with given ID from the repository.

func (*PaymentsService) Get

func (ps *PaymentsService) Get(id string) (*domain.Payment, error)

Get retrieves a single Payment based on ID

func (*PaymentsService) GetAll

func (ps *PaymentsService) GetAll() ([]*domain.Payment, error)

GetAll simply returns all payments from the repository.

func (*PaymentsService) Update

func (ps *PaymentsService) Update(payment *domain.Payment) error

Update updates existing payment.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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