package whatsapp

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

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

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

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

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

func (l *DeregisterPhoneNumberLogic) DeregisterPhoneNumber(req *types.DeregisterReq) (*types.BaseMsgResp, error) {
	resp := types.BaseMsgResp{Msg: "取消注册成功"}

	_, err := aliyun.DeRegisterCamsPhoneNumber(*req.Phone, *req.WaId)
	if err != nil {
		resp.Msg = err.Error()
		resp.Code = 1
	}

	return &resp, nil
}
