diff --git a/src/main/java/com/contentstack/sdk/Config.java b/src/main/java/com/contentstack/sdk/Config.java index cf8d91d8..57d93968 100644 --- a/src/main/java/com/contentstack/sdk/Config.java +++ b/src/main/java/com/contentstack/sdk/Config.java @@ -1,7 +1,5 @@ package com.contentstack.sdk; -import lombok.Getter; -import lombok.Setter; import okhttp3.ConnectionPool; import org.jetbrains.annotations.NotNull; import org.json.JSONObject; @@ -23,23 +21,37 @@ public class Config { protected String version = "v3"; protected String scheme = "https://"; protected String endpoint; + protected String[] earlyAccess; protected boolean enableLivePreview = false; protected String livePreviewHost; protected JSONObject livePreviewEntry = null; protected ContentstackRegion region = ContentstackRegion.US; protected String managementToken; - @Setter - @Getter protected String branch; - @Setter protected Proxy proxy = null; protected ConnectionPool connectionPool = new ConnectionPool(); protected List plugins = null; + + /** + * Get early access + * @return array of String + */ + public String[] getEarlyAccess() { + return this.earlyAccess; + } + /** - * The configuration for the contentstack that contains support for + * Get early access + * @param earlyAccess type of String[] + * @return instance of {@link Config} */ + public Config setEarlyAccess(String[] earlyAccess) { + this.earlyAccess = earlyAccess; + return this; + } + public String getBranch() { return branch; } @@ -51,20 +63,20 @@ public void setBranch(String branch) { /** * Proxy can be set like below. * - * @param proxy - * Proxy setting, typically a type (http, socks) and a socket address. A Proxy is an immutable object - *
- *
- * Example:
- *
- * - * java.net.Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("proxyHost", "proxyPort")); - * java.net.Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("sl.theproxyvpn.io", 80)); Config - * config = new Config(); config.setProxy(proxy); - * + * @param proxy Proxy setting, typically a type (http, socks) and a socket address. A Proxy is an immutable object + *
+ *
+ * Example:
+ *
+ * + * java.net.Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("proxyHost", "proxyPort")); + * java.net.Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("sl.theproxyvpn.io", 80)); Config + * config = new Config(); config.setProxy(proxy); + * */ - @Getter - protected String[] earlyAccess; + public void setProxy(Proxy proxy) { + this.proxy = proxy; + } /** * Returns the Proxy instance @@ -122,8 +134,13 @@ public void setPlugins(List plugins) { this.plugins = plugins; } - public void setPlugins(List plugins) { - this.plugins = plugins; + /** + * Gets host. + * + * @return the host + */ + public String getHost() { + return host; } /** @@ -191,24 +208,4 @@ public enum ContentstackRegion { US, EU, AZURE_NA, AZURE_EU } - - /** - * To initialize the SDK with the latest features offered in the early access phase, - * include the early access parameter as shown in the following code: - * - * @param earlyAccessFeatures The list of Early Access Features - * {@code - * Config config = new Config(); - * String[] earlyAccess = {"Taxonomy", "Teams", "Terms", "LivePreview"}; - * config.earlyAccess(earlyAccess); - * Stack stack = Contentstack.stack(API_KEY, DELIVERY_TOKEN, ENV, config); - *

- * } - * @return Config - */ - public Config earlyAccess(@NotNull String[] earlyAccessFeatures) { - this.earlyAccess = earlyAccessFeatures; - return this; - } - } diff --git a/src/main/java/com/contentstack/sdk/Contentstack.java b/src/main/java/com/contentstack/sdk/Contentstack.java index 6f40c8e0..e186971f 100644 --- a/src/main/java/com/contentstack/sdk/Contentstack.java +++ b/src/main/java/com/contentstack/sdk/Contentstack.java @@ -69,7 +69,7 @@ public static Stack stack(String stackApiKey, String deliveryToken, String envir * @return the stack * @throws IllegalAccessException the illegal access exception Example *

- * { @Code Stack stack = + * { @Code stack = * contentstack.Stack("apiKey", "deliveryToken", * "environment"); } */ diff --git a/src/test/java/com/contentstack/sdk/TestContentstack.java b/src/test/java/com/contentstack/sdk/TestContentstack.java index 78663d1b..927245c8 100644 --- a/src/test/java/com/contentstack/sdk/TestContentstack.java +++ b/src/test/java/com/contentstack/sdk/TestContentstack.java @@ -111,7 +111,7 @@ void initStackWithConfigs() throws IllegalAccessException { void testConfigEarlyAccessSingleFeature() throws IllegalAccessException { Config config = new Config(); String[] earlyAccess = {"Taxonomy"}; - config.earlyAccess(earlyAccess); + config.setEarlyAccess(earlyAccess); Stack stack = Contentstack.stack(API_KEY, DELIVERY_TOKEN, ENV, config); Assertions.assertEquals(earlyAccess[0], config.earlyAccess[0]); Assertions.assertNotNull(stack.headers.containsKey("x-header-ea")); @@ -123,7 +123,7 @@ void testConfigEarlyAccessSingleFeature() throws IllegalAccessException { void testConfigEarlyAccessMultipleFeature() throws IllegalAccessException { Config config = new Config(); String[] earlyAccess = {"Taxonomy", "Teams", "Terms", "LivePreview"}; - config.earlyAccess(earlyAccess); + config.setEarlyAccess(earlyAccess); Stack stack = Contentstack.stack(API_KEY, DELIVERY_TOKEN, ENV, config); Assertions.assertEquals(4, stack.headers.keySet().size()); Assertions.assertEquals(earlyAccess[1], config.earlyAccess[1]);