package com.sqx.modules.utils;

import com.sqx.common.utils.Result;
import com.sqx.modules.common.service.CommonInfoService;
import com.winnerlook.model.VoiceNotifyBody;
import com.winnerlook.model.VoiceResponseResult;
import com.winnerlook.service.VoiceSender;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.LinkedHashMap;

public class AppNotifyUtil {

    public static Result AppNotify(String calleeNumber, String accountId, String token, String templateId) {
        VoiceNotifyBody message = new VoiceNotifyBody();
        /*用户接收回执的服务器地址*/
        message.setCallbackUrl("");
        message.setCalleeNumber(calleeNumber);
        message.setReplayTimes(1);
        /*设置平台分配的模板ID*/
        message.setTemplateId(templateId);
        LinkedHashMap<String,String> params = new LinkedHashMap<String,String>();
        message.setTemplateArgs(params);
        try {
            VoiceResponseResult result1 = VoiceSender.httpsSendVoiceNotify(message, accountId, token);
            System.out.println("result = " + result1);
            return Result.success().put("data",result1);
        }catch (Exception e) {
            //Log.e(this.getClass(), " e = " + e);
            e.printStackTrace();
        }
        return Result.error("系统错误，请联系管理员。");
    }
}
