package tw.com.altob.goodpk.Api;

import android.content.Context;
import android.text.TextUtils;

import com.ga.sdk.api.AbstractBaseApi;

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

import tw.com.altob.goodpk.BuildConfig;
import tw.com.altob.goodpk.Util.PrefsUtil;

public class BaseApi extends AbstractBaseApi {

    @Override
    protected Map<String, String> getHeader() {
        Map<String, String> headers = null;

        if (!TextUtils.isEmpty(this.accessToken)) {
            headers = new HashMap<>();
            headers.put("Authorization", "Bearer " + this.accessToken);
        }

        return headers;
    }

    @Override
    protected String getAccessToken(Context context) {
        return PrefsUtil.getAccessToken(context);
    }

    @Override
    protected String toUrl(String path) {
        return BuildConfig.API_URL + path;
    }
}