package com.fq.channel.sdk.base.net;

import com.fq.channel.sdk.base.Constants.AppConfig;
import com.fq.channel.sdk.base.Constants.FqConfig;
import com.fq.channel.sdk.base.Exception.NullStringToEmptyAdapterFactory;
import com.fq.channel.sdk.base.net.callback.BaseCallback;
import com.fq.channel.sdk.base.net.req.ParamsUtils;
import com.fq.channel.sdk.base.net.req.ReqContent;
import com.fq.channel.sdk.base.net.req.ReqHeader;
import com.fq.channel.sdk.base.net.req.ReqInitBody;
import com.fq.channel.sdk.base.utils.Utils;
import com.fq.threelib.gson.Gson;
import com.fq.threelib.gson.GsonBuilder;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;

/**
 * @Description: 业务网络请求封装类
 * @Author: FLuty
 * @CreateDate: 2020/4/3 10:45
 */
public class FqNetRequest {

    /**
     * 初始化请求
     *
     * @param callback
     */
    public static void init(BaseCallback callback) {
        String request = ParamsUtils.getInstance().generateInitParams();
        HttpManager.getInstance().post(FqConfig.KEY_URL_INT,Utils.decodeText(request) , callback);
    }

    /**
     * 对Json字符串进行URLEncoder
     *
     * @param requestJson Json字符串
     * @return
     */
    private String encoderJson(String requestJson) {
        try {
            return URLEncoder.encode(requestJson, "UTF-8");
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        return "";
    }
}
