<commit_before>package io.fabianterhorst.apiclient;

import com.google.gson.ExclusionStrategy;
import com.google.gson.FieldAttributes;
import com.google.gson.GsonBuilder;

import io.realm.Realm;
import io.realm.RealmObject;
import okhttp3.HttpUrl;
import okhttp3.Interceptor;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;
import rx.Observable;

public class ApiClient<Api> extends ApiObserver implements IApi<Api> {

    private Api mApi;

    private final Class<Api> mClazz;

    private String mApiKey;

    private final String mApiBaseUrl;

    private static ApiClient mInstance;

    private final Interceptor API_KEY_INTERCEPTOR = chain -> {
        Request oldRequest = chain.request();
        HttpUrl httpUrl = getHttpUrlBuilder(oldRequest.url().newBuilder()).build();
        Request.Builder builder = getRequestBuilder(oldRequest.newBuilder());
        builder.url(httpUrl);
        return chain.proceed(builder.build());
    };

    public ApiClient(String apiKey, Class<Api> clazz, String apiBaseUrl) {
        this.mApiKey = apiKey;
        this.mClazz = clazz;
        this.mApiBaseUrl = apiBaseUrl;
    }

    public ApiClient(Realm realm, String apiKey, Class<Api> clazz, String apiBaseUrl) {
        super(realm);
        this.mApiKey = apiKey;
        this.mClazz = clazz;
        this.mApiBaseUrl = apiBaseUrl;
    }

    /**
     * Set the api key for the default interceptor
     * This api key will set as a query parameter value with the parameter key you have specify by initialising the ApiClient to the url
     *<commit_msg>add new constructor when no apiKey is needed<commit_after>package io.fabianterhorst.apiclient;

import com.google.gson.ExclusionStrategy;
import com.google.gson.FieldAttributes;
import com.google.gson.GsonBuilder;

import io.realm.Realm;
import io.realm.RealmObject;
import okhttp3.HttpUrl;
import okhttp3.Interceptor;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;
import rx.Observable;

public class ApiClient<Api> extends ApiObserver implements IApi<Api> {

    private Api mApi;

    private final Class<Api> mClazz;

    private String mApiKey;

    private final String mApiBaseUrl;

    private static ApiClient mInstance;

    private final Interceptor API_KEY_INTERCEPTOR = chain -> {
        Request oldRequest = chain.request();
        HttpUrl httpUrl = getHttpUrlBuilder(oldRequest.url().newBuilder()).build();
        Request.Builder builder = getRequestBuilder(oldRequest.newBuilder());
        builder.url(httpUrl);
        return chain.proceed(builder.build());
    };

    public ApiClient(Class<Api> clazz, String apiBaseUrl) {
        this.mClazz = clazz;
        this.mApiBaseUrl = apiBaseUrl;
    }

    public ApiClient(String apiKey, Class<Api> clazz, String apiBaseUrl) {
        this.mApiKey = apiKey;
        this.mClazz = clazz;
        this.mApiBaseUrl = apiBaseUrl;
    }

    public ApiClient(Realm realm, String apiKey, Class<Api> clazz, String apiBaseUrl) {
        super(realm);
        this.mApiKey = apiKey;
        this.mClazz = clazz;
        this.mApiBaseUrl = apiBaseUrl;
    }

    /**
     * Set the api key for the default interceptor
     * This api key will set as a query parameter value with the parameter key you have specify by initialising the ApiClient to the url
     *
{'fraction_non_alphanumeric': 0.08384744812114414, 'fraction_numerical': 0.003925967470555244, 'mean_word_length': 3.561381074168798, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3872356', 'n_tokens_mistral': 1082, 'n_tokens_neox': 1079, 'n_words': 278}