package com.gree.mall.miniapp.logic.common.kuaidi100.core;


import com.gree.mall.miniapp.logic.common.kuaidi100.pojo.HttpResult;
import com.gree.mall.miniapp.logic.common.kuaidi100.request.BaseRequest;
import com.gree.mall.miniapp.logic.common.kuaidi100.response.BaseResponse;
import com.gree.mall.miniapp.logic.common.kuaidi100.utils.HttpUtils;

/**
 * @Author: api.kuaidi100.com
 * @Date: 2020-11-25 16:02
 */
public abstract class BaseClient implements IBaseClient{

    private int connectTimeout = 3000;

    private int socketTimeout = 3000;

    public HttpResult execute(BaseRequest request) throws Exception{

        return HttpUtils.doPost(getApiUrl(request),request,connectTimeout,socketTimeout);
    }

    public BaseResponse executeToObject(BaseRequest request) throws Exception{

        return null;
    }

    public void setTimeOut(int connectTimeout, int socketTimeout) {
        this.connectTimeout = connectTimeout;
        this.socketTimeout = socketTimeout;
    }

    public abstract String getApiUrl(BaseRequest request);

    public int getConnectTimeout() {
        return connectTimeout;
    }

    public int getSocketTimeout() {
        return socketTimeout;
    }
}
