Skip to content

Commit

Permalink
translation status api
Browse files Browse the repository at this point in the history
  • Loading branch information
yevheniyJ committed Nov 24, 2023
1 parent fafe283 commit feeabbe
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import com.crowdin.client.core.model.Credentials;
import com.crowdin.client.core.model.ResponseList;
import com.crowdin.client.translationstatus.model.Category;
import com.crowdin.client.translationstatus.model.FileProgress;
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;
Expand Down Expand Up @@ -99,7 +99,7 @@ public ResponseList<LanguageProgress> getFileProgress(Long projectId, Long fileI
* <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<FileProgress> getLanguageProgress(Long projectId, String languageId, Integer limit, Integer offset) throws HttpException, HttpBadRequestException {
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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,14 @@
@Data
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
public class FileProgress extends Progress {
public class FileBranchProgress extends Progress {

/**
* For strings-based projects
*/
private Long branchId;
/**
* For non strings-based projects
*/
private Long fileId;
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class FileProgressResponseList {
private List<FileProgressResponseObject> data;
private Pagination pagination;

public static ResponseList<FileProgress> to(FileProgressResponseList fileProgressResponseList) {
public static ResponseList<FileBranchProgress> to(FileProgressResponseList fileProgressResponseList) {
return ResponseList.of(
fileProgressResponseList.getData().stream()
.map(FileProgressResponseObject::getData)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
@Data
public class FileProgressResponseObject {

private FileProgress data;
private FileBranchProgress data;
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.crowdin.client.translationstatus.model;

import com.crowdin.client.languages.model.Language;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
Expand All @@ -10,4 +11,5 @@
public class LanguageProgress extends Progress {

private String languageId;
private Language language;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.crowdin.client.core.model.ResponseList;
import com.crowdin.client.framework.RequestMock;
import com.crowdin.client.framework.TestClient;
import com.crowdin.client.translationstatus.model.FileProgress;
import com.crowdin.client.translationstatus.model.FileBranchProgress;
import com.crowdin.client.translationstatus.model.LanguageProgress;
import com.crowdin.client.translationstatus.model.QaCheck;
import org.apache.http.client.methods.HttpGet;
Expand Down Expand Up @@ -60,7 +60,7 @@ public void getFileProgressTest() {

@Test
public void getLanguageProgressTest() {
ResponseList<FileProgress> languageProgress = this.getTranslationStatusApi().getLanguageProgress(projectId, languageId, null, null);
ResponseList<FileBranchProgress> languageProgress = this.getTranslationStatusApi().getLanguageProgress(projectId, languageId, null, null);
assertEquals(languageProgress.getData().size(), 1);
assertEquals(languageProgress.getData().get(0).getData().getPhrases().getTotal(), (Integer) 5000);
assertEquals(languageProgress.getData().get(0).getData().getPhrases().getPreTranslateAppliedTo(), (Integer) 1254);
Expand Down

0 comments on commit feeabbe

Please sign in to comment.