Documentation ¶
Index ¶
- func CloseDB(db *gorm.DB)
- func DecodeCreatePaymentRequest(_ context.Context, r *http.Request) (interface{}, error)
- func DecodeDeletePayementRequest(_ context.Context, r *http.Request) (interface{}, error)
- func DecodeGetListPaymentsRequest(_ context.Context, r *http.Request) (interface{}, error)
- func DecodeGetPaymentRequest(_ context.Context, r *http.Request) (interface{}, error)
- func DecodeUpdatePayementRequest(_ context.Context, r *http.Request) (interface{}, error)
- func EncodeBasicResponse(_ context.Context, w http.ResponseWriter, response interface{}) error
- func EncodeCreationResponse(ctx context.Context, w http.ResponseWriter, response interface{}) error
- func MakeCreatePaymentEndpoint(svc PaymentService) endpoint.Endpoint
- func MakeDeletePaymentEndpoint(svc PaymentService) endpoint.Endpoint
- func MakeGetListPaymentsEndpoint(svc PaymentService) endpoint.Endpoint
- func MakeGetPaymentEndpoint(svc PaymentService) endpoint.Endpoint
- func MakeUpdatePaymentEndpoint(svc PaymentService) endpoint.Endpoint
- func MigrateDB(db *gorm.DB)
- func NewDBConnection(file string) (*gorm.DB, error)
- func NewHTTPTransport(svc PaymentService) http.Handler
- type Attributes
- type BeneficiaryParty
- type Charge
- type ChargesInformation
- type CreatePaymentRequest
- type CreatePaymentResponse
- type DebtorParty
- type DeletePaymentRequest
- type DeletePaymentResponse
- type Forex
- type GetListPaymentRequest
- type GetPaymentRequest
- type GetPaymentResponse
- type MockPaymentService
- func (_m *MockPaymentService) CreatePayment(p Payment) (CreatePaymentResponse, error)
- func (_m *MockPaymentService) DeletePayment(id uuid.UUID) (*time.Time, error)
- func (_m *MockPaymentService) GetListPayments() ([]Payment, error)
- func (_m *MockPaymentService) GetPayment(id string) (Payment, error)
- func (_m *MockPaymentService) UpdatePayment(p UpdatePaymentRequest) (UpdatePaymentResponse, error)
- type Model
- type ModelBase
- type Payment
- type PaymentService
- type SponsorParty
- type UpdatePaymentRequest
- type UpdatePaymentResponse
- type Validator
- func (v Validator) CreatePayment(p Payment) (CreatePaymentResponse, error)
- func (v Validator) DeletePayment(id uuid.UUID) (*time.Time, error)
- func (v Validator) GetListPayments() ([]Payment, error)
- func (v Validator) GetPayment(id string) (Payment, error)
- func (v Validator) UpdatePayment(req UpdatePaymentRequest) (UpdatePaymentResponse, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecodeCreatePaymentRequest ¶
DecodeCreatePaymentRequest exported to be accessible from outside the package (from main)
func DecodeDeletePayementRequest ¶
DecodeDeletePayementRequest exported to be accessible from outside the package (from main)
func DecodeGetListPaymentsRequest ¶
DecodeGetListPaymentsRequest exported to be accessible from outside the package (from main)
func DecodeGetPaymentRequest ¶
DecodeGetPaymentRequest exported to be accessible from outside the package (from main)
func DecodeUpdatePayementRequest ¶
DecodeUpdatePayementRequest exported to be accessible from outside the package (from main)
func EncodeBasicResponse ¶
func EncodeBasicResponse(_ context.Context, w http.ResponseWriter, response interface{}) error
EncodeBasicResponse exported to be accessible from outside the package (from main)
func EncodeCreationResponse ¶
func EncodeCreationResponse(ctx context.Context, w http.ResponseWriter, response interface{}) error
EncodeCreationResponse exported to be accessible from outside the package (from main)
func MakeCreatePaymentEndpoint ¶
func MakeCreatePaymentEndpoint(svc PaymentService) endpoint.Endpoint
MakeCreatePaymentEndpoint is an endpoint constructor that takes a service and constructs individual endpoints for the CreatePayment method
func MakeDeletePaymentEndpoint ¶
func MakeDeletePaymentEndpoint(svc PaymentService) endpoint.Endpoint
MakeDeletePaymentEndpoint is an endpoint constructor that takes a service and constructs individual endpoints for the DeletePayment method
func MakeGetListPaymentsEndpoint ¶
func MakeGetListPaymentsEndpoint(svc PaymentService) endpoint.Endpoint
MakeGetListPaymentsEndpoint is an endpoint constructor that takes a service and constructs individual endpoints for the GetListPayments method
func MakeGetPaymentEndpoint ¶
func MakeGetPaymentEndpoint(svc PaymentService) endpoint.Endpoint
MakeGetPaymentEndpoint is an endpoint constructor that takes a service and constructs individual endpoints for the GetPayment method
func MakeUpdatePaymentEndpoint ¶
func MakeUpdatePaymentEndpoint(svc PaymentService) endpoint.Endpoint
MakeUpdatePaymentEndpoint is an endpoint constructor that takes a service and constructs individual endpoints for the UpdatePayment method
func NewDBConnection ¶
NewDBConnection implements the connection to the Postgresql DB
func NewHTTPTransport ¶
func NewHTTPTransport(svc PaymentService) http.Handler
NewHTTPTransport creates a new JSON over HTTP transport
Types ¶
type Attributes ¶
type Attributes struct { Model Amount string `json:"amount" validate:"required"` BeneficiaryParty BeneficiaryParty `json:"beneficiary_party" gorm:"auto_preload" validate:"required"` BeneficiaryPartyID uint `json:"-" sql:"index"` ChargesInformation ChargesInformation `json:"charges_information" gorm:"auto_preload" validate:"required"` ChargesInformationID uint `json:"-" sql:"index"` Currency string `json:"currency" validate:"required"` DebtorParty DebtorParty `json:"debtor_party" gorm:"auto_preload" validate:"required"` DebtorPartyID uint `json:"-" sql:"index"` EndToEndReference string `json:"end_to_end_reference" validate:"required"` Forex Forex `json:"fx" gorm:"auto_preload" validate:"required"` ForexID uint `json:"-" sql:"index"` NumericReference string `json:"numeric_reference" validate:"required"` PayID string `json:"payment_id" validate:"required"` PaymentPurpose string `json:"payment_purpose" validate:"required"` PaymentScheme string `json:"payment_scheme" validate:"required"` PaymentType string `json:"payment_type" validate:"required"` ProcessingDate string `json:"processing_date" validate:"required"` Reference string `json:"reference" validate:"required"` SchemePaymentSubType string `json:"scheme_payment_sub_type" validate:"required"` SchemePaymentType string `json:"scheme_payment_type" validate:"required"` SponsorParty SponsorParty `json:"sponsor_party" gorm:"auto_preload" validate:"required"` SponsorPartyID uint `json:"-" sql:"index"` }
Attributes ...
type BeneficiaryParty ¶
type BeneficiaryParty struct { DebtorParty AccountType int `json:"account_type" binding:"exists"` }
BeneficiaryParty ...
type Charge ¶
type Charge struct { Model ChargesInformationID uint `json:"-" sql:"index"` Amount string `json:"amount" validate:"required"` Currency string `json:"currency" validate:"required"` }
Charge ...
type ChargesInformation ¶
type ChargesInformation struct { Model BearerCode string `json:"bearer_code" validate:"required"` SenderCharges []Charge `json:"sender_charges" gorm:"auto_preload" validate:"required"` ReceiverChargesAmount string `json:"receiver_charges_amount" validate:"required"` ReceiverChargesCurrency string `json:"receiver_charges_currency" validate:"required"` }
ChargesInformation ...
type CreatePaymentRequest ¶
type CreatePaymentRequest struct {
Payment
}
CreatePaymentRequest is the request type used to insert a new payment
type CreatePaymentResponse ¶
CreatePaymentResponse is the response returned after creating a new payment containing the Payment ID
type DebtorParty ¶
type DebtorParty struct { SponsorParty AccountName string `json:"account_name" validate:"required"` AccountNumberCode string `json:"account_number_code" validate:"required"` Address string `json:"address" validate:"required"` Name string `json:"name" validate:"required"` }
DebtorParty ...
type DeletePaymentRequest ¶
DeletePaymentRequest represents the type needed when requesting to delete a payment
type DeletePaymentResponse ¶
DeletePaymentResponse represents the type needed as a response to a payment deletion
type Forex ¶
type Forex struct { Model ContractReference string `json:"contract_reference" validate:"required"` ExchangeRate string `json:"exchange_rate" validate:"required"` OriginalAmount string `json:"original_amount" validate:"required"` OriginalCurrency string `json:"original_currency" validate:"required"` }
Forex ...
type GetListPaymentRequest ¶
type GetListPaymentRequest struct{}
GetListPaymentRequest is the request type used to list all payments
type GetPaymentRequest ¶
type GetPaymentRequest struct {
PaymentID string
}
GetPaymentRequest is the request type used to retrieve a specific payment
type GetPaymentResponse ¶
type GetPaymentResponse struct {
Payment
}
GetPaymentResponse is the request type used to retrieve a specific payment
type MockPaymentService ¶
MockPaymentService is an autogenerated mock type for the PaymentService type
func (*MockPaymentService) CreatePayment ¶
func (_m *MockPaymentService) CreatePayment(p Payment) (CreatePaymentResponse, error)
CreatePayment provides a mock function with given fields: p
func (*MockPaymentService) DeletePayment ¶
DeletePayment provides a mock function with given fields: id
func (*MockPaymentService) GetListPayments ¶
func (_m *MockPaymentService) GetListPayments() ([]Payment, error)
GetListPayments provides a mock function with given fields:
func (*MockPaymentService) GetPayment ¶
func (_m *MockPaymentService) GetPayment(id string) (Payment, error)
GetPayment provides a mock function with given fields: id
func (*MockPaymentService) UpdatePayment ¶
func (_m *MockPaymentService) UpdatePayment(p UpdatePaymentRequest) (UpdatePaymentResponse, error)
UpdatePayment provides a mock function with given fields: p
type ModelBase ¶
type ModelBase struct { CreatedAt time.Time `json:"-"` UpdatedAt time.Time `json:"-"` DeletedAt *time.Time `json:"-" sql:"index"` }
ModelBase model definition, including fields `CreatedAt`, `UpdatedAt`, `DeletedAt`, which could be embedded in all models
type Payment ¶
type Payment struct { ModelBase ID uuid.UUID `json:"id" gorm:"type:uuid; primary_key"` Type string `json:"type" validate:"required"` Version uint `json:"version" binding:"exists"` OrganisationID uuid.UUID `json:"organisation_id" validate:"required"` Attributes Attributes `json:"attributes" gorm:"auto_preload" validate:"required"` AttributesID uint `json:"-" sql:"index"` }
Payment reprensents a payment resource
type PaymentService ¶
type PaymentService interface { GetPayment(id string) (Payment, error) GetListPayments() ([]Payment, error) CreatePayment(p Payment) (CreatePaymentResponse, error) UpdatePayment(p UpdatePaymentRequest) (UpdatePaymentResponse, error) DeletePayment(id uuid.UUID) (*time.Time, error) }
PaymentService is an interface that implements a simple RESTful API for Payment Service (CRUD functionality against a postgresql DB). PaymentService can retrieve a list of all submitted Payments (GetListPayment), get a payment based on a payment ID (GetPayement), create a payment based on a json file and return its ID, update a payment based on the original payment ID and a new payment json file and delete a payment (softdelete - DeletedAt will have a timestamp but the entry will still be available)
func NewLogging ¶
func NewLogging(logger log.Logger, next PaymentService) PaymentService
NewLogging is how the logging middleware (loggingMiddleware struct) is constructed (the function is exported so it can be used from outside the package)
func NewPaymentService ¶
func NewPaymentService(db *gorm.DB) PaymentService
NewPaymentService is the payment API contructor function
func NewValidator ¶
func NewValidator(svc PaymentService) (PaymentService, error)
NewValidator returns a new instance of PaymentService with a model validation layer
type SponsorParty ¶
type SponsorParty struct { Model //gorm.Model AccountNumber string `json:"account_number" validate:"required"` BankID string `json:"bank_id" validate:"required"` BankIDCode string `json:"bank_id_code" validate:"required"` }
SponsorParty ...
type UpdatePaymentRequest ¶
UpdatePaymentRequest is the request passed when updating a payment based on the ID and the new payment information.
type UpdatePaymentResponse ¶
UpdatePaymentResponse is the response returned after updating an already existing payment based on its ID
type Validator ¶
type Validator struct {
// contains filtered or unexported fields
}
Validator needs to be exported as it is the return type of NewValidator who is also exported
func (Validator) CreatePayment ¶
func (v Validator) CreatePayment(p Payment) (CreatePaymentResponse, error)
CreatePayment needs to be exported to be accessed outside of the paymentsapi package
func (Validator) DeletePayment ¶
DeletePayment needs to be exported to be accessed outside of the paymentsapi package
func (Validator) GetListPayments ¶
GetListPayments needs to be exported to be accessed outside of the paymentsapi package
func (Validator) GetPayment ¶
GetPayment needs to be exported to be accessed outside of the paymentsapi package
func (Validator) UpdatePayment ¶
func (v Validator) UpdatePayment(req UpdatePaymentRequest) (UpdatePaymentResponse, error)
UpdatePayment needs to be exported to be accessed outside of the paymentsapi package