Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/main/java/com/crowdin/client/bundles/BundlesApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,15 @@ public ResponseList<Bundle> listBundles(Long projectId) throws HttpException, Ht
return listBundles(projectId, new Pagination());
}

/**
* @param projectId project identifier
* @param options pagination options (limit, offset)
* @return list of bundles
* @see <ul>
* <li><a href="https://developer.crowdin.com/api/v2/#operation/api.projects.bundles.getMany" target="_blank"><b>API Documentation</b></a></li>
* <li><a href="https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.bundles.getMany" target="_blank"><b>Enterprise API Documentation</b></a></li>
* </ul>
*/
public ResponseList<Bundle> listBundles(Long projectId, Pagination options) throws HttpException, HttpBadRequestException {
Map<String, Optional<Object>> queryParams = HttpRequestConfig.buildUrlParams(
"limit", Optional.ofNullable(options.getLimit()),
Expand Down Expand Up @@ -133,6 +142,11 @@ public ResponseList<? extends FileInfo> listBundleFiles(Long projectId, Long bun
* @param bundleId bundle identifier
* @param limit maximum number of items to retrieve (default 25)
* @param offset starting offset in the collection (default 0)
* @return list of bundle branches
* @see <ul>
* <li><a href="https://developer.crowdin.com/api/v2/#operation/api.projects.bundles.branches.getMany" target="_blank"><b>API Documentation</b></a></li>
* <li><a href="https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.bundles.branches.getMany" target="_blank"><b>Enterprise API Documentation</b></a></li>
* </ul>
*/
public ResponseList<Branch> listBundleBranches(Long projectId, Long bundleId, Integer limit, Integer offset) throws HttpException, HttpBadRequestException {
Map<String, Optional<Object>> queryParams = HttpRequestConfig.buildUrlParams(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ public class AddBundleRequest {
private String exportPattern;
private Boolean isMultilingual;
private Boolean includeProjectSourceLanguage;
private String sourceLanguageExportPattern;
private Boolean includeInContextPseudoLanguage;
private List<Long> labelIds;
private List<Long> excludeLabelIds;
private LabelMatchRule labelMatchRule;
private LabelMatchRule excludeLabelMatchRule;
private List<String> languageIds;
}
4 changes: 4 additions & 0 deletions src/main/java/com/crowdin/client/bundles/model/Bundle.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@ public class Bundle {
private boolean isMultilingual;
private Boolean includeProjectSourceLanguage;
private Boolean includeInContextPseudoLanguage;
private String sourceLanguageExportPattern;
private LabelMatchRule labelMatchRule;
private LabelMatchRule excludeLabelMatchRule;
private List<Long> labelIds;
private List<Long> excludeLabelIds;
private List<String> languageIds;
private String webUrl;
private Date createdAt;
private Date updatedAt;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ public class BundleExport {
private Date updatedAt;
private Date startedAt;
private Date finishedAt;
/**
* @deprecated deprecated in the API, may be removed in the future
*/
@Deprecated
private String eta;

}
17 changes: 17 additions & 0 deletions src/main/java/com/crowdin/client/bundles/model/LabelMatchRule.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.crowdin.client.bundles.model;

import com.crowdin.client.core.model.EnumConverter;

public enum LabelMatchRule implements EnumConverter<LabelMatchRule> {

ALL, ANY;

public static LabelMatchRule from(String value) {
return LabelMatchRule.valueOf(value.toUpperCase());
}

@Override
public Object to(LabelMatchRule v) {
return v.name().toLowerCase();
}
}
1 change: 1 addition & 0 deletions src/main/java/com/crowdin/client/clients/model/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ public class Client {
private String name;
private String description;
private Status status;
private String webUrl;
}
33 changes: 27 additions & 6 deletions src/main/java/com/crowdin/client/fields/FieldsApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ public FieldsApi(Credentials credentials, ClientConfig clientConfig) {
* @param search Search fields by slug or name
* @param limit maximum number of items to retrieve (default 25)
* @param offset starting offset in the collection (default 0)
* @return list of distributions
* @return list of fields
* @see <ul>
* <li><a href="https://developer.crowdin.com/enterprise/api/v2/#operation/api.fields.getMany" target="_blank"><b>API Documentation</b></a></li>
* <li><a href="https://developer.crowdin.com/enterprise/api/v2/#operation/api.fields.getMany" target="_blank"><b>Enterprise API Documentation</b></a></li>
* </ul>
*/
public ResponseList<Field> listFields(String entity, String search, Integer limit, Integer offset) throws HttpException, HttpBadRequestException {
Expand All @@ -44,6 +44,13 @@ public ResponseList<Field> listFields(String entity, String search, Integer limi
return listFields(params);
}

/**
* @param params query parameters (entity, search, type, limit, offset)
* @return list of fields
* @see <ul>
* <li><a href="https://developer.crowdin.com/enterprise/api/v2/#operation/api.fields.getMany" target="_blank"><b>Enterprise API Documentation</b></a></li>
* </ul>
*/
public ResponseList<Field> listFields(ListFieldsParams params) throws HttpException, HttpBadRequestException {
Map<String, Optional<Object>> queryParams = HttpRequestConfig.buildUrlParams(
"entity", Optional.ofNullable(params.getEntity()),
Expand All @@ -60,7 +67,7 @@ public ResponseList<Field> listFields(ListFieldsParams params) throws HttpExcept
* @param request object {@link com.crowdin.client.fields.model.FieldRequest}
* @return Field object
* @see <ul>
* <li><a href="https://developer.crowdin.com/enterprise/api/v2/#operation/api.fields.post" target="_blank"><b>API Documentation</b></a></li>
* <li><a href="https://developer.crowdin.com/enterprise/api/v2/#operation/api.fields.post" target="_blank"><b>Enterprise API Documentation</b></a></li>
* </ul>
*/
public ResponseObject<Field> addField(FieldRequest request) throws HttpException, HttpBadRequestException {
Expand All @@ -72,18 +79,32 @@ public ResponseObject<Field> addField(FieldRequest request) throws HttpException
* @param fieldId field identifier
* @return field object according to id
* @see <ul>
* <li><a href="https://developer.crowdin.com/enterprise/api/v2/#operation/api.fields.get" target="_blank"><b>API Documentation</b></a></li>
* <li><a href="https://developer.crowdin.com/enterprise/api/v2/#operation/api.fields.get" target="_blank"><b>Enterprise API Documentation</b></a></li>
* </ul>
* @deprecated the API returns a single field object, not a collection; use {@link #getFieldById(Long)} instead
*/
@Deprecated
public ResponseList<Field> getField(Long fieldId) throws HttpException, HttpBadRequestException {
FieldResponseObjectList responseObject = this.httpClient.get(this.url + "/fields/" + fieldId, new HttpRequestConfig(), FieldResponseObjectList.class);
return FieldResponseObjectList.to(responseObject);
}

/**
* @param fieldId field identifier
* @return field object according to id
* @see <ul>
* <li><a href="https://developer.crowdin.com/enterprise/api/v2/#operation/api.fields.get" target="_blank"><b>Enterprise API Documentation</b></a></li>
* </ul>
*/
public ResponseObject<Field> getFieldById(Long fieldId) throws HttpException, HttpBadRequestException {
FieldResponseObject responseObject = this.httpClient.get(this.url + "/fields/" + fieldId, new HttpRequestConfig(), FieldResponseObject.class);
return ResponseObject.of(responseObject.getData());
}

/**
* @param fieldId field identifier
* @see <ul>
* <li><a href="https://developer.crowdin.com/enterprise/api/v2/#operation/api.fields.delete" target="_blank"><b>API Documentation</b></a></li>
* <li><a href="https://developer.crowdin.com/enterprise/api/v2/#operation/api.fields.delete" target="_blank"><b>Enterprise API Documentation</b></a></li>
* </ul>
*/
public void deleteField(Long fieldId) throws HttpException, HttpBadRequestException {
Expand All @@ -95,7 +116,7 @@ public void deleteField(Long fieldId) throws HttpException, HttpBadRequestExcept
* @param request object
* @return field object
* @see <ul>
* <li><a href="https://developer.crowdin.com/enterprise/api/v2/#operation/api.fields.patch" target="_blank"><b>API Documentation</b></a></li>
* <li><a href="https://developer.crowdin.com/enterprise/api/v2/#operation/api.fields.patch" target="_blank"><b>Enterprise API Documentation</b></a></li>
* </ul>
*/
public ResponseObject<Field> editField(Long fieldId, List<PatchRequest> request) throws HttpException, HttpBadRequestException {
Expand Down
80 changes: 80 additions & 0 deletions src/main/java/com/crowdin/client/fields/model/Config.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.crowdin.client.fields.model;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;

import java.util.List;
Expand All @@ -8,10 +10,88 @@
public class Config {
private List<Option> options;
private List<Location> locations;

/**
* @deprecated the API defines {@code min} as a number, use {@link #minValue} instead
*/
@Deprecated
@JsonIgnore
private Integer min;

/**
* @deprecated the API defines {@code max} as a number, use {@link #maxValue} instead
*/
@Deprecated
@JsonIgnore
private Integer max;

/**
* Minimal value of a number field (JSON key {@code min})
*/
@JsonProperty("min")
private Double minValue;

/**
* Maximal value of a number field (JSON key {@code max})
*/
@JsonProperty("max")
private Double maxValue;

private String units;

/**
* Legacy integer view of {@link #minValue}. A fractional value within the {@link Integer} range is truncated
* towards zero (e.g. {@code 1.5} &rarr; {@code 1}, {@code -1.5} &rarr; {@code -1}). A value outside the
* {@link Integer} range (or not a number) is returned as {@code null} instead of being clamped.
*
* @return minimal value truncated to an integer, or {@code null} if it is not set or does not fit into an integer
* @deprecated the API defines {@code min} as a number; use {@code getMinValue()} ({@link #minValue}) instead,
* which returns the exact value
*/
@Deprecated
public Integer getMin() {
return toInteger(this.minValue);
}

/**
* @param min minimal value
* @deprecated use {@link #minValue} instead
*/
@Deprecated
public void setMin(Integer min) {
this.minValue = min == null ? null : min.doubleValue();
}

/**
* Legacy integer view of {@link #maxValue}. A fractional value within the {@link Integer} range is truncated
* towards zero (e.g. {@code 9.9} &rarr; {@code 9}, {@code -9.9} &rarr; {@code -9}). A value outside the
* {@link Integer} range (or not a number) is returned as {@code null} instead of being clamped.
*
* @return maximal value truncated to an integer, or {@code null} if it is not set or does not fit into an integer
* @deprecated the API defines {@code max} as a number; use {@code getMaxValue()} ({@link #maxValue}) instead,
* which returns the exact value
*/
@Deprecated
public Integer getMax() {
return toInteger(this.maxValue);
}

/**
* @param max maximal value
* @deprecated use {@link #maxValue} instead
*/
@Deprecated
public void setMax(Integer max) {
this.maxValue = max == null ? null : max.doubleValue();
}

private static Integer toInteger(Double value) {
if (value == null || value.isNaN() || value < Integer.MIN_VALUE || value > Integer.MAX_VALUE) {
return null;
}
return value.intValue();
}

@Data
public static class Option {
private String label;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ public enum EntityType implements EnumConverter<EntityType> {
TASK,
FILE,
TRANSLATION,
STRING;
STRING,
TERM,
CONCEPT;

public static EntityType from(String value) {
return EntityType.valueOf(value.toUpperCase());
Expand Down
29 changes: 29 additions & 0 deletions src/main/java/com/crowdin/client/issues/model/Issue.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,37 @@ public class Issue {
private String text;
private Long userId;
private Long stringId;
private User user;
private StringObject string;
private String languageId;
private Type type;
private Status status;
private Date createdAt;

@Data
public static class User {
private Long id;
private String username;
private String fullName;
private String avatarUrl;
}

@Data
public static class StringObject {
private Long id;
private String text;
private String type;
/**
* @deprecated deprecated in the API
*/
@Deprecated
private Boolean hasPlurals;
/**
* @deprecated deprecated in the API
*/
@Deprecated
private Boolean isIcu;
private String context;
private Long fileId;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public class Language {
private String threeLettersCode;
private String locale;
private String androidCode;
private String bcp47Code;
private String osxCode;
private String osxLocale;
private List<String> pluralCategoryNames;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.crowdin.client.machinetranslationengines.model;

import lombok.Data;

@Data
public class CustomMtTranslateCredentials implements Credentials {

/**
* Base URL
*/
private String url;
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ public NotificationsApi(Credentials credentials, ClientConfig clientConfig) {
/**
* @param request request object
* @see <ul>
* <li><a href="https://developer.crowdin.com/api/v2/#tag/Notifications/api.projects.notification.post" target="_blank"><b>API Documentation</b></a></li>
* <li><a href="https://developer.crowdin.com/api/v2/#operation/api.notify.post" target="_blank"><b>API Documentation</b></a></li>
* <li><a href="https://developer.crowdin.com/enterprise/api/v2/#operation/api.notify.post" target="_blank"><b>Enterprise API Documentation</b></a></li>
* </ul>
*/
public void sendNotificationToAuthenticatedUser(SendNotificationToAuthenticatedUserRequest request) throws HttpException, HttpBadRequestException {
Expand Down
20 changes: 20 additions & 0 deletions src/main/java/com/crowdin/client/securitylogs/SecurityLogsApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,30 @@ public SecurityLogsApi(Credentials credentials, ClientConfig clientConfig) {
* </ul>
*/
public ResponseList<SecurityLogResource> listUserSecurityLogs(Long userId, Long limit, Integer offset, String event, String ipAddress) throws HttpException, HttpBadRequestException {
return listUserSecurityLogs(userId, limit, offset, event, null, null, ipAddress);
}

/**
* @param userId user Identifier
* @param limit maximum number of items to retrieve (default 25)
* @param offset starting offset in the collection (default 0)
* @param event value of event
* @param createdAfter String Date in UTC format (ISO 8601)
* @param createdBefore String Date in UTC format (ISO 8601)
* @param ipAddress value of ipAddress
* @return list of Security logs
* @see <ul>
* <li><a href="https://developer.crowdin.com/api/v2/#operation/api.users.security-logs.getMany" target="_blank"><b>API Documentation</b></a></li>
* <li><a href="https://developer.crowdin.com/enterprise/api/v2/#operation/api.users.security-logs.getMany" target="_blank"><b>Enterprise API Documentation</b></a></li>
* </ul>
*/
public ResponseList<SecurityLogResource> listUserSecurityLogs(Long userId, Long limit, Integer offset, String event, String createdAfter, String createdBefore, String ipAddress) throws HttpException, HttpBadRequestException {
Map<String, Optional<Object>> queryParams = HttpRequestConfig.buildUrlParams(
"limit", Optional.ofNullable(limit),
"offset", Optional.ofNullable(offset),
"event", Optional.ofNullable(event),
"createdAfter", Optional.ofNullable(createdAfter),
"createdBefore", Optional.ofNullable(createdBefore),
"ipAddress", Optional.ofNullable(ipAddress)
);
SecurityLogsResourceResponseList securityLogsResponseList = this.httpClient.get(this.url + "/users/" + userId+ "/security-logs", new HttpRequestConfig(queryParams), SecurityLogsResourceResponseList.class);
Expand Down
Loading
Loading