package com.usoftchina.dingtalk.sdk.test;

import com.usoftchina.dingtalk.sdk.MessageSdk;
import com.usoftchina.dingtalk.sdk.dto.SendMessageReq;
import com.usoftchina.dingtalk.sdk.util.UrlUtils;
import org.junit.Test;

import java.net.URLEncoder;

/**
 * @author yingp
 * @date 2020/2/21
 */
public class MessageTest extends BaseTest {
    private static MessageSdk sdk;

    static {
        sdk = new MessageSdk(properties);
    }

    @Test
    public void sendProcessMessage() throws Exception {
        String paramsStr = "{\"master\":\"UAS\",\"nodeId\":53840602,\"baseUrl\":\"" + URLEncoder.encode("http://yrkj.usoftchina.com:9443/uas", "utf-8") + "\"}";
        String msgUrl = UrlUtils.generateAuthUrl("ding0fb1b0cd2510faf7ffe93478753d9884", "UAS", "Uas", "http://yrkj.usoftchina.com:9443/uas/",
                "http://yrkj.usoftchina.com:9443/office/authorize", "uas/approval/" + URLEncoder.encode(paramsStr, "utf-8"));
        sdk.send("Uas", new SendMessageReq()
                .actionCard("应鹏的工作日报流程", "单据编号:2020020258", msgUrl)
                .toUser("manager8449"));
    }
}
