package lingtao.net.util;

import com.alibaba.fastjson.JSONObject;
import lingtao.net.vo.*;

import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.Map;

public class ShengDaPriceUtils {

    private static final String AppId = "3a1ab376af58ec4e918b4c506480efdf";
    private static final String AppSecret = "e06KAvT6ugHpQd5zjHukfMJBH0dxfA74gWk9o1lsLqOMTYExFVvWuTh0twMQvNBF";
    //UV打印亚克力
    private static final String productId = "UVDAYINYAKELI";

    public static String getToken() {
        String tokenString = HttpUtils.sendGetRequest("http://47.114.150.226:88/Handler/apiShengda.ashx?t=apiGetToken");
        System.out.println("获取token返回:" + tokenString);
        ShengDaTokenVo huaFangTokenVo = JSONObject.parseObject(tokenString, ShengDaTokenVo.class);
        return huaFangTokenVo.getResult();
    }


    public static ShengDaPriceResultVo getPrice(ShengDaPriceRequstVo params) {
        Map<String, String> heards = new HashMap<>();
        heards.put("Authorization", "Bearer " + getToken());
        String resultText = HttpUtils.sendPostRequest("https://open.sd2000.com/api/app/calculate", JSONObject.toJSONString(params), heards);
        ShengDaPriceResultVo result = JSONObject.parseObject(resultText, ShengDaPriceResultVo.class);
        return result;
    }

}
