feat(customer): list the customer's outlets
Adds GET /customer/outlets for the customer app: the active outlets of the customer's organization, where their EnakPoint and EnakCoin can be used, sorted by name. Each carries its name and address, and from the outlet's loyalty settings whether the cashier accepts EnakPoint and whether orders there earn EnakPoint or EnakCoin. Nothing internal (printer settings, tax rate) is exposed. The outlets list under /outlets needs a staff token, so the app had no way to show where the wallet works. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
8bf2fe5585
commit
c1ec6a3dfd
@@ -0,0 +1,40 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
|
||||
"github.com/google/uuid"
|
||||
|
||||
"apskel-pos-be/internal/constants"
|
||||
"apskel-pos-be/internal/contract"
|
||||
"apskel-pos-be/internal/processor"
|
||||
"apskel-pos-be/internal/repository"
|
||||
)
|
||||
|
||||
// CustomerOutletService serves the outlets list of the customer app.
|
||||
type CustomerOutletService interface {
|
||||
List(ctx context.Context, customerID uuid.UUID) *contract.Response
|
||||
}
|
||||
|
||||
type CustomerOutletServiceImpl struct {
|
||||
outlets *processor.CustomerOutletProcessor
|
||||
}
|
||||
|
||||
func NewCustomerOutletService(outlets *processor.CustomerOutletProcessor) *CustomerOutletServiceImpl {
|
||||
return &CustomerOutletServiceImpl{outlets: outlets}
|
||||
}
|
||||
|
||||
func (s *CustomerOutletServiceImpl) List(ctx context.Context, customerID uuid.UUID) *contract.Response {
|
||||
outlets, err := s.outlets.List(ctx, customerID)
|
||||
if err != nil {
|
||||
code := constants.InternalServerErrorCode
|
||||
if errors.Is(err, repository.ErrWalletNotFound) {
|
||||
code = constants.NotFoundErrorCode
|
||||
}
|
||||
return contract.BuildErrorResponse([]*contract.ResponseError{
|
||||
contract.NewResponseError(code, constants.RequestEntity, err.Error()),
|
||||
})
|
||||
}
|
||||
return contract.BuildSuccessResponse(outlets)
|
||||
}
|
||||
Reference in New Issue
Block a user