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 ApiStatusChangedEventHandler implements MessageEventHandler {

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

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

    @Override
    public String getDisplayName() {
        return "API 상태 변화";
    }

    @Override
    public String getDescription() {
        return "<div>사용 가능 변수: </div><br/>"
                + "<div> - message 알림 메시지 </div><br/>";
    }

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