Skip to content

Commit aa2ac4a

Browse files
authored
Merge pull request #309 from crowdin/reports-api-updates
feat: reports api updates
2 parents 7565f3c + 49424a2 commit aa2ac4a

25 files changed

+468
-161
lines changed

src/main/java/com/crowdin/client/core/http/impl/json/DateDeserializer.java

+5
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ public Date deserialize(JsonParser p, DeserializationContext ctxt) throws IOExce
1919
return null;
2020
}
2121

22+
return deserializeDate(date);
23+
}
24+
25+
@SneakyThrows
26+
public static Date deserializeDate(String date) {
2227
try {
2328
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
2429
return format.parse(date);

src/main/java/com/crowdin/client/core/http/impl/json/JacksonJsonTransformer.java

+3
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,7 @@ public <T> String convert(T obj) {
7272
return this.objectMapper.writeValueAsString(obj);
7373
}
7474

75+
public ObjectMapper getObjectMapper() {
76+
return this.objectMapper;
77+
}
7578
}

src/main/java/com/crowdin/client/reports/ReportsApi.java

+65-1
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,70 @@ public ResponseObject<DownloadLink> downloadOrganizationReport(String reportId)
101101
return ResponseObject.of(responseObject.getData());
102102
}
103103

104+
/**
105+
* @return list of report settings template
106+
* @see <ul>
107+
* <li><a href="https://support.crowdin.com/developer/enterprise/api/v2/#tag/Reports/operation/api.reports.settings-templates.getMany" target="_blank"><b>Enterprise API Documentation</b></a></li>
108+
* </ul>
109+
*/
110+
public ResponseList<ReportSettingsTemplate.OrganizationReportSettingsTemplate> listOrganizationReportSettingsTemplates(ListOrganizationReportSettingsParams params) throws HttpException, HttpBadRequestException {
111+
Map<String, Optional<Object>> queryParams = HttpRequestConfig.buildUrlParams(
112+
"projectId", Optional.ofNullable(params.getProjectId()),
113+
"groupId", Optional.ofNullable(params.getGroupId()),
114+
"limit", Optional.ofNullable(params.getLimit()),
115+
"offset", Optional.ofNullable(params.getOffset())
116+
);
117+
OrganizationReportSettingsTemplateList reportSettingsTemplateList = this.httpClient.get(this.url + "/reports/settings-templates", new HttpRequestConfig(queryParams), OrganizationReportSettingsTemplateList.class);
118+
return OrganizationReportSettingsTemplateList.to(reportSettingsTemplateList);
119+
}
120+
121+
/**
122+
* @param request request object
123+
* @return report settings template
124+
* @see <ul>
125+
* <li><a href="https://support.crowdin.com/developer/enterprise/api/v2/#tag/Reports/operation/api.reports.settings-templates.post" target="_blank"><b>Enterprise API Documentation</b></a></li>
126+
* </ul>
127+
*/
128+
public ResponseObject<ReportSettingsTemplate.OrganizationReportSettingsTemplate> addOrganizationReportSettingsTemplate(ReportSettingsTemplate.OrganizationReportSettingsTemplate request) throws HttpException, HttpBadRequestException {
129+
OrganizationReportSettingsTemplateResponseObject responseObject = this.httpClient.post(this.url + "/reports/settings-templates", request, new HttpRequestConfig(), OrganizationReportSettingsTemplateResponseObject.class);
130+
return ResponseObject.of(responseObject.getData());
131+
}
132+
133+
/**
134+
* @param reportSettingsTemplateId report settings template identifier
135+
* @return report settings template
136+
* @see <ul>
137+
* <li><a href="https://support.crowdin.com/developer/enterprise/api/v2/#tag/Reports/operation/api.reports.settings-templates.get" target="_blank"><b>Enterprise API Documentation</b></a></li>
138+
* </ul>
139+
*/
140+
public ResponseObject<ReportSettingsTemplate.OrganizationReportSettingsTemplate> getOrganizationReportSettingsTemplate(Long reportSettingsTemplateId) throws HttpException, HttpBadRequestException {
141+
OrganizationReportSettingsTemplateResponseObject responseObject = this.httpClient.get(this.url + "/reports/settings-templates/" + reportSettingsTemplateId, new HttpRequestConfig(), OrganizationReportSettingsTemplateResponseObject.class);
142+
return ResponseObject.of(responseObject.getData());
143+
}
144+
145+
/**
146+
* @param reportSettingsTemplateId report settings template identifier
147+
* @param request request object
148+
* @return report settings template
149+
* @see <ul>
150+
* <li><a href="https://support.crowdin.com/developer/enterprise/api/v2/#tag/Reports/operation/api.reports.settings-templates.patch" target="_blank"><b>Enterprise API Documentation</b></a></li>
151+
* </ul>
152+
*/
153+
public ResponseObject<ReportSettingsTemplate.OrganizationReportSettingsTemplate> editOrganizationReportSettingsTemplate(Long reportSettingsTemplateId, List<PatchRequest> request) throws HttpException, HttpBadRequestException {
154+
OrganizationReportSettingsTemplateResponseObject responseObject = this.httpClient.patch(this.url + "/reports/settings-templates/" + reportSettingsTemplateId, request, new HttpRequestConfig(), OrganizationReportSettingsTemplateResponseObject.class);
155+
return ResponseObject.of(responseObject.getData());
156+
}
157+
158+
/**
159+
* @param reportSettingsTemplateId report settings template identifier
160+
* @see <ul>
161+
* <li><a href="https://support.crowdin.com/developer/enterprise/api/v2/#tag/Reports/operation/api.reports.settings-templates.delete" target="_blank"><b>Enterprise API Documentation</b></a></li>
162+
* </ul>
163+
*/
164+
public void deleteOrganizationReportSettingsTemplate(Long reportSettingsTemplateId) throws HttpException, HttpBadRequestException {
165+
this.httpClient.delete(this.url + "/reports/settings-templates/" + reportSettingsTemplateId, new HttpRequestConfig(), Void.class);
166+
}
167+
104168
/**
105169
* @param projectId project identifier
106170
* @param request request object
@@ -214,7 +278,7 @@ public ResponseObject<ReportSettingsTemplate> editReportSettingsTemplate(Long pr
214278
* </ul>
215279
*/
216280
public void deleteReportSettingsTemplate(Long projectId, Long reportSettingsTemplateId) throws HttpException, HttpBadRequestException {
217-
this.httpClient.delete(this.url + "/projects/" + projectId + "/settings-templates/" + reportSettingsTemplateId, new HttpRequestConfig(), Void.class);
281+
this.httpClient.delete(this.url + "/projects/" + projectId + "/reports/settings-templates/" + reportSettingsTemplateId, new HttpRequestConfig(), Void.class);
218282
}
219283

220284
// -- USER REPORTS -- //
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package com.crowdin.client.reports.model;
2+
3+
import lombok.Data;
4+
import lombok.EqualsAndHashCode;
5+
6+
import java.util.Date;
7+
import java.util.List;
8+
9+
@Data
10+
@EqualsAndHashCode(callSuper = true)
11+
public class ContributionRawDataGenerateReportRequest extends GenerateReportRequest {
12+
private String name = "contribution-raw-data";
13+
private Schema schema;
14+
15+
@Data
16+
public static class Schema {
17+
private String mode;
18+
private Unit unit;
19+
private List<String> columns;
20+
private List<Long> tmIds;
21+
private List<Long> mtIds;
22+
private List<Long> aiPromptIds;
23+
private Date dateFrom;
24+
private Date dateTo;
25+
}
26+
27+
@Data
28+
@EqualsAndHashCode(callSuper = true)
29+
public static class GeneralSchema extends Schema {
30+
private String languageId;
31+
private Long userId;
32+
private List<Long> fileIds;
33+
private List<Long> directoryIds;
34+
private List<Long> branchIds;
35+
}
36+
37+
@Data
38+
@EqualsAndHashCode(callSuper = true)
39+
public static class ByTaskSchema extends Schema {
40+
private Long taskId;
41+
}
42+
}

src/main/java/com/crowdin/client/reports/model/CostEstimationPostEditingGenerateReportRequest.java

+4-19
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,16 @@ public static class Schema {
1717
private Unit unit;
1818
private Currency currency;
1919
private ReportsFormat format;
20+
private BaseRatesForm baseRates;
21+
private List<IndividualRate> individualRates;
22+
private NetRateSchemes netRateSchemes;
2023
private Boolean calculateInternalMatches;
2124
private Boolean includePreTranslatedStrings;
2225
}
2326

2427
@Data
2528
@EqualsAndHashCode(callSuper = true)
2629
public static class GeneralSchema extends Schema {
27-
private BaseRatesForm baseRates;
28-
private List<IndividualRate> individualRates;
29-
private NetRateSchemes netRateSchemes;
3030
private String languageId;
3131
private List<Long> fileIds;
3232
private List<Long> directoryIds;
@@ -35,27 +35,12 @@ public static class GeneralSchema extends Schema {
3535
private Date dateTo;
3636
private List<Long> labelIds;
3737
private LabelIncludeType labelIncludeType;
38+
private Long workflowStepId;
3839
}
3940

4041
@Data
4142
@EqualsAndHashCode(callSuper = true)
4243
public static class ByTaskSchema extends Schema {
43-
private BaseRatesForm baseRates;
44-
private List<IndividualRate> individualRates;
45-
private NetRateSchemes netRateSchemes;
4644
private Long taskId;
4745
}
48-
49-
@Data
50-
public static class IndividualRate {
51-
private List<String> languageIds;
52-
private List<Long> userIds;
53-
private float fullTranslation;
54-
private float proofread;
55-
}
56-
57-
@Data
58-
public static class NetRateSchemes {
59-
private List<Match> tmMatch;
60-
}
6146
}

src/main/java/com/crowdin/client/reports/model/GenerateGroupReportRequest.java

+3-79
Original file line numberDiff line numberDiff line change
@@ -19,81 +19,20 @@ public static abstract class Schema {
1919

2020
@Data
2121
@EqualsAndHashCode(callSuper = true)
22-
public static class GroupTranslationCostsPerEditingSchema extends Schema {
22+
public static class GroupTranslationCostsPostEditingSchema extends Schema {
2323
private List<Long> projectIds;
2424
private Unit unit;
2525
private Currency currency;
2626
private ReportsFormat format;
2727
private BaseRatesForm baseRates;
2828
private List<IndividualRate> individualRates;
2929
private NetRateSchemes netRateSchemes;
30+
private Boolean excludeApprovalsForEditedTranslations;
31+
private Boolean preTranslatedStringsCategorizationAdjustment;
3032
private GroupingParameter groupBy;
3133
private Date dateFrom;
3234
private Date dateTo;
33-
private List<String> languageId;
3435
private List<Long> userIds;
35-
private List<Long> branchIds;
36-
private List<Long> labelIds;
37-
private LabelIncludeType labelIncludeType;
38-
}
39-
40-
@Data
41-
@EqualsAndHashCode(callSuper = true)
42-
public static class GroupTranslationCostsPerEditingByTaskSchema extends Schema {
43-
private Unit unit;
44-
private Currency currency;
45-
private ReportsFormat format;
46-
private BaseRatesForm baseRates;
47-
private List<IndividualRate> individualRates;
48-
private NetRateSchemes netRateSchemes;
49-
private Long taskId;
50-
}
51-
52-
@Data
53-
@EqualsAndHashCode(callSuper = true)
54-
public static class CostsEstimationSchema extends Schema {
55-
private List<Long> projectIds;
56-
private Unit unit;
57-
private Currency currency;
58-
private ReportsFormat format;
59-
private BaseRatesForm baseRates;
60-
private List<IndividualRate> individualRates;
61-
private NetRateSchemes netRateSchemes;
62-
private Boolean calculateInternalMatches;
63-
private Boolean includePreTranslatedStrings;
64-
private String languageId;
65-
private List<Long> branchIds;
66-
private Date dateFrom;
67-
private Date dateTo;
68-
private List<Long> labelIds;
69-
private LabelIncludeType labelIncludeType;
70-
}
71-
72-
@Data
73-
@EqualsAndHashCode(callSuper = true)
74-
public static class CostsEstimationByTaskSchema extends Schema {
75-
private List<Long> projectIds;
76-
private Unit unit;
77-
private Currency currency;
78-
private ReportsFormat format;
79-
private BaseRatesForm baseRates;
80-
private List<IndividualRate> individualRates;
81-
private NetRateSchemes netRateSchemes;
82-
private Boolean calculateInternalMatches;
83-
private Boolean includePreTranslatedStrings;
84-
private Long taskId;
85-
}
86-
87-
@Data
88-
@EqualsAndHashCode(callSuper = true)
89-
public static class GroupTranslationCostSchema extends Schema {
90-
private List<Long> projectIds;
91-
private Unit unit;
92-
private Currency currency;
93-
private ReportsFormat format;
94-
private GroupingParameter groupBy;
95-
private Date dateFrom;
96-
private Date dateTo;
9736
}
9837

9938
@Data
@@ -107,19 +46,4 @@ public static class GroupTopMembersSchema extends Schema {
10746
private Date dateFrom;
10847
private Date dateTo;
10948
}
110-
111-
@Data
112-
public static class IndividualRate {
113-
private List<String> languageIds;
114-
private List<Long> userIds;
115-
private Float fullTranslation;
116-
private Float proofread;
117-
}
118-
119-
@Data
120-
public static class NetRateSchemes {
121-
private List<Match> tmMatch;
122-
private List<Match> mtMatch;
123-
private List<Match> suggestionMatch;
124-
}
12549
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.crowdin.client.reports.model;
2+
3+
import lombok.Data;
4+
5+
import java.util.List;
6+
7+
@Data
8+
public class IndividualRate {
9+
private List<String> languageIds;
10+
private List<Long> userIds;
11+
private Float fullTranslation;
12+
private Float proofread;
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.crowdin.client.reports.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 ListOrganizationReportSettingsParams extends Pagination {
10+
11+
private Long projectId;
12+
private Long groupId;
13+
}

src/main/java/com/crowdin/client/reports/model/MatchType.java

+7-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,13 @@ public enum MatchType implements EnumConverter<MatchType> {
66
PERFECT("perfect"),
77
OPTION_100("100"),
88
OPTION_99_82("99-82"),
9-
OPTION_81_60("81-60");
9+
OPTION_99_95("99-95"),
10+
OPTION_94_90("94-90"),
11+
OPTION_89_80("89-80"),
12+
OPTION_81_60("81-60"),
13+
TM_MATCH("tm_match"),
14+
APPROVAL("approval"),
15+
NO_MATCH("no_match");
1016

1117
private String value;
1218

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.crowdin.client.reports.model;
2+
3+
import lombok.Data;
4+
5+
import java.util.List;
6+
7+
@Data
8+
public class NetRateSchemes {
9+
private List<Match> tmMatch;
10+
private List<Match> mtMatch;
11+
private List<Match> suggestionMatch;
12+
private List<Match> aiMatch;
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.crowdin.client.reports.model;
2+
3+
import com.crowdin.client.core.model.Pagination;
4+
import com.crowdin.client.core.model.ResponseList;
5+
import com.crowdin.client.core.model.ResponseObject;
6+
import lombok.Data;
7+
8+
import java.util.List;
9+
import java.util.stream.Collectors;
10+
11+
@Data
12+
public class OrganizationReportSettingsTemplateList {
13+
14+
private List<OrganizationReportSettingsTemplateResponseObject> data;
15+
private Pagination pagination;
16+
17+
public static ResponseList<ReportSettingsTemplate.OrganizationReportSettingsTemplate> to(OrganizationReportSettingsTemplateList reportSettingsTemplateList) {
18+
return ResponseList.of(
19+
reportSettingsTemplateList.getData().stream()
20+
.map(OrganizationReportSettingsTemplateResponseObject::getData)
21+
.map(ResponseObject::of)
22+
.collect(Collectors.toList()),
23+
reportSettingsTemplateList.getPagination()
24+
);
25+
}
26+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package com.crowdin.client.reports.model;
2+
3+
import lombok.Data;
4+
5+
@Data
6+
public class OrganizationReportSettingsTemplateResponseObject {
7+
8+
private ReportSettingsTemplate.OrganizationReportSettingsTemplate data;
9+
}

0 commit comments

Comments
 (0)