Skip to content

Commit c39acf5

Browse files
committed
added possibility to pass custom base url
1 parent 078a4d8 commit c39acf5

2 files changed

Lines changed: 15 additions & 3 deletions

File tree

src/main/java/com/crowdin/client/core/CrowdinApi.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,18 @@ public CrowdinApi(Credentials credentials, ClientConfig clientConfig) {
3434
this.httpClient = clientConfig.getHttpClient();
3535
}
3636
this.clientConfig = clientConfig;
37-
if (credentials.getOrganization() != null) {
38-
this.url = "https://" + credentials.getOrganization() + ".api.crowdin.com/api/v2";
37+
if (clientConfig.getBaseUrl() != null) {
38+
if (clientConfig.getBaseUrl().endsWith("/")) {
39+
this.url = clientConfig.getBaseUrl() + "api/v2";
40+
} else {
41+
this.url = clientConfig.getBaseUrl() + "/api/v2";
42+
}
3943
} else {
40-
this.url = "https://api.crowdin.com/api/v2";
44+
if (credentials.getOrganization() != null) {
45+
this.url = "https://" + credentials.getOrganization() + ".api.crowdin.com/api/v2";
46+
} else {
47+
this.url = "https://api.crowdin.com/api/v2";
48+
}
4149
}
4250
}
4351
}

src/main/java/com/crowdin/client/core/model/ClientConfig.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,8 @@ public class ClientConfig {
2828
* Provide custom json transformer
2929
*/
3030
private JsonTransformer jsonTransformer;
31+
/**
32+
* Base url of the server
33+
*/
34+
private String baseUrl;
3135
}

0 commit comments

Comments
 (0)