Skip to content

Commit 7534d6c

Browse files
committed
added possibility to pass custom base url
1 parent c39acf5 commit 7534d6c

3 files changed

Lines changed: 29 additions & 13 deletions

File tree

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ public CrowdinApi(Credentials credentials, ClientConfig clientConfig) {
3434
this.httpClient = clientConfig.getHttpClient();
3535
}
3636
this.clientConfig = clientConfig;
37-
if (clientConfig.getBaseUrl() != null) {
38-
if (clientConfig.getBaseUrl().endsWith("/")) {
39-
this.url = clientConfig.getBaseUrl() + "api/v2";
37+
if (credentials.getBaseUrl() != null) {
38+
if (credentials.getBaseUrl().endsWith("/")) {
39+
this.url = credentials.getBaseUrl() + "api/v2";
4040
} else {
41-
this.url = clientConfig.getBaseUrl() + "/api/v2";
41+
this.url = credentials.getBaseUrl() + "/api/v2";
4242
}
4343
} else {
4444
if (credentials.getOrganization() != null) {

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,4 @@ 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;
3531
}
Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,32 @@
11
package com.crowdin.client.core.model;
22

3-
import lombok.Data;
4-
import lombok.NonNull;
5-
6-
@Data
73
public class Credentials {
84

9-
@NonNull
105
private final String token;
116
private final String organization;
7+
private String baseUrl;
8+
9+
public Credentials(String token, String organization) {
10+
this.token = token;
11+
this.organization = organization;
12+
}
13+
14+
public Credentials(String token, String organization, String baseUrl) {
15+
this.token = token;
16+
this.organization = organization;
17+
this.baseUrl = baseUrl;
18+
}
19+
20+
public String getToken() {
21+
return token;
22+
}
23+
24+
public String getOrganization() {
25+
return organization;
26+
}
27+
28+
public String getBaseUrl() {
29+
return baseUrl;
30+
}
31+
1232
}

0 commit comments

Comments
 (0)