|
4 | 4 | import com.crowdin.client.core.http.HttpRequestConfig; |
5 | 5 | import com.crowdin.client.core.http.exceptions.HttpBadRequestException; |
6 | 6 | 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.DownloadLink; |
10 | | -import com.crowdin.client.core.model.DownloadLinkResponseObject; |
11 | | -import com.crowdin.client.core.model.PatchRequest; |
12 | | -import com.crowdin.client.core.model.ResponseList; |
13 | | -import com.crowdin.client.core.model.ResponseObject; |
| 7 | +import com.crowdin.client.core.model.*; |
14 | 8 | import com.crowdin.client.glossaries.model.*; |
15 | 9 |
|
16 | 10 | import java.util.List; |
@@ -59,11 +53,36 @@ public ResponseList<Concept> listConcepts(Long glossaryId, Integer limit, Intege |
59 | 53 | return listConcepts(glossaryId, params); |
60 | 54 | } |
61 | 55 |
|
| 56 | + /** |
| 57 | + * @param glossaryId glossary identifier |
| 58 | + * @param limit maximum number of items to retrieve (default 25) |
| 59 | + * @param offset starting offset in the collection (default 0) |
| 60 | + * @param orderBy list of OrderByFields |
| 61 | + * @return list of concepts |
| 62 | + * @see <ul> |
| 63 | + * <li><a href="https://developer.crowdin.com/api/v2/#operation/api.glossaries.concepts.getMany" target="_blank"><b>API Documentation</b></a></li> |
| 64 | + * <li><a href="https://developer.crowdin.com/enterprise/api/v2/#operation/api.glossaries.concepts.getMany" target="_blank"><b>Enterprise API Documentation</b></a></li> |
| 65 | + * </ul> |
| 66 | + */ |
| 67 | + public ResponseList<Concept> listConcepts(Long glossaryId, Integer limit, Integer offset, List<OrderByField> orderBy) throws HttpException, HttpBadRequestException { |
| 68 | + ListConceptsParams params = new ListConceptsParams(); |
| 69 | + params.setLimit(limit); |
| 70 | + params.setOffset(offset); |
| 71 | + params.setOrderByList(orderBy); |
| 72 | + return listConcepts(glossaryId, params); |
| 73 | + } |
| 74 | + |
62 | 75 | public ResponseList<Concept> listConcepts(Long glossaryId, ListConceptsParams params) throws HttpException, HttpBadRequestException { |
| 76 | + ListConceptsParams query = Optional.ofNullable(params).orElse(new ListConceptsParams()); |
| 77 | + |
| 78 | + String orderBy = query.getOrderByList() != null |
| 79 | + ? OrderByField.generateSortParam(query.getOrderByList()) |
| 80 | + : query.getOrderBy(); |
| 81 | + |
63 | 82 | Map<String, Optional<Object>> queryParams = HttpRequestConfig.buildUrlParams( |
64 | | - "orderBy", Optional.ofNullable(params.getOrderBy()), |
65 | | - "limit", Optional.ofNullable(params.getLimit()), |
66 | | - "offset", Optional.ofNullable(params.getOffset()) |
| 83 | + "orderBy", Optional.ofNullable(orderBy), |
| 84 | + "limit", Optional.ofNullable(query.getLimit()), |
| 85 | + "offset", Optional.ofNullable(query.getOffset()) |
67 | 86 | ); |
68 | 87 | ConceptResponseList conceptResponseList = this.httpClient.get(this.url + "/glossaries/" + glossaryId + "/concepts", new HttpRequestConfig(queryParams), ConceptResponseList.class); |
69 | 88 | return ConceptResponseList.to(conceptResponseList); |
@@ -128,12 +147,39 @@ public ResponseList<Glossary> listGlossaries(Long groupId, Integer limit, Intege |
128 | 147 | return listGlossaries(params); |
129 | 148 | } |
130 | 149 |
|
| 150 | + /** |
| 151 | + * @param groupId group identifier |
| 152 | + * @param limit maximum number of items to retrieve (default 25) |
| 153 | + * @param offset starting offset in the collection (default 0) |
| 154 | + * @param orderBy list of OrderByField |
| 155 | + * @return list of glossaries |
| 156 | + * @see <ul> |
| 157 | + * <li><a href="https://developer.crowdin.com/api/v2/#operation/api.glossaries.getMany" target="_blank"><b>API Documentation</b></a></li> |
| 158 | + * <li><a href="https://developer.crowdin.com/enterprise/api/v2/#operation/api.glossaries.getMany" target="_blank"><b>Enterprise API Documentation</b></a></li> |
| 159 | + * </ul> |
| 160 | + */ |
| 161 | + public ResponseList<Glossary> listGlossaries(Long groupId, Integer limit, Integer offset, List<OrderByField> orderBy) throws HttpException, HttpBadRequestException { |
| 162 | + ListGlossariesParams params = new ListGlossariesParams(); |
| 163 | + params.setGroupId(groupId); |
| 164 | + params.setLimit(limit); |
| 165 | + params.setOffset(offset); |
| 166 | + params.setOrderByList(orderBy); |
| 167 | + return listGlossaries(params); |
| 168 | + } |
| 169 | + |
131 | 170 | public ResponseList<Glossary> listGlossaries(ListGlossariesParams params) throws HttpException, HttpBadRequestException { |
| 171 | + ListGlossariesParams query = Optional.ofNullable(params).orElse(new ListGlossariesParams()); |
| 172 | + |
| 173 | + String orderBy = query.getOrderByList() != null |
| 174 | + ? OrderByField.generateSortParam(query.getOrderByList()) |
| 175 | + : query.getOrderBy(); |
| 176 | + |
132 | 177 | Map<String, Optional<Object>> queryParams = HttpRequestConfig.buildUrlParams( |
133 | | - "groupId", Optional.ofNullable(params.getGroupId()), |
134 | | - "userId", Optional.ofNullable(params.getUserId()), |
135 | | - "limit", Optional.ofNullable(params.getLimit()), |
136 | | - "offset", Optional.ofNullable(params.getOffset()) |
| 178 | + "groupId", Optional.ofNullable(query.getGroupId()), |
| 179 | + "userId", Optional.ofNullable(query.getUserId()), |
| 180 | + "limit", Optional.ofNullable(query.getLimit()), |
| 181 | + "offset", Optional.ofNullable(query.getOffset()), |
| 182 | + "orderBy", Optional.ofNullable(orderBy) |
137 | 183 | ); |
138 | 184 | GlossaryResponseList glossaryResponseList = this.httpClient.get(this.url + "/glossaries", new HttpRequestConfig(queryParams), GlossaryResponseList.class); |
139 | 185 | return GlossaryResponseList.to(glossaryResponseList); |
@@ -285,16 +331,49 @@ public ResponseList<Term> listTerms(Long glossaryId, Long userId, String languag |
285 | 331 | return listTerms(glossaryId, params); |
286 | 332 | } |
287 | 333 |
|
| 334 | + /** |
| 335 | + * @param glossaryId glossary identifier |
| 336 | + * @param userId user identifier |
| 337 | + * @param languageId language identifier |
| 338 | + * @param conceptId concept identifier |
| 339 | + * @param translationOfTermId term identifier |
| 340 | + * @param limit maximum number of items to retrieve (default 25) |
| 341 | + * @param offset starting offset in the collection (default 0) |
| 342 | + * @param orderBy list of OrderByField |
| 343 | + * @return list of terms |
| 344 | + * @see <ul> |
| 345 | + * <li><a href="https://developer.crowdin.com/api/v2/#operation/api.glossaries.terms.getMany" target="_blank"><b>API Documentation</b></a></li> |
| 346 | + * <li><a href="https://developer.crowdin.com/enterprise/api/v2/#operation/api.glossaries.terms.getMany" target="_blank"><b>Enterprise API Documentation</b></a></li> |
| 347 | + * </ul> |
| 348 | + */ |
| 349 | + public ResponseList<Term> listTerms(Long glossaryId, Long userId, String languageId, Long conceptId, @Deprecated Long translationOfTermId, Integer limit, Integer offset, List<OrderByField> orderBy) throws HttpException, HttpBadRequestException { |
| 350 | + ListTermsParams params = new ListTermsParams(); |
| 351 | + params.setUserId(userId); |
| 352 | + params.setLanguageId(languageId); |
| 353 | + params.setConceptId(conceptId); |
| 354 | + params.setTranslationOfTermId(translationOfTermId); |
| 355 | + params.setLimit(limit); |
| 356 | + params.setOffset(offset); |
| 357 | + params.setOrderByList(orderBy); |
| 358 | + return listTerms(glossaryId, params); |
| 359 | + } |
| 360 | + |
288 | 361 | public ResponseList<Term> listTerms(Long glossaryId, ListTermsParams params) throws HttpException, HttpBadRequestException { |
| 362 | + ListTermsParams query = Optional.ofNullable(params).orElse(new ListTermsParams()); |
| 363 | + |
| 364 | + String orderBy = query.getOrderByList() != null |
| 365 | + ? OrderByField.generateSortParam(query.getOrderByList()) |
| 366 | + : query.getOrderBy(); |
| 367 | + |
289 | 368 | Map<String, Optional<Object>> queryParams = HttpRequestConfig.buildUrlParams( |
290 | | - "orderBy", Optional.ofNullable(params.getOrderBy()), |
291 | | - "userId", Optional.ofNullable(params.getUserId()), |
292 | | - "languageId", Optional.ofNullable(params.getLanguageId()), |
293 | | - "conceptId", Optional.ofNullable(params.getConceptId()), |
294 | | - "translationOfTermId", Optional.ofNullable(params.getTranslationOfTermId()), |
295 | | - "croql", Optional.ofNullable(params.getCroql()), |
296 | | - "limit", Optional.ofNullable(params.getLimit()), |
297 | | - "offset", Optional.ofNullable(params.getOffset()) |
| 369 | + "orderBy", Optional.ofNullable(orderBy), |
| 370 | + "userId", Optional.ofNullable(query.getUserId()), |
| 371 | + "languageId", Optional.ofNullable(query.getLanguageId()), |
| 372 | + "conceptId", Optional.ofNullable(query.getConceptId()), |
| 373 | + "translationOfTermId", Optional.ofNullable(query.getTranslationOfTermId()), |
| 374 | + "croql", Optional.ofNullable(query.getCroql()), |
| 375 | + "limit", Optional.ofNullable(query.getLimit()), |
| 376 | + "offset", Optional.ofNullable(query.getOffset()) |
298 | 377 | ); |
299 | 378 | TermResponseList termResponseList = this.httpClient.get(this.url + "/glossaries/" + glossaryId + "/terms", new HttpRequestConfig(queryParams), TermResponseList.class); |
300 | 379 | return TermResponseList.to(termResponseList); |
|
0 commit comments