package com.eactive.eai.rms.ext.djb.ums.event;

import java.util.HashMap;
import java.util.Map;

import org.springframework.stereotype.Component;

import com.eactive.apim.portal.template.entity.MessageCode;
import com.eactive.apim.portal.template.service.MessageEventHandler;
import com.eactive.apim.portal.template.service.MessageRecipient;
import com.eactive.apim.portal.template.service.MessageSendEvent;

@Component
public class AdminVerificationMobilePhoneEventHandler implements MessageEventHandler {

    @Override
    public MessageCode getKey() {
        return MessageCode.ADMIN_VERIFICATION_MOBILEPHONE;
    }

    @Override
    public boolean allowAdditionalRecipients() {
        return false;
    }

    @Override
    public String getDisplayName() {
        return "관리자포탈 휴대폰 인증번호 발송";
    }

    @Override
    public String getDescription() {
        return "<div>사용 가능 변수: </div><br/>"
                + "<div> - userName 수신자 이름 </div><br/>"
                + "<div> - authNumber 인증번호 </div><br/>";
    }

    @Override
    public MessageSendEvent createEvent(Object source, MessageRecipient recipient, Map<String, Object> params) {
        Map<String, String> eventParams = new HashMap<>();
        String authNumber = (String) params.get("authNumber");
        eventParams.put("authNumber", authNumber);
        eventParams.put("AUTH_CODE", authNumber);
        eventParams.put("userName", (String) params.get("userName"));
        return new MessageSendEvent(source, MessageCode.ADMIN_VERIFICATION_MOBILEPHONE, recipient, eventParams);
    }
}
