package com.hz.pm.api.meeting.helper;

import com.ningdatech.yxt.client.YxtClient;
import com.ningdatech.yxt.constants.YxtSmsSignEnum;
import com.ningdatech.yxt.model.cmd.SendSmsCmd;
import com.ningdatech.yxt.model.cmd.SendSmsCmd.SendSmsContext;
import com.ningdatech.yxt.model.cmd.SubmitTaskCallResponse;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Component;

import java.util.Collections;
import java.util.List;

import static com.ningdatech.yxt.model.cmd.SubmitTaskCallCmd.SubmitTaskCallContext;
import static com.ningdatech.yxt.model.cmd.SubmitTaskCallCmd.of;

/**
 * <p>
 * YxtCallOrSmsHelper
 * </p>
 *
 * @author WendyYang
 * @since 23:59 2022/8/31
 */
@Component
@AllArgsConstructor
public class YxtCallOrSmsHelper {

    private final YxtClient yxtClient;

    public String submitCallTask(List<SubmitTaskCallContext> callContexts) {
        SubmitTaskCallResponse callResponse = yxtClient.submitTaskCall(of(callContexts));
        return callResponse.getSubmitKey();
    }

    public void sendSms(List<SendSmsContext> smsList) {
        SendSmsCmd cmd = new SendSmsCmd();
        cmd.setContextList(smsList);
        cmd.setSmsSignEnum(YxtSmsSignEnum.LS_BIG_DATA_BUREAU);
        yxtClient.submitSmsTask(cmd);
    }

    public void sendSms(SendSmsContext sms) {
        sendSms(Collections.singletonList(sms));
    }

}
