forked from crowdin/crowdin-api-client-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTranslationStatusApi.java
More file actions
201 lines (186 loc) · 12.5 KB
/
TranslationStatusApi.java
File metadata and controls
201 lines (186 loc) · 12.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
package com.crowdin.client.translationstatus;
import com.crowdin.client.core.CrowdinApi;
import com.crowdin.client.core.http.HttpRequestConfig;
import com.crowdin.client.core.http.exceptions.HttpBadRequestException;
import com.crowdin.client.core.http.exceptions.HttpException;
import com.crowdin.client.core.model.ClientConfig;
import com.crowdin.client.core.model.Credentials;
import com.crowdin.client.core.model.ResponseList;
import com.crowdin.client.core.model.ResponseObject;
import com.crowdin.client.translationstatus.model.Category;
import com.crowdin.client.translationstatus.model.FileBranchProgress;
import com.crowdin.client.translationstatus.model.FileProgressResponseList;
import com.crowdin.client.translationstatus.model.LanguageProgress;
import com.crowdin.client.translationstatus.model.LanguageProgressResponseList;
import com.crowdin.client.translationstatus.model.QaCheck;
import com.crowdin.client.translationstatus.model.QaCheckResponseList;
import com.crowdin.client.translationstatus.model.QaCheckRevalidation;
import com.crowdin.client.translationstatus.model.QaCheckRevalidationRequest;
import com.crowdin.client.translationstatus.model.QaCheckRevalidationResponseObject;
import com.crowdin.client.translationstatus.model.Validation;
import java.util.Map;
import java.util.Optional;
public class TranslationStatusApi extends CrowdinApi {
public TranslationStatusApi(Credentials credentials) {
super(credentials);
}
public TranslationStatusApi(Credentials credentials, ClientConfig clientConfig) {
super(credentials, clientConfig);
}
/**
* @param projectId project identifier
* @param branchId branch identifier
* @param limit maximum number of items to retrieve (default 25)
* @param offset starting offset in the collection (default 0)
* @return list of branch progress
* @see <ul>
* <li><a href="https://developer.crowdin.com/api/v2/#operation/api.projects.branches.languages.progress.getMany" target="_blank"><b>API Documentation</b></a></li>
* <li><a href="https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.branches.languages.progress.getMany" target="_blank"><b>Enterprise API Documentation</b></a></li>
* </ul>
*/
public ResponseList<LanguageProgress> getBranchProgress(Long projectId, Long branchId, Integer limit, Integer offset) throws HttpException, HttpBadRequestException {
Map<String, Optional<Integer>> queryParams = HttpRequestConfig.buildUrlParams(
"limit", Optional.ofNullable(limit),
"offset", Optional.ofNullable(offset)
);
LanguageProgressResponseList languageProgressResponseList = this.httpClient.get(this.url + "/projects/" + projectId + "/branches/" + branchId + "/languages/progress", new HttpRequestConfig(queryParams), LanguageProgressResponseList.class);
return LanguageProgressResponseList.to(languageProgressResponseList);
}
/**
* @param projectId project identifier
* @param directoryId directory identifier
* @param limit maximum number of items to retrieve (default 25)
* @param offset starting offset in the collection (default 0)
* @return list of directory progress
* @see <ul>
* <li><a href="https://developer.crowdin.com/api/v2/#operation/api.projects.directories.languages.progress.getMany" target="_blank"><b>API Documentation</b></a></li>
* <li><a href="https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.directories.languages.progress.getMany" target="_blank"><b>Enterprise API Documentation</b></a></li>
* </ul>
*/
public ResponseList<LanguageProgress> getDirectoryProgress(Long projectId, Long directoryId, Integer limit, Integer offset) throws HttpException, HttpBadRequestException {
Map<String, Optional<Integer>> queryParams = HttpRequestConfig.buildUrlParams(
"limit", Optional.ofNullable(limit),
"offset", Optional.ofNullable(offset)
);
LanguageProgressResponseList languageProgressResponseList = this.httpClient.get(this.url + "/projects/" + projectId + "/directories/" + directoryId + "/languages/progress", new HttpRequestConfig(queryParams), LanguageProgressResponseList.class);
return LanguageProgressResponseList.to(languageProgressResponseList);
}
/**
* @param projectId project identifier
* @param fileId file identifier
* @param limit maximum number of items to retrieve (default 25)
* @param offset starting offset in the collection (default 0)
* @return list of file progress
* @see <ul>
* <li><a href="https://developer.crowdin.com/api/v2/#operation/api.projects.files.languages.progress.getMany" target="_blank"><b>API Documentation</b></a></li>
* <li><a href="https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.files.languages.progress.getMany" target="_blank"><b>Enterprise API Documentation</b></a></li>
* </ul>
*/
public ResponseList<LanguageProgress> getFileProgress(Long projectId, Long fileId, Integer limit, Integer offset) throws HttpException, HttpBadRequestException {
Map<String, Optional<Integer>> queryParams = HttpRequestConfig.buildUrlParams(
"limit", Optional.ofNullable(limit),
"offset", Optional.ofNullable(offset)
);
LanguageProgressResponseList languageProgressResponseList = this.httpClient.get(this.url + "/projects/" + projectId + "/files/" + fileId + "/languages/progress", new HttpRequestConfig(queryParams), LanguageProgressResponseList.class);
return LanguageProgressResponseList.to(languageProgressResponseList);
}
/**
* @param projectId project identifier
* @param languageId language identifier
* @param limit maximum number of items to retrieve (default 25)
* @param offset starting offset in the collection (default 0)
* @return list of language progress
* @see <ul>
* <li><a href="https://developer.crowdin.com/api/v2/#operation/api.projects.languages.files.progress.getMany" target="_blank"><b>API Documentation</b></a></li>
* <li><a href="https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.languages.files.progress.getMany" target="_blank"><b>Enterprise API Documentation</b></a></li>
* </ul>
*/
public ResponseList<FileBranchProgress> getLanguageProgress(Long projectId, String languageId, Integer limit, Integer offset) throws HttpException, HttpBadRequestException {
Map<String, Optional<Integer>> queryParams = HttpRequestConfig.buildUrlParams(
"limit", Optional.ofNullable(limit),
"offset", Optional.ofNullable(offset)
);
FileProgressResponseList fileProgressResponseList = this.httpClient.get(this.url + "/projects/" + projectId + "/languages/" + languageId + "/progress", new HttpRequestConfig(queryParams), FileProgressResponseList.class);
return FileProgressResponseList.to(fileProgressResponseList);
}
/**
* @param projectId project identifier
* @param limit maximum number of items to retrieve (default 25)
* @param offset starting offset in the collection (default 0)
* @param languageIds language identifiers
* @return list of project progress
* @see <ul>
* <li><a href="https://developer.crowdin.com/api/v2/#operation/api.projects.languages.progress.getMany" target="_blank"><b>API Documentation</b></a></li>
* <li><a href="https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.languages.progress.getMany" target="_blank"><b>Enterprise API Documentation</b></a></li>
* </ul>
*/
public ResponseList<LanguageProgress> getProjectProgress(Long projectId, Integer limit, Integer offset, String languageIds) throws HttpException, HttpBadRequestException {
Map<String, Optional<Object>> queryParams = HttpRequestConfig.buildUrlParams(
"limit", Optional.ofNullable(limit),
"offset", Optional.ofNullable(offset),
"languageIds", Optional.ofNullable(languageIds)
);
LanguageProgressResponseList languageProgressResponseList = this.httpClient.get(this.url + "/projects/" + projectId + "/languages/progress", new HttpRequestConfig(queryParams), LanguageProgressResponseList.class);
return LanguageProgressResponseList.to(languageProgressResponseList);
}
/**
* @param projectId project identifier
* @param limit maximum number of items to retrieve (default 25)
* @param offset starting offset in the collection (default 0)
* @param category category
* @param validation validation
* @return list of qa check issues
* @see <ul>
* <li><a href="https://developer.crowdin.com/api/v2/#operation/api.projects.qa-checks.getMany" target="_blank"><b>API Documentation</b></a></li>
* <li><a href="https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.qa-checks.getMany" target="_blank"><b>Enterprise API Documentation</b></a></li>
* </ul>
*/
public ResponseList<QaCheck> listQaCheckIssues(Long projectId, Integer limit, Integer offset, Category category, Validation validation) throws HttpException, HttpBadRequestException {
Map<String, Optional<Object>> queryParams = HttpRequestConfig.buildUrlParams(
"limit", Optional.ofNullable(limit),
"offset", Optional.ofNullable(offset),
"category", Optional.ofNullable(category),
"validation", Optional.ofNullable(validation)
);
String builtUrl = String.format("%s/projects/%d/qa-checks", this.url, projectId);
QaCheckResponseList qaCheckResponseList = this.httpClient.get(builtUrl, new HttpRequestConfig(queryParams), QaCheckResponseList.class);
return QaCheckResponseList.to(qaCheckResponseList);
}
/**
* @param projectId project identifier
* @param revalidationId qa checks revalidation identifier
* @return status of qa checks revalidation job
* @see <ul>
* <li><a href="https://support.crowdin.com/developer/api/v2/#operation/api.projects.qa-checks.revalidate.get" target="_blank"><b>API Documentation</b></a></li>
* <li><a href="https://support.crowdin.com/developer/enterprise/api/v2/#operation/api.projects.qa-checks.revalidate.get" target="_blank"><b>Enterprise API Documentation</b></a></li>
* </ul>
*/
public ResponseObject<QaCheckRevalidation> getQaChecksRevalidationStatus(Long projectId, String revalidationId) throws HttpException, HttpBadRequestException {
QaCheckRevalidationResponseObject qaCheckRevalidationResponseObject = this.httpClient.get(this.url + "/projects/" + projectId + "/qa-checks/revalidate/" + revalidationId, new HttpRequestConfig(), QaCheckRevalidationResponseObject.class);
return ResponseObject.of(qaCheckRevalidationResponseObject.getData());
}
/**
* @param projectId project identifier
* @param request QaCheckRevalidationRequest
* @return QaCheckRevalidation
* @see <ul>
* <li><a href="https://support.crowdin.com/developer/api/v2/#operation/api.projects.qa-checks.revalidate.post" target="_blank"><b>API Documentation</b></a></li>
* <li><a href="https://support.crowdin.com/developer/enterprise/api/v2/#operation/api.projects.qa-checks.revalidate.post" target="_blank"><b>Enterprise API Documentation</b></a></li>
* </ul>
*/
public ResponseObject<QaCheckRevalidation> revalidateQaChecks(Long projectId, QaCheckRevalidationRequest request) throws HttpException, HttpBadRequestException {
QaCheckRevalidationResponseObject qaCheckRevalidationResponseObject = this.httpClient.post(this.url + "/projects/" + projectId + "/qa-checks/revalidate", request, new HttpRequestConfig(), QaCheckRevalidationResponseObject.class);
return ResponseObject.of(qaCheckRevalidationResponseObject.getData());
}
/**
* @param projectId project identifier
* @param revalidationId qa checks revalidation identifier
* @see <ul>
* <li><a href="https://support.crowdin.com/developer/api/v2/#operation/api.projects.qa-checks.revalidate.delete" target="_blank"><b>API Documentation</b></a></li>
* <li><a href="https://support.crowdin.com/developer/enterprise/api/v2/#operation/api.projects.qa-checks.revalidate.delete" target="_blank"><b>Enterprise API Documentation</b></a></li>
* </ul>
*/
public void cancelQaChecksRevalidation(Long projectId, String revalidationId) throws HttpException, HttpBadRequestException {
this.httpClient.delete(this.url + "/projects/" + projectId + "/qa-checks/revalidate/" + revalidationId, new HttpRequestConfig(), Void.class);
}
}