From 8ed383768fba9f40d6adf7ae69dde517b64cbbd1 Mon Sep 17 00:00:00 2001 From: Sebastian Stehle Date: Sun, 1 Sep 2024 18:53:03 +0200 Subject: [PATCH] Rename BaseURL parameter. --- .../java/com/squidex/api/AuthInterceptor.java | 9 ++++----- src/main/java/com/squidex/api/SquidexClient.java | 8 ++++---- .../com/squidex/api/SquidexClientBuilder.java | 16 ++++++++++------ src/test/java/com/squidex/api/TestSetup.java | 2 +- src/test/java/com/squidex/api/Utils.java | 2 +- 5 files changed, 20 insertions(+), 17 deletions(-) diff --git a/src/main/java/com/squidex/api/AuthInterceptor.java b/src/main/java/com/squidex/api/AuthInterceptor.java index 620aa0e..a89c4df 100644 --- a/src/main/java/com/squidex/api/AuthInterceptor.java +++ b/src/main/java/com/squidex/api/AuthInterceptor.java @@ -5,7 +5,6 @@ import org.jetbrains.annotations.NotNull; import java.io.IOException; -import java.time.Instant; import java.util.Objects; import okhttp3.FormBody; @@ -18,15 +17,15 @@ public final class AuthInterceptor implements Interceptor { private final Gson gson = new Gson(); - private final String baseUrl; + private final String url; private final String clientId; private final String clientSecret; private final TokenStore tokenStore; private final OkHttpClient httpClient; - public AuthInterceptor(OkHttpClient httpClient, String baseUrl, String clientId, String clientSecret, TokenStore tokenStore) { + public AuthInterceptor(OkHttpClient httpClient, String url, String clientId, String clientSecret, TokenStore tokenStore) { this.httpClient = httpClient; - this.baseUrl = baseUrl; + this.url = url; this.clientId = clientId; this.clientSecret = clientSecret; this.tokenStore = tokenStore; @@ -72,7 +71,7 @@ private AccessToken acquireToken() throws IOException { .add("scope", "squidex-api") .build(); - HttpUrl tokenUrl = Objects.requireNonNull(HttpUrl.parse(baseUrl)) + HttpUrl tokenUrl = Objects.requireNonNull(HttpUrl.parse(url)) .newBuilder() .addPathSegments("identity-server/connect/token") .build(); diff --git a/src/main/java/com/squidex/api/SquidexClient.java b/src/main/java/com/squidex/api/SquidexClient.java index 62a3692..f0e0b6d 100644 --- a/src/main/java/com/squidex/api/SquidexClient.java +++ b/src/main/java/com/squidex/api/SquidexClient.java @@ -50,13 +50,13 @@ public class SquidexClient { private final String appName; private final String clientId; private final String clientSecret; - private final String baseUrl; + private final String url; public SquidexClient(ApiClient apiClient, String appName, String clientId, String clientSecret, String baseUrl) { this.appName = appName; this.clientId = clientId; this.clientSecret = clientSecret; - this.baseUrl = baseUrl; + this.url = baseUrl; this.appsApi = memoize(() -> new AppsApi(apiClient)); this.assetsApi = memoize(() -> new AssetsApi(apiClient)); this.backupsApi = memoize(() -> new BackupsApi(apiClient)); @@ -106,8 +106,8 @@ public String getClientSecret() { return clientSecret; } - public String getBaseUrl() { - return baseUrl; + public String getUrl() { + return url; } public UserManagementApi userManagement() { diff --git a/src/main/java/com/squidex/api/SquidexClientBuilder.java b/src/main/java/com/squidex/api/SquidexClientBuilder.java index fea6939..40b770f 100644 --- a/src/main/java/com/squidex/api/SquidexClientBuilder.java +++ b/src/main/java/com/squidex/api/SquidexClientBuilder.java @@ -18,7 +18,7 @@ import okhttp3.Response; public final class SquidexClientBuilder { - private String baseUrl = "https://cloud.squidex.io"; + private String url = "https://cloud.squidex.io"; private String clientId; private String clientSecret; private String appName; @@ -26,11 +26,15 @@ public final class SquidexClientBuilder { private OkHttpClient httpClient; private boolean trustAllCerts; - public SquidexClientBuilder baseUrl(String baseUrl) { - this.baseUrl = baseUrl; + public SquidexClientBuilder url(String url) { + this.url = url; return this; } + public String url() { + return this.url; + } + public SquidexClientBuilder clientId(String clientId) { this.clientId = clientId; return this; @@ -124,7 +128,7 @@ public java.security.cert.X509Certificate[] getAcceptedIssuers() { AuthInterceptor interceptor = new AuthInterceptor( this.httpClient, - this.baseUrl, + this.url, this.clientId, this.clientSecret, this.tokenStore); @@ -148,9 +152,9 @@ public Response intercept(@NotNull Chain chain) throws IOException { .build(); ApiClient apiClient = new ApiClient(this.httpClient); - apiClient.setBasePath(this.baseUrl); + apiClient.setBasePath(this.url); apiClient.setVerifyingSsl(!this.trustAllCerts); - return new SquidexClient(apiClient, this.appName, this.clientId, this.clientSecret, this.baseUrl); + return new SquidexClient(apiClient, this.appName, this.clientId, this.clientSecret, this.url); } } diff --git a/src/test/java/com/squidex/api/TestSetup.java b/src/test/java/com/squidex/api/TestSetup.java index 0654cbd..3fe424c 100644 --- a/src/test/java/com/squidex/api/TestSetup.java +++ b/src/test/java/com/squidex/api/TestSetup.java @@ -18,7 +18,7 @@ public void beforeAll(ExtensionContext context) throws Exception { System.out.printf("Using =<%s>%n", client.getAppName()); System.out.printf("Using =<%s>%n", client.getClientId()); System.out.printf("Using =<%s>%n", client.getClientSecret()); - System.out.printf("Using =<%s>%n", client.getBaseUrl()); + System.out.printf("Using =<%s>%n", client.getUrl()); this.waitForServer(); diff --git a/src/test/java/com/squidex/api/Utils.java b/src/test/java/com/squidex/api/Utils.java index 2947423..76dfacc 100644 --- a/src/test/java/com/squidex/api/Utils.java +++ b/src/test/java/com/squidex/api/Utils.java @@ -37,7 +37,7 @@ public static ClientProvider getClient() { .appName(appName) .clientId(clientId) .clientSecret(clientSecret) - .baseUrl(environment); + .url(environment); singleClient = new ClientProvider(builder, builder.build());