Skip to content

Commit

Permalink
clients can be retrieved with custom API url now
Browse files Browse the repository at this point in the history
  • Loading branch information
ibalosh committed Feb 25, 2021
1 parent ff2612f commit 7219a9e
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ target
out
src/test/java/temp
src/test/resources/*properties*
.gradle

2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
</developers>

<properties>
<postmark.version>1.5.5</postmark.version>
<postmark.version>1.5.6</postmark.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
<jackson.minimum.version>2.9.7</jackson.minimum.version>
Expand Down
14 changes: 14 additions & 0 deletions src/main/java/com/wildbit/java/postmark/Postmark.java
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand All @@ -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() {}
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/integration/MessageStreamsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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"));

Expand Down

0 comments on commit 7219a9e

Please sign in to comment.