forked from ebhomengo/niki
22 lines
795 B
Go
22 lines
795 B
Go
package adminkindboxreqservice
|
|
|
|
import (
|
|
"context"
|
|
|
|
param "git.gocasts.ir/ebhomengo/niki/param/admin/kind_box_req"
|
|
richerror "git.gocasts.ir/ebhomengo/niki/pkg/rich_error"
|
|
)
|
|
|
|
func (s Service) AssignSenderAgent(ctx context.Context, req param.AssignSenderRequest) (param.AssignSenderResponse, error) {
|
|
const op = "adminkindboxreqservice.AssignSenderAgent"
|
|
if fieldErrors, vErr := s.vld.ValidateAssignSenderAgent(ctx, req); vErr != nil {
|
|
return param.AssignSenderResponse{FieldErrors: fieldErrors}, richerror.New(op).WithErr(vErr)
|
|
}
|
|
err := s.repo.AssignSenderAgentToKindBoxReq(ctx, req.KindBoxReqID, req.SenderAgentID)
|
|
if err != nil {
|
|
return param.AssignSenderResponse{}, richerror.New(op).WithErr(err).WithKind(richerror.KindUnexpected)
|
|
}
|
|
|
|
return param.AssignSenderResponse{}, nil
|
|
}
|