Skip to content

Commit 3d48d3f

Browse files
authored
Merge pull request #30 from crowdin/feat/base_url
Base url option
2 parents 078a4d8 + 7534d6c commit 3d48d3f

2 files changed

Lines changed: 36 additions & 8 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 (credentials.getBaseUrl() != null) {
38+
if (credentials.getBaseUrl().endsWith("/")) {
39+
this.url = credentials.getBaseUrl() + "api/v2";
40+
} else {
41+
this.url = credentials.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
}
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)