Skip to content

Commit

Permalink
fix: 'unassignLabelFromStrings' - 'stringIds' parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
andrii-bodnar committed Jul 26, 2023
1 parent e6d9014 commit cb43a45
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 7 additions & 2 deletions src/main/java/com/crowdin/client/labels/LabelsApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -133,15 +133,20 @@ public ResponseList<SourceString> assignLabelToStrings(Long projectId, Long labe
/**
* @param projectId Project Identifier
* @param labelId Label Identifier
* @param stringIds List of string IDs
* @return Source string
* @see <ul>
* <li><a href="https://developer.crowdin.com/api/v2/#operation/api.projects.labels.strings.deleteMany" target="_blank"><b>API Documentation</b></a></li>
* <li><a href="https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.labels.strings.deleteMany" target="_blank"><b>Enterprise API Documentation</b></a></li>
* </ul>
*/
public ResponseList<SourceString> unassignLabelFromStrings(Long projectId, Long labelId) throws HttpException, HttpBadRequestException {
public ResponseList<SourceString> unassignLabelFromStrings(Long projectId, Long labelId, List<Long> stringIds) throws HttpException, HttpBadRequestException {
String builtUrl = String.format("%s/projects/%d/labels/%d/strings", this.url, projectId, labelId);
SourceStringResponseList response = this.httpClient.delete(builtUrl, new HttpRequestConfig(), SourceStringResponseList.class);
Map<String, Optional<Object>> queryParams = HttpRequestConfig.buildUrlParams(
"stringIds", Optional.ofNullable(stringIds == null ? null : stringIds.stream().map(String::valueOf).collect(Collectors.joining(","))
));

SourceStringResponseList response = this.httpClient.delete(builtUrl, new HttpRequestConfig(queryParams), SourceStringResponseList.class);
return SourceStringResponseList.to(response);
}

Expand Down
2 changes: 1 addition & 1 deletion src/test/java/com/crowdin/client/labels/LabelsApiTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public void assignLabelToStringTest() {

@Test
public void unassignLabelToStringTest() {
ResponseList<SourceString> response = this.getLabelsApi().unassignLabelFromStrings(projectId, labelId);
ResponseList<SourceString> response = this.getLabelsApi().unassignLabelFromStrings(projectId, labelId, Arrays.asList(1L, 2L));
assertEquals(1, response.getData().size());
}

Expand Down

0 comments on commit cb43a45

Please sign in to comment.