From 7219a9eac613e22ba9791a220f3103636edad205 Mon Sep 17 00:00:00 2001 From: Igor Balos Date: Thu, 25 Feb 2021 10:20:41 +0100 Subject: [PATCH] clients can be retrieved with custom API url now --- .gitignore | 1 + pom.xml | 2 +- .../java/com/wildbit/java/postmark/Postmark.java | 14 ++++++++++++++ src/test/java/integration/MessageStreamsTest.java | 2 +- 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index e22388f..84fa8eb 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,5 @@ target out src/test/java/temp src/test/resources/*properties* +.gradle diff --git a/pom.xml b/pom.xml index 1f591fd..13a3cb9 100644 --- a/pom.xml +++ b/pom.xml @@ -24,7 +24,7 @@ - 1.5.5 + 1.5.6 UTF-8 1.8 2.9.7 diff --git a/src/main/java/com/wildbit/java/postmark/Postmark.java b/src/main/java/com/wildbit/java/postmark/Postmark.java index 7be6408..f3e899b 100644 --- a/src/main/java/com/wildbit/java/postmark/Postmark.java +++ b/src/main/java/com/wildbit/java/postmark/Postmark.java @@ -66,6 +66,13 @@ public static ApiClient getApiClient(String apiToken, Boolean secureConnection) return new ApiClient(DEFAULTS.API_URL.value, getHeadersWithAuth(DEFAULTS.SERVER_AUTH_HEADER, apiToken), secureConnection); } + /** + * In rare cases, other than default API url might need to be used, mainly for testing purposes. + */ + public static ApiClient getApiClient(String apiToken, Boolean secureConnection, String customApiUrl) { + return new ApiClient(customApiUrl, getHeadersWithAuth(DEFAULTS.SERVER_AUTH_HEADER, apiToken), secureConnection); + } + public static AccountApiClient getAccountApiClient(String apiToken) { return new AccountApiClient(DEFAULTS.API_URL.value, getHeadersWithAuth(DEFAULTS.ACOUNT_AUTH_HEADER, apiToken)); } @@ -74,6 +81,13 @@ public static AccountApiClient getAccountApiClient(String apiToken, Boolean secu return new AccountApiClient(DEFAULTS.API_URL.value, getHeadersWithAuth(DEFAULTS.ACOUNT_AUTH_HEADER, apiToken), secureConnection); } + /** + * In rare cases, other than default API url might need to be used, mainly for testing purposes. + */ + public static AccountApiClient getAccountApiClient(String apiToken, Boolean secureConnection, String customApiUrl) { + return new AccountApiClient(customApiUrl, getHeadersWithAuth(DEFAULTS.ACOUNT_AUTH_HEADER, apiToken), secureConnection); + } + // private methods private Postmark() {} diff --git a/src/test/java/integration/MessageStreamsTest.java b/src/test/java/integration/MessageStreamsTest.java index 1208b20..f548d64 100644 --- a/src/test/java/integration/MessageStreamsTest.java +++ b/src/test/java/integration/MessageStreamsTest.java @@ -63,7 +63,7 @@ void edit() throws PostmarkException, IOException { @Test void archive() throws PostmarkException, IOException { - String streamId = "bulk"; + String streamId = "bulk1"; MessageStreams messages = client.getMessageStreams(Parameters.init().build("messageStreamType", "all") .build("includeArchivedStreams", "true"));