package com.seeyon.apps.src_hxinvoice.util;

import cn.hutool.http.HttpRequest;
import com.alibaba.fastjson.JSONObject;
import com.seeyon.apps.src_hxinvoice.vo.HxinvoiceResponse;
import com.seeyon.ctp.util.json.JSONUtil;

/**
 * 功能描述:<br>
 * <pre>
 *
 * </pre>
 *
 * @Author: HuangZhengguo
 * @Date: 2024/4/28
 */
public class HxinvoiceHttpUtil {

    private HxinvoiceHttpUtil() {

    }

    public static String doPost(String url, String body) throws Exception {

        return HttpRequest.post(url).header("accept", "*/*")
                .body(body).execute().body();
    }

    public static HxinvoiceResponse parseResponse(String response) throws Exception {
        try {
            JSONObject object = JSONUtil.parseJSONString(response, JSONObject.class);
            return new HxinvoiceResponse(object);
        } catch (Exception e) {
            JSONObject jsonObject = new JSONObject();
            jsonObject.put("ZTDM", "0");
            jsonObject.put("ZTXX", "解析json异常");
            jsonObject.put("DDQQPCH", response);
            return new HxinvoiceResponse(jsonObject);
        }
    }



    public static void main(String[] args) {
        String url = "";
    }

}
