package cn.pluss.platform.yt;

import cn.pluss.platform.util.SignUtils;
import cn.pluss.platform.yt.constant.YtConstant;
import com.alibaba.fastjson.JSON;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 *
 *圆通开放平台请求封装
 *@author: bzg
 *@time: 2022/2/24 14:09
 */
@Data
@NoArgsConstructor
public class YtLogisticsRequest {

    private String sign;

    private String timestamp;

    private Object param;

    private String format;

    private String reqUrl;

    public static final String FORMAT_JSON = "JSON";

    public static final String FORMAT_XML = "xml";

    public YtLogisticsRequest(Object param,String key,String method,String code){
        this.sign = SignUtils.getYtSign(JSON.toJSONString(param), key,method,YtConstant.YT_DEFAULT_VERSION);
        this.timestamp = String.valueOf(System.currentTimeMillis());
        this.param = JSON.toJSONString(param);
        this.format = FORMAT_JSON;
        this.reqUrl = YtConstant.YT_API_PROD_DOMAIN + method + "/" + YtConstant.YT_DEFAULT_VERSION + "/" + YtConstant.YT_DEFAULT_CODE + "/" + code;
    }
}
