Skip to content

Commit b201312

Browse files
committed
string translations updates
1 parent a35b7ed commit b201312

10 files changed

+191
-63
lines changed

src/main/java/com/crowdin/client/bundles/BundlesApi.java

+10-8
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,7 @@
1010
import com.crowdin.client.core.http.HttpRequestConfig;
1111
import com.crowdin.client.core.http.exceptions.HttpBadRequestException;
1212
import com.crowdin.client.core.http.exceptions.HttpException;
13-
import com.crowdin.client.core.model.ClientConfig;
14-
import com.crowdin.client.core.model.Credentials;
15-
import com.crowdin.client.core.model.DownloadLink;
16-
import com.crowdin.client.core.model.DownloadLinkResponseObject;
17-
import com.crowdin.client.core.model.PatchRequest;
18-
import com.crowdin.client.core.model.ResponseList;
19-
import com.crowdin.client.core.model.ResponseObject;
13+
import com.crowdin.client.core.model.*;
2014
import com.crowdin.client.sourcefiles.model.Branch;
2115
import com.crowdin.client.sourcefiles.model.BranchResponseList;
2216
import com.crowdin.client.sourcefiles.model.FileInfo;
@@ -46,7 +40,15 @@ public BundlesApi(Credentials credentials, ClientConfig clientConfig) {
4640
* </ul>
4741
*/
4842
public ResponseList<Bundle> listBundles(Long projectId) throws HttpException, HttpBadRequestException {
49-
BundleResponseList response = this.httpClient.get(this.url + "/projects/" + projectId + "/bundles", new HttpRequestConfig(), BundleResponseList.class);
43+
return listBundles(projectId, new Pagination());
44+
}
45+
46+
public ResponseList<Bundle> listBundles(Long projectId, Pagination options) throws HttpException, HttpBadRequestException {
47+
Map<String, Optional<Object>> queryParams = HttpRequestConfig.buildUrlParams(
48+
"limit", Optional.ofNullable(options.getLimit()),
49+
"offset", Optional.ofNullable(options.getOffset())
50+
);
51+
BundleResponseList response = this.httpClient.get(this.url + "/projects/" + projectId + "/bundles", new HttpRequestConfig(queryParams), BundleResponseList.class);
5052
return BundleResponseList.to(response);
5153
}
5254

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

+7
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@ public static BooleanInt from(String value) {
1313
return value.equals("1") ? BooleanInt.TRUE : BooleanInt.FALSE;
1414
}
1515

16+
public static BooleanInt fromInt(Integer value) {
17+
if (value == null) {
18+
return null;
19+
}
20+
return value == 1 ? BooleanInt.TRUE : BooleanInt.FALSE;
21+
}
22+
1623
@Override
1724
public Integer to(BooleanInt v) {
1825
return v.val;

src/main/java/com/crowdin/client/fields/FieldsApi.java

+6-8
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,12 @@ public FieldsApi(Credentials credentials, ClientConfig clientConfig) {
3636
* </ul>
3737
*/
3838
public ResponseList<Field> listFields(String entity, String search, Integer limit, Integer offset) throws HttpException, HttpBadRequestException {
39-
Map<String, Optional<Object>> queryParams = HttpRequestConfig.buildUrlParams(
40-
"entity", Optional.ofNullable(entity),
41-
"search", Optional.ofNullable(search),
42-
"limit", Optional.ofNullable(limit),
43-
"offset", Optional.ofNullable(offset)
44-
);
45-
FieldResponseObjectList responseObject = this.httpClient.get(this.url + "/fields", new HttpRequestConfig(queryParams), FieldResponseObjectList.class);
46-
return FieldResponseObjectList.to(responseObject);
39+
ListFieldsParams params = new ListFieldsParams();
40+
params.setEntity(entity);
41+
params.setSearch(search);
42+
params.setLimit(limit);
43+
params.setOffset(offset);
44+
return listFields(params);
4745
}
4846

4947
public ResponseList<Field> listFields(ListFieldsParams params) throws HttpException, HttpBadRequestException {

src/main/java/com/crowdin/client/projectsgroups/ProjectsGroupsApi.java

+11-15
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,11 @@ public ProjectsGroupsApi(Credentials credentials, ClientConfig clientConfig) {
3737
* </ul>
3838
*/
3939
public ResponseList<Group> listGroups(Long parentId, Integer limit, Integer offset) throws HttpException, HttpBadRequestException {
40-
Map<String, Optional<Object>> queryParams = HttpRequestConfig.buildUrlParams(
41-
"parentId", Optional.ofNullable(parentId),
42-
"limit", Optional.ofNullable(limit),
43-
"offset", Optional.ofNullable(offset)
44-
);
45-
GroupResponseList groupResponseList = this.httpClient.get(this.url + "/groups", new HttpRequestConfig(queryParams), GroupResponseList.class);
46-
return GroupResponseList.to(groupResponseList);
40+
ListGroupOptions options = new ListGroupOptions();
41+
options.setParentId(parentId);
42+
options.setLimit(limit);
43+
options.setOffset(offset);
44+
return listGroups(options);
4745
}
4846

4947
public ResponseList<Group> listGroups(ListGroupOptions options) throws HttpException, HttpBadRequestException {
@@ -117,14 +115,12 @@ public ResponseObject<Group> editGroup(Long groupId, List<PatchRequest> request)
117115
* </ul>
118116
*/
119117
public ResponseList<? extends Project> listProjects(Long groupId, Integer hasManagerAccess, Integer limit, Integer offset) throws HttpException, HttpBadRequestException {
120-
Map<String, Optional<Object>> queryParams = HttpRequestConfig.buildUrlParams(
121-
"groupId", Optional.ofNullable(groupId),
122-
"hasManagerAccess", Optional.ofNullable(hasManagerAccess),
123-
"limit", Optional.ofNullable(limit),
124-
"offset", Optional.ofNullable(offset)
125-
);
126-
ProjectResponseList projectResponseList = this.httpClient.get(this.url + "/projects", new HttpRequestConfig(queryParams), ProjectResponseList.class);
127-
return ProjectResponseList.to(projectResponseList);
118+
ListProjectOptions options = new ListProjectOptions();
119+
options.setGroupId(groupId);
120+
options.setHasManagerAccess(hasManagerAccess);
121+
options.setLimit(limit);
122+
options.setOffset(offset);
123+
return listProjects(options);
128124
}
129125

130126
public ResponseList<? extends Project> listProjects(ListProjectOptions options) throws HttpException, HttpBadRequestException {

src/main/java/com/crowdin/client/stringtranslations/StringTranslationsApi.java

+83-32
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,7 @@
44
import com.crowdin.client.core.http.HttpRequestConfig;
55
import com.crowdin.client.core.http.exceptions.HttpBadRequestException;
66
import com.crowdin.client.core.http.exceptions.HttpException;
7-
import com.crowdin.client.core.model.ClientConfig;
8-
import com.crowdin.client.core.model.Credentials;
9-
import com.crowdin.client.core.model.ResponseList;
10-
import com.crowdin.client.core.model.ResponseObject;
7+
import com.crowdin.client.core.model.*;
118
import com.crowdin.client.stringtranslations.model.*;
129

1310
import java.util.Map;
@@ -53,15 +50,29 @@ public AlignTranslationResponse alignTranslation(Long projectId, AlignTranslatio
5350
* </ul>
5451
*/
5552
public ResponseList<Approval> listTranslationApprovals(Long projectId, Long fileId, Long stringId, String languageId, Long translationId, String labelIds, String excludeLabelIds, Integer limit, Integer offset) throws HttpException, HttpBadRequestException {
53+
ListTranslationApprovalsOptions options = new ListTranslationApprovalsOptions();
54+
options.setFileId(fileId);
55+
options.setStringId(stringId);
56+
options.setLanguageId(languageId);
57+
options.setTranslationId(translationId);
58+
options.setLabelIds(labelIds);
59+
options.setExcludeLabelIds(excludeLabelIds);
60+
options.setLimit(limit);
61+
options.setOffset(offset);
62+
return listTranslationApprovals(projectId, options);
63+
}
64+
65+
public ResponseList<Approval> listTranslationApprovals(Long projectId, ListTranslationApprovalsOptions options) throws HttpException, HttpBadRequestException {
5666
Map<String, Optional<Object>> queryParams = HttpRequestConfig.buildUrlParams(
57-
"fileId", Optional.ofNullable(fileId),
58-
"stringId", Optional.ofNullable(stringId),
59-
"languageId", Optional.ofNullable(languageId),
60-
"translationId", Optional.ofNullable(translationId),
61-
"labelIds", Optional.ofNullable(labelIds),
62-
"excludeLabelIds", Optional.ofNullable(excludeLabelIds),
63-
"limit", Optional.ofNullable(limit),
64-
"offset", Optional.ofNullable(offset)
67+
"orderBy", Optional.ofNullable(options.getOrderBy()),
68+
"fileId", Optional.ofNullable(options.getFileId()),
69+
"labelIds", Optional.ofNullable(options.getLabelIds()),
70+
"excludeLabelIds", Optional.ofNullable(options.getExcludeLabelIds()),
71+
"stringId", Optional.ofNullable(options.getStringId()),
72+
"languageId", Optional.ofNullable(options.getLanguageId()),
73+
"translationId", Optional.ofNullable(options.getTranslationId()),
74+
"limit", Optional.ofNullable(options.getLimit()),
75+
"offset", Optional.ofNullable(options.getOffset())
6576
);
6677
ApprovalResponseList approvalResponseList = this.httpClient.get(this.url + "/projects/" + projectId + "/approvals", new HttpRequestConfig(queryParams), ApprovalResponseList.class);
6778
return ApprovalResponseList.to(approvalResponseList);
@@ -126,17 +137,33 @@ public void removeApproval(Long projectId, Long approvalId) throws HttpException
126137
* </ul>
127138
*/
128139
public ResponseList<LanguageTranslations> listLanguageTranslations(Long projectId, String languageId, String stringIds, String labelIds, Long fileId, Long branchId, Long directoryId, String croql, Integer denormalizePlaceholders, Integer limit, Integer offset) throws HttpException, HttpBadRequestException {
140+
ListLanguageTranslationsOptions options = new ListLanguageTranslationsOptions();
141+
options.setStringIds(stringIds);
142+
options.setLabelIds(labelIds);
143+
options.setFileId(fileId);
144+
options.setBranchId(branchId);
145+
options.setDirectoryId(directoryId);
146+
options.setCroql(croql);
147+
options.setDenormalizePlaceholders(BooleanInt.fromInt(denormalizePlaceholders));
148+
options.setLimit(limit);
149+
options.setOffset(offset);
150+
return listLanguageTranslations(projectId, languageId, options);
151+
}
152+
153+
public ResponseList<LanguageTranslations> listLanguageTranslations(Long projectId, String languageId, ListLanguageTranslationsOptions options) throws HttpException, HttpBadRequestException {
129154
String builtUrl = String.format("%s/projects/%d/languages/%s/translations", this.url, projectId, languageId);
130155
Map<String, Optional<Object>> queryParams = HttpRequestConfig.buildUrlParams(
131-
"stringIds", Optional.ofNullable(stringIds),
132-
"labelIds", Optional.ofNullable(labelIds),
133-
"fileId", Optional.ofNullable(fileId),
134-
"branchId", Optional.ofNullable(branchId),
135-
"directoryId", Optional.ofNullable(directoryId),
136-
"croql", Optional.ofNullable(croql),
137-
"denormalizePlaceholders", Optional.ofNullable(denormalizePlaceholders),
138-
"limit", Optional.ofNullable(limit),
139-
"offset", Optional.ofNullable(offset)
156+
"stringIds", Optional.ofNullable(options.getStringIds()),
157+
"labelIds", Optional.ofNullable(options.getLabelIds()),
158+
"fileId", Optional.ofNullable(options.getFileId()),
159+
"branchId", Optional.ofNullable(options.getBranchId()),
160+
"directoryId", Optional.ofNullable(options.getDirectoryId()),
161+
"passedWorkflow", Optional.ofNullable(options.getPassedWorkflow()),
162+
"minApprovalCount", Optional.ofNullable(options.getMinApprovalCount()),
163+
"croql", Optional.ofNullable(options.getCroql()),
164+
"denormalizePlaceholders", Optional.ofNullable(options.getDenormalizePlaceholders()),
165+
"limit", Optional.ofNullable(options.getLimit()),
166+
"offset", Optional.ofNullable(options.getOffset())
140167
);
141168
LanguageTranslationsResponseList languageTranslationsResponseList = this.httpClient.get(builtUrl, new HttpRequestConfig(queryParams), LanguageTranslationsResponseList.class);
142169
return LanguageTranslationsResponseList.to(languageTranslationsResponseList);
@@ -155,11 +182,22 @@ public ResponseList<LanguageTranslations> listLanguageTranslations(Long projectI
155182
* </ul>
156183
*/
157184
public ResponseList<StringTranslation> listStringTranslations(Long projectId, Long stringId, String languageId, Integer limit, Integer offset) throws HttpException, HttpBadRequestException {
185+
ListStringTranslationsOptions options = new ListStringTranslationsOptions();
186+
options.setStringId(stringId);
187+
options.setLanguageId(languageId);
188+
options.setLimit(limit);
189+
options.setOffset(offset);
190+
return listStringTranslations(projectId, options);
191+
}
192+
193+
public ResponseList<StringTranslation> listStringTranslations(Long projectId, ListStringTranslationsOptions options) throws HttpException, HttpBadRequestException {
158194
Map<String, Optional<Object>> queryParams = HttpRequestConfig.buildUrlParams(
159-
"stringId", Optional.ofNullable(stringId),
160-
"languageId", Optional.ofNullable(languageId),
161-
"limit", Optional.ofNullable(limit),
162-
"offset", Optional.ofNullable(offset)
195+
"stringId", Optional.ofNullable(options.getStringId()),
196+
"languageId", Optional.ofNullable(options.getLanguageId()),
197+
"orderBy", Optional.ofNullable(options.getOrderBy()),
198+
"denormalizePlaceholders", Optional.ofNullable(options.getDenormalizePlaceholders()),
199+
"limit", Optional.ofNullable(options.getLimit()),
200+
"offset", Optional.ofNullable(options.getOffset())
163201
);
164202
StringTranslationResponseList stringTranslationResponseList = this.httpClient.get(this.url + "/projects/" + projectId + "/translations", new HttpRequestConfig(queryParams), StringTranslationResponseList.class);
165203
return StringTranslationResponseList.to(stringTranslationResponseList);
@@ -252,14 +290,27 @@ public ResponseObject<StringTranslation> restoreStringTranslation(Long projectId
252290
* </ul>
253291
*/
254292
public ResponseList<Vote> listTranslationVotes(Long projectId, Long stringId, String languageId, Long translationId, String labelIds, String excludeLabelIds, Integer limit, Integer offset) throws HttpException, HttpBadRequestException {
293+
ListTranslationVotesOptions options = new ListTranslationVotesOptions();
294+
options.setStringId(stringId);
295+
options.setLanguageId(languageId);
296+
options.setTranslationId(translationId);
297+
options.setLabelIds(labelIds);
298+
options.setExcludeLabelIds(excludeLabelIds);
299+
options.setLimit(limit);
300+
options.setOffset(offset);
301+
return listTranslationVotes(projectId, options);
302+
}
303+
304+
public ResponseList<Vote> listTranslationVotes(Long projectId, ListTranslationVotesOptions options) throws HttpException, HttpBadRequestException {
255305
Map<String, Optional<Object>> queryParams = HttpRequestConfig.buildUrlParams(
256-
"stringId", Optional.ofNullable(stringId),
257-
"languageId", Optional.ofNullable(languageId),
258-
"translationId", Optional.ofNullable(translationId),
259-
"labelIds", Optional.ofNullable(labelIds),
260-
"excludeLabelIds", Optional.ofNullable(excludeLabelIds),
261-
"limit", Optional.ofNullable(limit),
262-
"offset", Optional.ofNullable(offset)
306+
"stringId", Optional.ofNullable(options.getStringId()),
307+
"languageId", Optional.ofNullable(options.getLanguageId()),
308+
"translationId", Optional.ofNullable(options.getTranslationId()),
309+
"fileId", Optional.ofNullable(options.getFileId()),
310+
"labelIds", Optional.ofNullable(options.getLabelIds()),
311+
"excludeLabelIds", Optional.ofNullable(options.getExcludeLabelIds()),
312+
"limit", Optional.ofNullable(options.getLimit()),
313+
"offset", Optional.ofNullable(options.getOffset())
263314
);
264315
VoteResponseList voteResponseList = this.httpClient.get(this.url + "/projects/" + projectId + "/votes", new HttpRequestConfig(queryParams), VoteResponseList.class);
265316
return VoteResponseList.to(voteResponseList);

src/main/java/com/crowdin/client/stringtranslations/model/AddStringTranslationRequest.java

+1
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ public class AddStringTranslationRequest {
99
private String languageId;
1010
private String text;
1111
private PluralCategoryName pluralCategoryName;
12+
private Boolean addToTm;
1213
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package com.crowdin.client.stringtranslations.model;
2+
3+
import com.crowdin.client.core.model.BooleanInt;
4+
import com.crowdin.client.core.model.Pagination;
5+
import lombok.Data;
6+
import lombok.EqualsAndHashCode;
7+
8+
@EqualsAndHashCode(callSuper = true)
9+
@Data
10+
public class ListLanguageTranslationsOptions extends Pagination {
11+
12+
private String stringIds;
13+
private String labelIds;
14+
private Long fileId;
15+
private Long branchId;
16+
private Long directoryId;
17+
private BooleanInt passedWorkflow;
18+
private Integer minApprovalCount;
19+
private String croql;
20+
private BooleanInt denormalizePlaceholders;
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.crowdin.client.stringtranslations.model;
2+
3+
import com.crowdin.client.core.model.BooleanInt;
4+
import com.crowdin.client.core.model.Pagination;
5+
import lombok.Data;
6+
import lombok.EqualsAndHashCode;
7+
8+
@EqualsAndHashCode(callSuper = true)
9+
@Data
10+
public class ListStringTranslationsOptions extends Pagination {
11+
12+
private Long stringId;
13+
private String languageId;
14+
private String orderBy;
15+
private BooleanInt denormalizePlaceholders;
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package com.crowdin.client.stringtranslations.model;
2+
3+
import com.crowdin.client.core.model.Pagination;
4+
import lombok.Data;
5+
import lombok.EqualsAndHashCode;
6+
7+
@EqualsAndHashCode(callSuper = true)
8+
@Data
9+
public class ListTranslationApprovalsOptions extends Pagination {
10+
11+
private String orderBy;
12+
private Long fileId;
13+
private String labelIds;
14+
private String excludeLabelIds;
15+
private Long stringId;
16+
private String languageId;
17+
private Long translationId;
18+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package com.crowdin.client.stringtranslations.model;
2+
3+
import com.crowdin.client.core.model.BooleanInt;
4+
import com.crowdin.client.core.model.Pagination;
5+
import lombok.Data;
6+
import lombok.EqualsAndHashCode;
7+
8+
@EqualsAndHashCode(callSuper = true)
9+
@Data
10+
public class ListTranslationVotesOptions extends Pagination {
11+
12+
private Long stringId;
13+
private String languageId;
14+
private Long translationId;
15+
private Long fileId;
16+
private String labelIds;
17+
private String excludeLabelIds;
18+
}

0 commit comments

Comments
 (0)