package com.lutao.cloud.oil.typhoon;


import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.alibaba.druid.util.StringUtils;
import com.google.common.collect.ImmutableMap;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.core.io.DefaultResourceLoader;
import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

/**
 * @author zhaoqiang
 * @title: DataAPIUtils.java
 * @package: org.casst.back.task.util
 * @description: 数据接口工具类
 * @created 2020年11月4日 上午2:16:39
 */
@RefreshScope
public class DataAPIUtils {

    private final static String CLIENT_ID = BusiConstant.APP_USER_NAME_01;


    /**
     * @Description: 获取同步token
     * @Param: [java.lang.String, java.lang.String, java.lang.String]
     * @Return: java.lang.String
     * @Author: vincent.zhao
     * @Date: 2021/12/3 17:33
     */
    public static String getSyncTokenIP59255615() {

        String tokenUrl = "http://" + BusiConstant.IP_59_255_61_5 + ":" + BusiConstant.PORT_9090 + BusiConstant.TAKEN_URL;
        String data = "client_id=" + CLIENT_ID + "&client_secret=" + BusiConstant.APP_USER_NAME_PASSWORD.get(CLIENT_ID);
        String result = HttpUtil.createGet(tokenUrl).header("content-type", "application/json")
                .header("client_id", CLIENT_ID)
                .header("client_secret", BusiConstant.APP_USER_NAME_PASSWORD.get(CLIENT_ID))
                .execute().body();
        String token = JSONUtil.parseObj(result).getStr("access_token");
        return token;
    }


}
