package com.trade.service.thirdparty.sop.util;

import java.math.BigDecimal;
import java.util.Optional;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.alibaba.fastjson2.JSON;
import com.trade.common.utils.http.HttpClientUtils;
import com.trade.common.utils.http.HttpConfig;
import com.trade.service.thirdparty.sop.dto.SOPBasicRequest;

/**
 * SOP 接口请求
 */
public class SOPRestUtil {

    private static final Logger logger = LoggerFactory.getLogger(SOPRestUtil.class);

    public static ResponseJson sendPost2SOP(String url, SOPBasicRequest request) {
        logger.info("发起SOP http 接口请求，接口地址：{}，请求参数：{}", url, JSON.toJSONString(request));
        String result = HttpClientUtils.post(HttpConfig.custom().json(JSON.toJSONString(request)).url(url));
        logger.info("SOP 响应原始报文{}", result);
        return JSON.parseObject(result, ResponseJson.class);
    }

    public static ResponseJson sendGet2SOP(String url) {
        logger.info("发起SOP http 接口请求，接口地址：{}", url);
        String result = HttpClientUtils.get(HttpConfig.custom().url(url));
        logger.info("SOP 响应原始报文{}", result);
        return JSON.parseObject(result, ResponseJson.class);
    }
}
