package com.baoshi.swms.net.subscribe;

import com.baoshi.swms.net.api.SwmsApi;
import com.baoshi.swms.net.constant.SwmsConstant;

import java.util.HashMap;
import java.util.Map;

/**
 * SWMS基础发布者
 *
 * @author Zhendong Zhou
 * @date 2021/12/21 15:59
 */
public class SwmsBaseSubscribe extends BaseSubscribe{
    private static SwmsApi okHttpApi;

    public static SwmsApi getOkHttpApi() {
        if (okHttpApi==null) {
            okHttpApi = newApi(SwmsConstant.BASE_URL, getHeaderParams(), SwmsApi.class);
        }
        return okHttpApi;
    }

    public static void refreshSingleton(){
        okHttpApi=null;
    }

    //设置表头
    protected static Map<String, String> getHeaderParams() {
        Map<String, String> params = new HashMap<>();
        params.put("timestamp", String.valueOf(System.currentTimeMillis() / 1000));
        return params;
    }
}
