package whatsapp

import (
	"context"
	"wechat-api/hook/aliyun"

	"wechat-api/internal/svc"
	"wechat-api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type SubmitWhatsappCodeLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewSubmitWhatsappCodeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SubmitWhatsappCodeLogic {
	return &SubmitWhatsappCodeLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx}
}

func (l *SubmitWhatsappCodeLogic) SubmitWhatsappCode(req *types.SubmitCodeReq) (*types.BaseMsgResp, error) {
	resp := types.BaseMsgResp{}
	_, err := aliyun.SubmitCamsCode(*req.Cc+*req.Phone, *req.Code, *req.WaId)

	if err != nil {
		resp.Msg = err.Error()
		resp.Code = 1
	}

	return &resp, nil
}
