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

import com.fq.channel.sdk.base.constants.FqConfig;
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.RepOrderBody;
import com.fq.channel.sdk.base.utils.Utils;

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

/**
 * @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);
    }

    /**
     * 渠道登录
     *
     * @param channelInfo
     * @param callback
     */
    public static void login(HashMap<String, String> channelInfo, BaseCallback callback) {
        String request = ParamsUtils.getInstance().generateLoginParams(channelInfo);
        HttpManager.getInstance().post(FqConfig.KEY_URL_LOGIN,Utils.decodeText(request) , callback);
    }

    /**
     * 创建订单
     *
     * @param callback
     */
    public static void createOrder(RepOrderBody payInfo, BaseCallback callback) {
        String request = ParamsUtils.getInstance().generateOrderParams(payInfo);
        HttpManager.getInstance().post(FqConfig.KEY_URL_CREATE_ORDER,Utils.decodeText(request) , callback);
    }

}
