package emailalerts

import (
	"errors"
	"fonchain-fiee/api/emailAlerts"
	"fonchain-fiee/pkg/service"
	"fonchain-fiee/pkg/service/bundle/common"

	"github.com/gin-gonic/gin"
)

func EmailAlertSubmit(ctx *gin.Context) {
	var req emailAlerts.EmailAlertsSubmitReq
	if err := ctx.ShouldBindJSON(&req); err != nil {
		service.Error(ctx, err)
		return
	}
	resp, err := service.EmailAlertsProvider.EmailAlertsSubmit(ctx, &req)
	if err != nil {
		service.Error(ctx, errors.New(common.ErrorEmailAlertSubmitFailed))
		return
	}
	service.Success(ctx, resp)
}

func GetEmailInformationList(ctx *gin.Context) {
	var req emailAlerts.GetEmailInformationListReq
	if err := ctx.ShouldBindJSON(&req); err != nil {
		service.Error(ctx, err)
		return
	}
	resp, err := service.EmailAlertsProvider.GetEmailInformationList(ctx, &req)
	if err != nil {
		service.Error(ctx, errors.New(common.ErrorGetEmailInformationListFailed))
		return
	}
	service.Success(ctx, resp)
}
