All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.convertapi.client.Config Maven / Gradle / Ivy

package com.convertapi.client;

import okhttp3.OkHttpClient;

import java.util.function.Function;

public class Config {
    private static final String SCHEME = "https";
    @SuppressWarnings("SpellCheckingInspection")
    private static final String HOST = "v2.convertapi.com";
    private static final int TIMEOUT = 180;
    private static String defaultSecret;
    private static Function defaultHttpClientBuilder = b -> b;
    private final String scheme;
    private final String host;
    private final String secret;
    private final int timeout;
    private final Function httpClientBuilder;

    @SuppressWarnings("unused")
    public Config(String secret, String scheme, String host, int timeout, Function httpClientBuilder) {
        this.scheme = scheme;
        this.host = host;
        this.secret = secret;
        this.timeout = timeout;
        this.httpClientBuilder = httpClientBuilder;
    }

    @SuppressWarnings("WeakerAccess")
    public static Config defaults() {
        return new Config(Config.defaultSecret, SCHEME, HOST, TIMEOUT, Config.defaultHttpClientBuilder);
    }

    @SuppressWarnings("WeakerAccess")
    public static Config defaults(String secret) {
        return new Config(secret, SCHEME, HOST, TIMEOUT, Config.defaultHttpClientBuilder);
    }

    @SuppressWarnings("WeakerAccess")
    public static Config defaults(String secret, Function httpClientBuilder) {
        return new Config(secret, SCHEME, HOST, TIMEOUT, httpClientBuilder);
    }

    @SuppressWarnings("unused")
    public static void setDefaultSecret(String defaultSecret) {
        Config.defaultSecret = defaultSecret;
    }

    @SuppressWarnings("unused")
    public static void setDefaultHttpBuilder(Function httpClientBuilder) {
        Config.defaultHttpClientBuilder = httpClientBuilder;
    }

    int getTimeout() {
        return timeout;
    }

    String getScheme() {
        return scheme;
    }

    String getHost() {
        return host;
    }

    String getSecret() {
        return secret;
    }

    Function getHttpClientBuilder() {
        return httpClientBuilder;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy