package net.yyc.common.ding.entity;


import net.yyc.common.ding.config.DingConfig;
import net.yyc.common.ding.sign.AccessSign;
import net.yyc.common.ding.utils.JsonUtils;
import net.yyc.common.ding.utils.SignUtils;
import lombok.Data;

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

@Data
public class EmployCheckRequest extends CommonRequest{

	private static final String PATH = "/oapi/v1/employ/freelances/check";

	public EmployCheckRequest(
			DingConfig config,
			List list) {

		Map<String,Object> map = new HashMap<>();
		map.put("freelances",list);
		String bodyStr = JsonUtils.serializer(map);
		String serviceSign = null;
		try {
			//签名
			serviceSign = SignUtils.serviceSign(PATH, config.getAppSecret(),
					"POST", new HashMap<>(), bodyStr.getBytes());
		} catch (Exception e) {
			e.printStackTrace();
		}

		this.body = bodyStr;
		this.sign = new AccessSign(config.getAppId(),serviceSign);
		this.queryUrl = String.format("%s%s", config.getQueryUrl(), PATH);
	}


}
