Documentation ¶
Index ¶
- type InputError
- type NotFoundError
- type PaymentsRepository
- type PaymentsService
- func (ps *PaymentsService) Add(payment *domain.Payment) (string, error)
- func (ps *PaymentsService) Delete(id string) error
- func (ps *PaymentsService) Get(id string) (*domain.Payment, error)
- func (ps *PaymentsService) GetAll() ([]*domain.Payment, error)
- func (ps *PaymentsService) Update(payment *domain.Payment) error
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