org.gs4tr.gcc.restclient.GCConfig Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gcc-restclient Show documentation
Show all versions of gcc-restclient Show documentation
GlobalLink Connect Cloud java is a library to connect your system to GlobalLink Connect Cloud REST API.
package org.gs4tr.gcc.restclient;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
public class GCConfig {
private String apiUrl;
private String userName;
private String password;
private String connectorKey;
private String userAgent;
private GCProxyConfig proxyConfig;
private Map customHeaders = new HashMap<>();
private String bearerToken;
private Logger logger;
/**
* Basic Configuration class for GCC. Default Constructor
*
*/
public GCConfig() {
logger = Logger.getLogger(GCExchange.class.getName());
logger.setLevel(Level.OFF);
}
/**
* Basic Configuration class for GCC
*
* @param apiUrl API URL e.g. https://xxx-dev.translations.com/api/v2
* @param userName User Name
* @param password Password
*/
public GCConfig(String apiUrl, String userName, String password) {
this();
this.apiUrl = apiUrl;
this.userName = userName;
this.password = password;
}
/**
* Basic Configuration class for GCC
*
* @param apiUrl API URL e.g. https://xxx-dev.translations.com/api/v2
* @param userName User Name
* @param password Password
* @param connectorKey connector key
*/
public GCConfig(String apiUrl, String userName, String password, String connectorKey) {
this(apiUrl, userName, password);
this.connectorKey = connectorKey;
}
/**
* Basic Configuration class for GCC
*
* @param apiUrl API URL e.g. https://xxx-dev.translations.com/api/v2
* @param userName User Name
* @param password Password
* @param connectorKey connector key
* @param userAgent User Agent
*/
public GCConfig(String apiUrl, String userName, String password, String connectorKey, String userAgent) {
this(apiUrl, userName, password, connectorKey);
this.userAgent = userAgent;
}
/**
* Basic Configuration class for GCC
*
* @param apiUrl API URL e.g. https://xxx-dev.translations.com/api/v2
* @param userName User Name
* @param password Password
* @param connectorKey connector key
* @param userAgent User Agent
* @param customHeaders customHeaders
*/
public GCConfig(String apiUrl, String userName, String password, String connectorKey, String userAgent,
Map customHeaders) {
this(apiUrl, userName, password, connectorKey, userAgent);
this.customHeaders.putAll(customHeaders);
}
public String getApiUrl() {
return apiUrl;
}
public void setApiUrl(String apiUrl) {
this.apiUrl = apiUrl;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getUserAgent() {
return userAgent;
}
public void setUserAgent(String userAgent) {
this.userAgent = userAgent;
}
public String getBearerToken() {
return bearerToken;
}
public void setBearerToken(String bearerToken) {
this.bearerToken = bearerToken;
}
public String getConnectorKey() {
return connectorKey;
}
public void setConnectorKey(String connectorKey) {
this.connectorKey = connectorKey;
}
public GCProxyConfig getProxyConfig() {
return proxyConfig;
}
public void setProxyConfig(GCProxyConfig proxyConfig) {
this.proxyConfig = proxyConfig;
}
public Map getCustomHeaders() {
return customHeaders;
}
public void setCustomHeaders(Map customHeaders) {
this.customHeaders = customHeaders;
}
public static Builder builder() {
return new Builder();
}
public Logger getLogger() {
return logger;
}
public void setLogger(Logger logger) {
this.logger = logger;
}
public static class Builder {
private String apiUrl;
private String userName;
private String password;
private String connectorKey;
private String userAgent;
private Map customHeaders = new HashMap<>();
private Builder() {
}
public Builder apiUrl(String apiUrl) {
this.apiUrl = apiUrl;
return this;
}
public Builder userName(String userName) {
this.userName = userName;
return this;
}
public Builder password(String password) {
this.password = password;
return this;
}
public Builder connectorKey(String connectorKey) {
this.connectorKey = connectorKey;
return this;
}
public Builder userAgent(String userAgent) {
this.userAgent = userAgent;
return this;
}
public Builder customHeader(String name, String value) {
customHeaders.put(name, value);
return this;
}
public Builder customHeaders(Map headers) {
customHeaders.putAll(headers);
return this;
}
public GCConfig build() {
return new GCConfig(apiUrl, userName, password, connectorKey, userAgent, customHeaders);
}
}
}