diff --git a/src/main/java/com/crowdin/client/Client.java b/src/main/java/com/crowdin/client/Client.java index f33621274..e02cd9fce 100644 --- a/src/main/java/com/crowdin/client/Client.java +++ b/src/main/java/com/crowdin/client/Client.java @@ -2,6 +2,7 @@ import com.crowdin.client.applications.ApplicationsApi; import com.crowdin.client.bundles.BundlesApi; +import com.crowdin.client.clients.ClientsApi; import com.crowdin.client.core.CrowdinApi; import com.crowdin.client.core.model.ClientConfig; import com.crowdin.client.core.model.Credentials; @@ -64,6 +65,7 @@ public class Client extends CrowdinApi { private final BundlesApi bundlesApi; private final NotificationsApi notificationsApi; private final ApplicationsApi applicationsApi; + private final ClientsApi clientsApi; public Client(Credentials credentials) { super(credentials); @@ -95,6 +97,7 @@ public Client(Credentials credentials) { this.bundlesApi = new BundlesApi(credentials); this.notificationsApi = new NotificationsApi(credentials); this.applicationsApi = new ApplicationsApi(credentials); + this.clientsApi = new ClientsApi(credentials); } public Client(Credentials credentials, ClientConfig clientConfig) { @@ -127,6 +130,7 @@ public Client(Credentials credentials, ClientConfig clientConfig) { this.bundlesApi = new BundlesApi(credentials, clientConfig); this.notificationsApi = new NotificationsApi(credentials, clientConfig); this.applicationsApi = new ApplicationsApi(credentials, clientConfig); + this.clientsApi = new ClientsApi(credentials, clientConfig); } } diff --git a/src/main/java/com/crowdin/client/applications/ApplicationsApi.java b/src/main/java/com/crowdin/client/applications/ApplicationsApi.java index 9aa22817e..37788b9e2 100644 --- a/src/main/java/com/crowdin/client/applications/ApplicationsApi.java +++ b/src/main/java/com/crowdin/client/applications/ApplicationsApi.java @@ -9,6 +9,8 @@ import com.crowdin.client.core.model.Credentials; import com.crowdin.client.core.model.ResponseObject; +import java.util.Map; + public class ApplicationsApi extends CrowdinApi { public ApplicationsApi(Credentials credentials) { @@ -28,7 +30,7 @@ public ApplicationsApi(Credentials credentials, ClientConfig clientConfig) { *
  • Enterprise API Documentation
  • * */ - public ResponseObject getApplicationData(String applicationIdentifier, String path) throws HttpException, HttpBadRequestException { + public ResponseObject> getApplicationData(String applicationIdentifier, String path) throws HttpException, HttpBadRequestException { String builtUrl = String.format("%s/applications/%s/api/%s", this.url, applicationIdentifier, path); ApplicationDataResponseObject response = this.httpClient.get(builtUrl, new HttpRequestConfig(), ApplicationDataResponseObject.class); return ResponseObject.of(response.getData()); @@ -44,7 +46,7 @@ public ResponseObject getApplicationData(String applicationIden *
  • Enterprise API Documentation
  • * */ - public ResponseObject updateOrRestoreApplicationData(String applicationIdentifier, String path, UpdateOrRestoreApplicationDataRequest request) throws HttpException, HttpBadRequestException { + public ResponseObject> updateOrRestoreApplicationData(String applicationIdentifier, String path, Map request) throws HttpException, HttpBadRequestException { String builtUrl = String.format("%s/applications/%s/api/%s", this.url, applicationIdentifier, path); ApplicationDataResponseObject response = this.httpClient.put(builtUrl, request, new HttpRequestConfig(), ApplicationDataResponseObject.class); return ResponseObject.of(response.getData()); @@ -60,7 +62,7 @@ public ResponseObject updateOrRestoreApplicationData(String app *
  • Enterprise API Documentation
  • * */ - public ResponseObject addApplicationData(String applicationIdentifier, String path, AddApplicationDataRequest request) throws HttpException, HttpBadRequestException { + public ResponseObject> addApplicationData(String applicationIdentifier, String path, Map request) throws HttpException, HttpBadRequestException { String builtUrl = String.format("%s/applications/%s/api/%s", this.url, applicationIdentifier, path); ApplicationDataResponseObject response = this.httpClient.post(builtUrl, request, new HttpRequestConfig(), ApplicationDataResponseObject.class); return ResponseObject.of(response.getData()); @@ -89,7 +91,7 @@ public void deleteApplicationData(String applicationIdentifier, String path) thr *
  • Enterprise API Documentation
  • * */ - public ResponseObject editApplicationData(String applicationIdentifier, String path, EditApplicationDataRequest request) throws HttpException, HttpBadRequestException { + public ResponseObject> editApplicationData(String applicationIdentifier, String path, Map request) throws HttpException, HttpBadRequestException { String builtUrl = String.format("%s/applications/%s/api/%s", this.url, applicationIdentifier, path); ApplicationDataResponseObject response = this.httpClient.patch(builtUrl, request, new HttpRequestConfig(), ApplicationDataResponseObject.class); return ResponseObject.of(response.getData()); diff --git a/src/main/java/com/crowdin/client/applications/model/AddApplicationDataRequest.java b/src/main/java/com/crowdin/client/applications/model/AddApplicationDataRequest.java deleted file mode 100644 index b9564ce24..000000000 --- a/src/main/java/com/crowdin/client/applications/model/AddApplicationDataRequest.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.crowdin.client.applications.model; - -import lombok.Data; - -import java.util.Map; - -@Data -public class AddApplicationDataRequest { - private Map data; -} diff --git a/src/main/java/com/crowdin/client/applications/model/ApplicationData.java b/src/main/java/com/crowdin/client/applications/model/ApplicationData.java deleted file mode 100644 index 201f82e1e..000000000 --- a/src/main/java/com/crowdin/client/applications/model/ApplicationData.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.crowdin.client.applications.model; - -import lombok.Data; - -import java.util.Map; - -@Data -public class ApplicationData { - private Map data; -} diff --git a/src/main/java/com/crowdin/client/applications/model/ApplicationDataResponseObject.java b/src/main/java/com/crowdin/client/applications/model/ApplicationDataResponseObject.java index 841f87f10..0d81869df 100644 --- a/src/main/java/com/crowdin/client/applications/model/ApplicationDataResponseObject.java +++ b/src/main/java/com/crowdin/client/applications/model/ApplicationDataResponseObject.java @@ -2,7 +2,9 @@ import lombok.Data; +import java.util.Map; + @Data public class ApplicationDataResponseObject { - private ApplicationData data; + private Map data; } diff --git a/src/main/java/com/crowdin/client/applications/model/EditApplicationDataRequest.java b/src/main/java/com/crowdin/client/applications/model/EditApplicationDataRequest.java deleted file mode 100644 index e0f7141d2..000000000 --- a/src/main/java/com/crowdin/client/applications/model/EditApplicationDataRequest.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.crowdin.client.applications.model; - -import lombok.Data; - -import java.util.Map; - -@Data -public class EditApplicationDataRequest { - private Map data; - -} diff --git a/src/main/java/com/crowdin/client/applications/model/UpdateOrRestoreApplicationDataRequest.java b/src/main/java/com/crowdin/client/applications/model/UpdateOrRestoreApplicationDataRequest.java deleted file mode 100644 index bb6319456..000000000 --- a/src/main/java/com/crowdin/client/applications/model/UpdateOrRestoreApplicationDataRequest.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.crowdin.client.applications.model; - -import lombok.Data; - -import java.util.Map; - -@Data -public class UpdateOrRestoreApplicationDataRequest { - private Map data; -} diff --git a/src/main/java/com/crowdin/client/bundles/BundlesApi.java b/src/main/java/com/crowdin/client/bundles/BundlesApi.java index c0588bb80..5938e2d86 100644 --- a/src/main/java/com/crowdin/client/bundles/BundlesApi.java +++ b/src/main/java/com/crowdin/client/bundles/BundlesApi.java @@ -1,11 +1,24 @@ package com.crowdin.client.bundles; -import com.crowdin.client.bundles.model.*; +import com.crowdin.client.bundles.model.AddBundleRequest; +import com.crowdin.client.bundles.model.Bundle; +import com.crowdin.client.bundles.model.BundleExport; +import com.crowdin.client.bundles.model.BundleExportResponseObject; +import com.crowdin.client.bundles.model.BundleResponseList; +import com.crowdin.client.bundles.model.BundleResponseObject; import com.crowdin.client.core.CrowdinApi; import com.crowdin.client.core.http.HttpRequestConfig; import com.crowdin.client.core.http.exceptions.HttpBadRequestException; import com.crowdin.client.core.http.exceptions.HttpException; -import com.crowdin.client.core.model.*; +import com.crowdin.client.core.model.ClientConfig; +import com.crowdin.client.core.model.Credentials; +import com.crowdin.client.core.model.DownloadLink; +import com.crowdin.client.core.model.DownloadLinkResponseObject; +import com.crowdin.client.core.model.PatchRequest; +import com.crowdin.client.core.model.ResponseList; +import com.crowdin.client.core.model.ResponseObject; +import com.crowdin.client.sourcefiles.model.Branch; +import com.crowdin.client.sourcefiles.model.BranchResponseList; import com.crowdin.client.sourcefiles.model.FileInfo; import com.crowdin.client.sourcefiles.model.FileInfoResponseList; @@ -39,7 +52,7 @@ public ResponseList listBundles(Long projectId) throws HttpException, Ht /** * @param projectId project identifier - * @param request request object + * @param request request object * @return newly created bundle * @see
      *
    • API Documentation
    • @@ -53,7 +66,7 @@ public ResponseObject addBundle(Long projectId, AddBundleRequest request /** * @param projectId project identifier - * @param bundleId bundle identifier + * @param bundleId bundle identifier * @return bundle object * @see
        *
      • API Documentation
      • @@ -67,7 +80,7 @@ public ResponseObject getBundle(Long projectId, Long bundleId) throws Ht /** * @param projectId project identifier - * @param bundleId bundle identifier + * @param bundleId bundle identifier * @see
          *
        • API Documentation
        • *
        • Enterprise API Documentation
        • @@ -79,8 +92,8 @@ public void deleteBundle(Long projectId, Long bundleId) throws HttpException, Ht /** * @param projectId project identifier - * @param bundleId bundle identifier - * @param request request object + * @param bundleId bundle identifier + * @param request request object * @return updated bundle * @see
            *
          • API Documentation
          • @@ -94,9 +107,9 @@ public ResponseObject editBundle(Long projectId, Long bundleId, List *
          • API Documentation
          • @@ -114,8 +127,23 @@ public ResponseList listBundleFiles(Long projectId, Long bun /** * @param projectId project identifier - * @param bundleId bundle identifier - * @param exportId export identifier, consists of 36 characters + * @param bundleId bundle identifier + * @param limit maximum number of items to retrieve (default 25) + * @param offset starting offset in the collection (default 0) + */ + public ResponseList listBundleBranches(Long projectId, Long bundleId, Integer limit, Integer offset) throws HttpException, HttpBadRequestException { + Map> queryParams = HttpRequestConfig.buildUrlParams( + "limit", Optional.ofNullable(limit), + "offset", Optional.ofNullable(offset) + ); + BranchResponseList response = this.httpClient.get(this.url + "/projects/" + projectId + "/bundles/" + bundleId + "/branches", new HttpRequestConfig(queryParams), BranchResponseList.class); + return BranchResponseList.to(response); + } + + /** + * @param projectId project identifier + * @param bundleId bundle identifier + * @param exportId export identifier, consists of 36 characters * @return download link to bundle * @see
              *
            • API Documentation
            • @@ -132,7 +160,7 @@ public ResponseObject downloadBundle(Long projectId, Long bundleId /** * @param projectId project identifier - * @param bundleId bundle identifier + * @param bundleId bundle identifier * @return freshly created bundle export object * @see
                *
              • API Documentation
              • @@ -149,8 +177,8 @@ public ResponseObject exportBundle(Long projectId, Long bundleId) /** * @param projectId project identifier - * @param bundleId bundle identifier - * @param exportId export identifier, consists of 36 characters + * @param bundleId bundle identifier + * @param exportId export identifier, consists of 36 characters * @return requested bundle export object * @see
                  *
                • API Documentation
                • diff --git a/src/main/java/com/crowdin/client/bundles/model/Bundle.java b/src/main/java/com/crowdin/client/bundles/model/Bundle.java index 32d9a49fa..cea8ffea4 100644 --- a/src/main/java/com/crowdin/client/bundles/model/Bundle.java +++ b/src/main/java/com/crowdin/client/bundles/model/Bundle.java @@ -17,6 +17,7 @@ public class Bundle { private boolean isMultilingual; private Boolean includeProjectSourceLanguage; private List labelIds; + private List excludeLabelIds; private Date createdAt; private Date updatedAt; } diff --git a/src/main/java/com/crowdin/client/clients/ClientsApi.java b/src/main/java/com/crowdin/client/clients/ClientsApi.java new file mode 100644 index 000000000..893be1ad1 --- /dev/null +++ b/src/main/java/com/crowdin/client/clients/ClientsApi.java @@ -0,0 +1,41 @@ +package com.crowdin.client.clients; + +import com.crowdin.client.clients.model.Client; +import com.crowdin.client.clients.model.ClientResponseList; +import com.crowdin.client.core.CrowdinApi; +import com.crowdin.client.core.http.HttpRequestConfig; +import com.crowdin.client.core.http.exceptions.HttpBadRequestException; +import com.crowdin.client.core.http.exceptions.HttpException; +import com.crowdin.client.core.model.ClientConfig; +import com.crowdin.client.core.model.Credentials; +import com.crowdin.client.core.model.ResponseList; + +import java.util.Map; +import java.util.Optional; + +public class ClientsApi extends CrowdinApi { + public ClientsApi(Credentials credentials) { + super(credentials); + } + + public ClientsApi(Credentials credentials, ClientConfig clientConfig) { + super(credentials, clientConfig); + } + + /** + * @param limit maximum number of items to retrieve (default 25) + * @param offset starting offset in the collection (default 0) + * @return list of vendors + * @see + */ + public ResponseList listClients(Integer limit, Integer offset) throws HttpException, HttpBadRequestException { + Map> queryParams = HttpRequestConfig.buildUrlParams( + "limit", Optional.ofNullable(limit), + "offset", Optional.ofNullable(offset) + ); + ClientResponseList vendorResponseList = this.httpClient.get(this.url + "/clients", new HttpRequestConfig(queryParams), ClientResponseList.class); + return ClientResponseList.to(vendorResponseList); + } +} diff --git a/src/main/java/com/crowdin/client/clients/model/Client.java b/src/main/java/com/crowdin/client/clients/model/Client.java new file mode 100644 index 000000000..2b6dc69e1 --- /dev/null +++ b/src/main/java/com/crowdin/client/clients/model/Client.java @@ -0,0 +1,12 @@ +package com.crowdin.client.clients.model; + +import lombok.Data; + +@Data +public class Client { + + private Long id; + private String name; + private String description; + private Status status; +} diff --git a/src/main/java/com/crowdin/client/clients/model/ClientResponseList.java b/src/main/java/com/crowdin/client/clients/model/ClientResponseList.java new file mode 100644 index 000000000..89722bba7 --- /dev/null +++ b/src/main/java/com/crowdin/client/clients/model/ClientResponseList.java @@ -0,0 +1,26 @@ +package com.crowdin.client.clients.model; + +import com.crowdin.client.core.model.Pagination; +import com.crowdin.client.core.model.ResponseList; +import com.crowdin.client.core.model.ResponseObject; +import lombok.Data; + +import java.util.List; +import java.util.stream.Collectors; + +@Data +public class ClientResponseList { + + private List data; + private Pagination pagination; + + public static ResponseList to(ClientResponseList vendorResponseList) { + return ResponseList.of( + vendorResponseList.getData().stream() + .map(ClientResponseObject::getData) + .map(ResponseObject::of) + .collect(Collectors.toList()), + vendorResponseList.getPagination() + ); + } +} diff --git a/src/main/java/com/crowdin/client/clients/model/ClientResponseObject.java b/src/main/java/com/crowdin/client/clients/model/ClientResponseObject.java new file mode 100644 index 000000000..a0c9b54e9 --- /dev/null +++ b/src/main/java/com/crowdin/client/clients/model/ClientResponseObject.java @@ -0,0 +1,9 @@ +package com.crowdin.client.clients.model; + +import lombok.Data; + +@Data +public class ClientResponseObject { + + private Client data; +} diff --git a/src/main/java/com/crowdin/client/clients/model/Status.java b/src/main/java/com/crowdin/client/clients/model/Status.java new file mode 100644 index 000000000..bae0d1433 --- /dev/null +++ b/src/main/java/com/crowdin/client/clients/model/Status.java @@ -0,0 +1,17 @@ +package com.crowdin.client.clients.model; + +import com.crowdin.client.core.model.EnumConverter; + +public enum Status implements EnumConverter { + + PENDING, CONFIRMED, REJECTED; + + public static Status from(String value) { + return Status.valueOf(value.toUpperCase()); + } + + @Override + public String to(Status v) { + return v.name().toLowerCase(); + } +} diff --git a/src/main/java/com/crowdin/client/core/http/impl/json/FileFormatSettingsDeserializer.java b/src/main/java/com/crowdin/client/core/http/impl/json/FileFormatSettingsDeserializer.java index 1872f5c26..71e15355b 100644 --- a/src/main/java/com/crowdin/client/core/http/impl/json/FileFormatSettingsDeserializer.java +++ b/src/main/java/com/crowdin/client/core/http/impl/json/FileFormatSettingsDeserializer.java @@ -51,6 +51,9 @@ public FileFormatSettingsResource deserialize(JsonParser parser, Deserialization case "mdxV1": classToUse = MdxV1FileFormatSettings.class; break; + case "mdxV2": + classToUse = MdxV2FileFormatSettings.class; + break; case "fmMd": classToUse = FmMdFileFormatSettings.class; break; @@ -81,6 +84,9 @@ public FileFormatSettingsResource deserialize(JsonParser parser, Deserialization case "json": classToUse = JsonFileFormatSettings.class; break; + case "js": + classToUse = JavaScriptFileFormatSettings.class; + break; case "fjs": classToUse = FJSFileFormatSettings.class; break; diff --git a/src/main/java/com/crowdin/client/distributions/DistributionsApi.java b/src/main/java/com/crowdin/client/distributions/DistributionsApi.java index fec0b9fa2..6dab76d0a 100644 --- a/src/main/java/com/crowdin/client/distributions/DistributionsApi.java +++ b/src/main/java/com/crowdin/client/distributions/DistributionsApi.java @@ -10,11 +10,14 @@ import com.crowdin.client.core.model.ResponseList; import com.crowdin.client.core.model.ResponseObject; import com.crowdin.client.distributions.model.AddDistributionRequest; +import com.crowdin.client.distributions.model.AddDistributionStringsBasedRequest; import com.crowdin.client.distributions.model.Distribution; import com.crowdin.client.distributions.model.DistributionRelease; import com.crowdin.client.distributions.model.DistributionReleaseResponseObject; import com.crowdin.client.distributions.model.DistributionResponseList; import com.crowdin.client.distributions.model.DistributionResponseObject; +import com.crowdin.client.distributions.model.DistributionStringsBasedRelease; +import com.crowdin.client.distributions.model.DistributionStringsBasedReleaseResponseObject; import java.util.List; import java.util.Map; @@ -32,8 +35,8 @@ public DistributionsApi(Credentials credentials, ClientConfig clientConfig) { /** * @param projectId project identifier - * @param limit maximum number of items to retrieve (default 25) - * @param offset starting offset in the collection (default 0) + * @param limit maximum number of items to retrieve (default 25) + * @param offset starting offset in the collection (default 0) * @return list of distributions * @see
                    *
                  • API Documentation
                  • @@ -51,7 +54,7 @@ public ResponseList listDistributions(Long projectId, Integer limi /** * @param projectId project identifier - * @param request request object + * @param request request object * @return newly created distribution * @see
                      *
                    • API Documentation
                    • @@ -63,9 +66,14 @@ public ResponseObject addDistribution(Long projectId, AddDistribut return ResponseObject.of(distributionResponseObject.getData()); } + public ResponseObject addDistributionStringsBased(Long projectId, AddDistributionStringsBasedRequest request) throws HttpException, HttpBadRequestException { + DistributionResponseObject distributionResponseObject = this.httpClient.post(this.url + "/projects/" + projectId + "/distributions", request, new HttpRequestConfig(), DistributionResponseObject.class); + return ResponseObject.of(distributionResponseObject.getData()); + } + /** * @param projectId project identifier - * @param hash hash + * @param hash hash * @return distribution * @see
                        *
                      • API Documentation
                      • @@ -79,7 +87,7 @@ public ResponseObject getDistribution(Long projectId, String hash) /** * @param projectId project identifier - * @param hash hash + * @param hash hash * @see
                          *
                        • API Documentation
                        • *
                        • Enterprise API Documentation
                        • @@ -91,8 +99,8 @@ public void deleteDistribution(Long projectId, String hash) throws HttpException /** * @param projectId project identifier - * @param hash hash - * @param request request object + * @param hash hash + * @param request request object * @return updated distribution * @see
                            *
                          • API Documentation
                          • @@ -106,7 +114,7 @@ public ResponseObject editDistribution(Long projectId, String hash /** * @param projectId project identifier - * @param hash hash + * @param hash hash * @return distribution release * @see
                              *
                            • API Documentation
                            • @@ -118,9 +126,14 @@ public ResponseObject getDistributionRelease(Long projectId return ResponseObject.of(distributionReleaseResponseObject.getData()); } + public ResponseObject getDistributionStringsBasedRelease(Long projectId, String hash) throws HttpException, HttpBadRequestException { + DistributionStringsBasedReleaseResponseObject distributionReleaseResponseObject = this.httpClient.get(this.url + "/projects/" + projectId + "/distributions/" + hash + "/release", new HttpRequestConfig(), DistributionStringsBasedReleaseResponseObject.class); + return ResponseObject.of(distributionReleaseResponseObject.getData()); + } + /** * @param projectId project identifier - * @param hash hash + * @param hash hash * @return distribution release * @see
                                *
                              • API Documentation
                              • @@ -129,8 +142,15 @@ public ResponseObject getDistributionRelease(Long projectId */ public ResponseObject createDistributionRelease(Long projectId, String hash) throws HttpException, HttpBadRequestException { DistributionReleaseResponseObject distributionReleaseResponseObject = this.httpClient.post(this.url + - "/projects/" + projectId + "/distributions/" + hash + "/release", new DistributionRelease(), new HttpRequestConfig(), + "/projects/" + projectId + "/distributions/" + hash + "/release", new DistributionRelease(), new HttpRequestConfig(), DistributionReleaseResponseObject.class); return ResponseObject.of(distributionReleaseResponseObject.getData()); } + + public ResponseObject createDistributionStringsBasedRelease(Long projectId, String hash) throws HttpException, HttpBadRequestException { + DistributionStringsBasedReleaseResponseObject distributionReleaseResponseObject = this.httpClient.post(this.url + + "/projects/" + projectId + "/distributions/" + hash + "/release", new DistributionStringsBasedRelease(), new HttpRequestConfig(), + DistributionStringsBasedReleaseResponseObject.class); + return ResponseObject.of(distributionReleaseResponseObject.getData()); + } } diff --git a/src/main/java/com/crowdin/client/distributions/model/AddDistributionStringsBasedRequest.java b/src/main/java/com/crowdin/client/distributions/model/AddDistributionStringsBasedRequest.java new file mode 100644 index 000000000..4bce7a35f --- /dev/null +++ b/src/main/java/com/crowdin/client/distributions/model/AddDistributionStringsBasedRequest.java @@ -0,0 +1,11 @@ +package com.crowdin.client.distributions.model; + +import lombok.Data; + +import java.util.List; + +@Data +public class AddDistributionStringsBasedRequest { + private String name; + private List bundleIds; +} diff --git a/src/main/java/com/crowdin/client/distributions/model/DistributionStringsBasedRelease.java b/src/main/java/com/crowdin/client/distributions/model/DistributionStringsBasedRelease.java new file mode 100644 index 000000000..047229a1e --- /dev/null +++ b/src/main/java/com/crowdin/client/distributions/model/DistributionStringsBasedRelease.java @@ -0,0 +1,14 @@ +package com.crowdin.client.distributions.model; + +import lombok.Data; + +import java.util.Date; + +@Data +public class DistributionStringsBasedRelease { + private String status; + private Integer progress; + private String currentLanguageId; + private Long currentBranchId; + private Date date; +} diff --git a/src/main/java/com/crowdin/client/distributions/model/DistributionStringsBasedReleaseResponseObject.java b/src/main/java/com/crowdin/client/distributions/model/DistributionStringsBasedReleaseResponseObject.java new file mode 100644 index 000000000..aaefdc4f1 --- /dev/null +++ b/src/main/java/com/crowdin/client/distributions/model/DistributionStringsBasedReleaseResponseObject.java @@ -0,0 +1,9 @@ +package com.crowdin.client.distributions.model; + +import lombok.Data; + +@Data +public class DistributionStringsBasedReleaseResponseObject { + + private DistributionStringsBasedRelease data; +} diff --git a/src/main/java/com/crowdin/client/labels/LabelsApi.java b/src/main/java/com/crowdin/client/labels/LabelsApi.java index e91fc37c1..a9573a981 100644 --- a/src/main/java/com/crowdin/client/labels/LabelsApi.java +++ b/src/main/java/com/crowdin/client/labels/LabelsApi.java @@ -4,6 +4,7 @@ import com.crowdin.client.core.http.HttpRequestConfig; import com.crowdin.client.core.http.exceptions.HttpBadRequestException; import com.crowdin.client.core.http.exceptions.HttpException; +import com.crowdin.client.core.model.BooleanInt; import com.crowdin.client.core.model.ClientConfig; import com.crowdin.client.core.model.Credentials; import com.crowdin.client.core.model.PatchRequest; @@ -39,17 +40,19 @@ public LabelsApi(Credentials credentials, ClientConfig clientConfig) { * @param projectId Project Identifier * @param limit A maximum number of items to retrieve. Default: 25 * @param offset A starting offset in the collection. Default: 0 + * @param isSystem Filter collection by isSystem value * @return list of labels * @see */ - public ResponseList
                              */ - public ResponseList getLanguageProgress(Long projectId, String languageId, Integer limit, Integer offset) throws HttpException, HttpBadRequestException { + public ResponseList getLanguageProgress(Long projectId, String languageId, Integer limit, Integer offset) throws HttpException, HttpBadRequestException { Map> queryParams = HttpRequestConfig.buildUrlParams( "limit", Optional.ofNullable(limit), "offset", Optional.ofNullable(offset) diff --git a/src/main/java/com/crowdin/client/translationstatus/model/FileProgress.java b/src/main/java/com/crowdin/client/translationstatus/model/FileBranchProgress.java similarity index 55% rename from src/main/java/com/crowdin/client/translationstatus/model/FileProgress.java rename to src/main/java/com/crowdin/client/translationstatus/model/FileBranchProgress.java index ee070260b..1d3f37472 100644 --- a/src/main/java/com/crowdin/client/translationstatus/model/FileProgress.java +++ b/src/main/java/com/crowdin/client/translationstatus/model/FileBranchProgress.java @@ -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; } diff --git a/src/main/java/com/crowdin/client/translationstatus/model/FileProgressResponseList.java b/src/main/java/com/crowdin/client/translationstatus/model/FileProgressResponseList.java index 87bc1d3a6..a07e5f84a 100644 --- a/src/main/java/com/crowdin/client/translationstatus/model/FileProgressResponseList.java +++ b/src/main/java/com/crowdin/client/translationstatus/model/FileProgressResponseList.java @@ -14,7 +14,7 @@ public class FileProgressResponseList { private List data; private Pagination pagination; - public static ResponseList to(FileProgressResponseList fileProgressResponseList) { + public static ResponseList to(FileProgressResponseList fileProgressResponseList) { return ResponseList.of( fileProgressResponseList.getData().stream() .map(FileProgressResponseObject::getData) diff --git a/src/main/java/com/crowdin/client/translationstatus/model/FileProgressResponseObject.java b/src/main/java/com/crowdin/client/translationstatus/model/FileProgressResponseObject.java index 565dbb2c9..11c00cd65 100644 --- a/src/main/java/com/crowdin/client/translationstatus/model/FileProgressResponseObject.java +++ b/src/main/java/com/crowdin/client/translationstatus/model/FileProgressResponseObject.java @@ -5,5 +5,5 @@ @Data public class FileProgressResponseObject { - private FileProgress data; + private FileBranchProgress data; } diff --git a/src/main/java/com/crowdin/client/translationstatus/model/LanguageProgress.java b/src/main/java/com/crowdin/client/translationstatus/model/LanguageProgress.java index c9e9a233c..2ccc3402e 100644 --- a/src/main/java/com/crowdin/client/translationstatus/model/LanguageProgress.java +++ b/src/main/java/com/crowdin/client/translationstatus/model/LanguageProgress.java @@ -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; @@ -10,4 +11,5 @@ public class LanguageProgress extends Progress { private String languageId; + private Language language; } diff --git a/src/main/java/com/crowdin/client/users/model/AddProjectMemberRequest.java b/src/main/java/com/crowdin/client/users/model/AddProjectMemberRequest.java index 990c6960f..b19496c9f 100644 --- a/src/main/java/com/crowdin/client/users/model/AddProjectMemberRequest.java +++ b/src/main/java/com/crowdin/client/users/model/AddProjectMemberRequest.java @@ -9,8 +9,17 @@ public class AddProjectMemberRequest { private List userIds; + private String usernames; + private List emails; + /** + * @deprecated + */ private Boolean accessToAllWorkflowSteps; private Boolean managerAccess; + private Boolean developerAccess; + /** + * @deprecated + */ private Map permissions; private List roles; } diff --git a/src/main/java/com/crowdin/client/users/model/ProjectMember.java b/src/main/java/com/crowdin/client/users/model/ProjectMember.java index 707471fa8..70a9fbecf 100644 --- a/src/main/java/com/crowdin/client/users/model/ProjectMember.java +++ b/src/main/java/com/crowdin/client/users/model/ProjectMember.java @@ -11,12 +11,24 @@ public class ProjectMember { private Long id; private String username; + private String fullName; private String firstName; private String lastName; + private String avatarUrl; private boolean isManager; + private boolean isDeveloper; private ManagerOfGroup managerOfGroup; + /** + * @deprecated + */ private boolean accessToAllWorkflowSteps; + /** + * @deprecated + */ private Map permissions; private List roles; - private Date lastSeen; + private String role; + private String timezone; + private Date joinedAt; + private Date givenAccessAt; } diff --git a/src/main/java/com/crowdin/client/users/model/ReplaceProjectMemberPermissionsRequest.java b/src/main/java/com/crowdin/client/users/model/ReplaceProjectMemberPermissionsRequest.java index 0cc11efa8..7235cd6eb 100644 --- a/src/main/java/com/crowdin/client/users/model/ReplaceProjectMemberPermissionsRequest.java +++ b/src/main/java/com/crowdin/client/users/model/ReplaceProjectMemberPermissionsRequest.java @@ -8,8 +8,14 @@ @Data public class ReplaceProjectMemberPermissionsRequest { + /** + * @deprecated + */ private Boolean accessToAllWorkflowSteps; private Boolean managerAccess; + /** + * @deprecated + */ private Map permissions; private List roles; } diff --git a/src/main/java/com/crowdin/client/users/model/TeamMember.java b/src/main/java/com/crowdin/client/users/model/TeamMember.java index f44784947..32d3d9dbe 100644 --- a/src/main/java/com/crowdin/client/users/model/TeamMember.java +++ b/src/main/java/com/crowdin/client/users/model/TeamMember.java @@ -3,6 +3,7 @@ import lombok.Data; import java.util.Date; +import java.util.List; import java.util.Map; @Data @@ -12,8 +13,12 @@ public class TeamMember { private String username; private String fullName; private String role; + /** + * @deprecated + */ private Map permissions; private String avatarUrl; private Date joinedAt; private String timezone; + private List roles; } diff --git a/src/main/java/com/crowdin/client/vendors/model/Status.java b/src/main/java/com/crowdin/client/vendors/model/Status.java new file mode 100644 index 000000000..7085b9420 --- /dev/null +++ b/src/main/java/com/crowdin/client/vendors/model/Status.java @@ -0,0 +1,16 @@ +package com.crowdin.client.vendors.model; + +import com.crowdin.client.core.model.EnumConverter; + +public enum Status implements EnumConverter { + PENDING, CONFIRMED, REJECTED; + + public static Status from(String value) { + return Status.valueOf(value.toUpperCase()); + } + + @Override + public String to(Status v) { + return v.name().toLowerCase(); + } +} diff --git a/src/main/java/com/crowdin/client/vendors/model/Vendor.java b/src/main/java/com/crowdin/client/vendors/model/Vendor.java index a76341559..fc7f7227f 100644 --- a/src/main/java/com/crowdin/client/vendors/model/Vendor.java +++ b/src/main/java/com/crowdin/client/vendors/model/Vendor.java @@ -8,5 +8,5 @@ public class Vendor { private Long id; private String name; private String description; - private String status; + private Status status; } diff --git a/src/main/java/com/crowdin/client/webhooks/model/AddWebhookRequest.java b/src/main/java/com/crowdin/client/webhooks/model/AddWebhookRequest.java index ffd3456af..7f96235b8 100644 --- a/src/main/java/com/crowdin/client/webhooks/model/AddWebhookRequest.java +++ b/src/main/java/com/crowdin/client/webhooks/model/AddWebhookRequest.java @@ -3,6 +3,7 @@ import lombok.Data; import java.util.List; +import java.util.Map; @Data public class AddWebhookRequest { @@ -14,6 +15,6 @@ public class AddWebhookRequest { private Boolean isActive; private Boolean batchingEnabled; private ContentType contentType; - private Object headers; + private Map headers; private Object payload; } diff --git a/src/main/java/com/crowdin/client/webhooks/model/Webhook.java b/src/main/java/com/crowdin/client/webhooks/model/Webhook.java index 0f2809e79..3f1031f1d 100644 --- a/src/main/java/com/crowdin/client/webhooks/model/Webhook.java +++ b/src/main/java/com/crowdin/client/webhooks/model/Webhook.java @@ -4,6 +4,7 @@ import java.util.Date; import java.util.List; +import java.util.Map; @Data public class Webhook { @@ -13,8 +14,8 @@ public class Webhook { private String name; private String url; private List events; - private List headers; - private List payload; + private Map headers; + private Object payload; private Boolean isActive; private Boolean batchingEnabled; private RequestType requestType; diff --git a/src/test/java/com/crowdin/client/applications/ApplicationsApiTest.java b/src/test/java/com/crowdin/client/applications/ApplicationsApiTest.java index ac255e653..c2c9c1729 100644 --- a/src/test/java/com/crowdin/client/applications/ApplicationsApiTest.java +++ b/src/test/java/com/crowdin/client/applications/ApplicationsApiTest.java @@ -1,10 +1,13 @@ package com.crowdin.client.applications; -import com.crowdin.client.applications.model.*; import com.crowdin.client.core.model.ResponseObject; import com.crowdin.client.framework.RequestMock; import com.crowdin.client.framework.TestClient; -import org.apache.http.client.methods.*; +import org.apache.http.client.methods.HttpDelete; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.client.methods.HttpPatch; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.client.methods.HttpPut; import org.junit.jupiter.api.Test; import java.util.Arrays; @@ -12,7 +15,8 @@ import java.util.List; import java.util.Map; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; class ApplicationsApiTest extends TestClient { @@ -33,18 +37,20 @@ public List getMocks() { @Test void getApplicationData() { - ResponseObject response = this.getApplicationsApi().getApplicationData(applicationIdentifier, path); + ResponseObject> response = this.getApplicationsApi().getApplicationData(applicationIdentifier, path); assertNotNull(response); + assertEquals(response.getData().get("customKey1"), "value"); + assertEquals(response.getData().get("customKey2"), "value"); } @Test void updateOrRestoreApplicationData() { Map applicationDataPayload = new HashMap<>(); applicationDataPayload.put("updateKey", "value"); - UpdateOrRestoreApplicationDataRequest updateOrRestoreApplicationDataRequest = new UpdateOrRestoreApplicationDataRequest(); - updateOrRestoreApplicationDataRequest.setData(applicationDataPayload); - ResponseObject response = this.getApplicationsApi().updateOrRestoreApplicationData(applicationIdentifier, path, updateOrRestoreApplicationDataRequest); + ResponseObject> response = this.getApplicationsApi().updateOrRestoreApplicationData(applicationIdentifier, path, applicationDataPayload); assertNotNull(response); + assertEquals(response.getData().get("customKey1"), "value"); + assertEquals(response.getData().get("customKey2"), "value"); } @Test @@ -52,10 +58,10 @@ void addApplicationData() { Map addApplicationDataPayload = new HashMap<>(); addApplicationDataPayload.put("Key1", "value"); addApplicationDataPayload.put("Key2", "value"); - AddApplicationDataRequest applicationDataRequest = new AddApplicationDataRequest(); - applicationDataRequest.setData(addApplicationDataPayload); - ResponseObject response = this.getApplicationsApi().addApplicationData(applicationIdentifier, path, applicationDataRequest); + ResponseObject> response = this.getApplicationsApi().addApplicationData(applicationIdentifier, path, addApplicationDataPayload); assertNotNull(response); + assertEquals(response.getData().get("customKey1"), "value"); + assertEquals(response.getData().get("customKey2"), "value"); } @Test @@ -67,10 +73,10 @@ void deleteApplicationData() { void editApplicationData() { Map request = new HashMap<>(); request.put("editKey", "editedValue"); - EditApplicationDataRequest editApplicationDataRequest = new EditApplicationDataRequest(); - editApplicationDataRequest.setData(request); - ResponseObject response = this.getApplicationsApi().editApplicationData(applicationIdentifier, path, editApplicationDataRequest); + ResponseObject> response = this.getApplicationsApi().editApplicationData(applicationIdentifier, path, request); assertNotNull(response); + assertEquals(response.getData().get("customKey1"), "value"); + assertEquals(response.getData().get("customKey2"), "value"); } -} \ No newline at end of file +} diff --git a/src/test/java/com/crowdin/client/bundles/BundlesApiTest.java b/src/test/java/com/crowdin/client/bundles/BundlesApiTest.java index 8738f8412..233e361c1 100644 --- a/src/test/java/com/crowdin/client/bundles/BundlesApiTest.java +++ b/src/test/java/com/crowdin/client/bundles/BundlesApiTest.java @@ -8,6 +8,7 @@ import com.crowdin.client.core.model.DownloadLink; import com.crowdin.client.framework.RequestMock; import com.crowdin.client.framework.TestClient; +import com.crowdin.client.sourcefiles.model.Branch; import com.crowdin.client.sourcefiles.model.File; import com.crowdin.client.sourcefiles.model.FileInfo; import org.apache.http.client.methods.HttpDelete; @@ -33,6 +34,9 @@ public class BundlesApiTest extends TestClient { private final Long bundleId = 14L; private final Long fileInfoCollectionResourceId = 44L; private final Long fileCollectionResourceId = 43L; + private final Long branchCollectionResourceId = 44L; + private final Long branchId = 45L; + private final String branchName = "dev"; private final String name = "Resx bundle"; private final String bundleResourceName = "umbrella_app.xliff"; private final String format = "crowdin-resx"; @@ -51,6 +55,7 @@ public List getMocks() { RequestMock.build(this.url + "/projects/" + projectId + "/bundles/" + bundleId, HttpPatch.METHOD_NAME, "api/bundles/editBundle.json", "api/bundles/bundle.json"), RequestMock.build(this.url + "/projects/" + projectId + "/bundles/" + fileInfoCollectionResourceId + "/files", HttpGet.METHOD_NAME, "api/bundles/fileInfoCollectionResource.json"), RequestMock.build(this.url + "/projects/" + projectId2 + "/bundles/" + fileCollectionResourceId + "/files", HttpGet.METHOD_NAME, "api/bundles/fileCollectionResource.json"), + RequestMock.build(this.url + "/projects/" + projectId2 + "/bundles/" + branchCollectionResourceId + "/branches", HttpGet.METHOD_NAME, "api/bundles/branchCollectionResource.json"), RequestMock.build(this.url + "/projects/" + projectId + "/bundles/" + bundleId + "/exports/" + exportId + "/download", HttpGet.METHOD_NAME, "api/bundles/downloadBundle.json"), RequestMock.build(this.url + "/projects/" + projectId + "/bundles/" + bundleId + "/exports", HttpPost.METHOD_NAME, "api/bundles/exportBundle.json"), RequestMock.build(this.url + "/projects/" + projectId + "/bundles/" + bundleId + "/exports/" + exportId, HttpGet.METHOD_NAME, "api/bundles/exportBundle.json") @@ -136,6 +141,15 @@ public void listFileCollectionResourceTest() { assertEquals(fileCollectionResourceResponse.getName(), bundleResourceName); } + @Test + public void listBranchCollectionResourceTest() { + ResponseList response = this.getBundlesApi().listBundleBranches(projectId2, branchCollectionResourceId, null,null); + Branch branch = response.getData().get(0).getData(); + assertTrue(branch instanceof Branch); + assertEquals(branch.getId(), branchId); + assertEquals(branch.getName(), branchName); + } + @Test public void downloadBundleTest() { TimeZone.setDefault(tz); diff --git a/src/test/java/com/crowdin/client/clients/ClientsApiTest.java b/src/test/java/com/crowdin/client/clients/ClientsApiTest.java new file mode 100644 index 000000000..87f21f7ee --- /dev/null +++ b/src/test/java/com/crowdin/client/clients/ClientsApiTest.java @@ -0,0 +1,36 @@ +package com.crowdin.client.clients; + +import com.crowdin.client.clients.model.Client; +import com.crowdin.client.clients.model.Status; +import com.crowdin.client.core.model.ResponseList; +import com.crowdin.client.framework.RequestMock; +import com.crowdin.client.framework.TestClient; +import org.apache.http.client.methods.HttpGet; +import org.junit.jupiter.api.Test; + +import java.util.List; + +import static java.util.Collections.singletonList; +import static org.junit.jupiter.api.Assertions.assertEquals; + +public class ClientsApiTest extends TestClient { + + private final Long clientId = 678L; + private final String name = "John Smith Translation Agency"; + + @Override + public List getMocks() { + return singletonList( + RequestMock.build(this.url + "/clients", HttpGet.METHOD_NAME, "api/clients/listClients.json") + ); + } + + @Test + public void listClientsTest() { + ResponseList clientResponseList = this.getClientsApi().listClients(null, null); + assertEquals(clientResponseList.getData().size(), 1); + assertEquals(clientResponseList.getData().get(0).getData().getId(), clientId); + assertEquals(clientResponseList.getData().get(0).getData().getName(), name); + assertEquals(clientResponseList.getData().get(0).getData().getStatus(), Status.PENDING); + } +} diff --git a/src/test/java/com/crowdin/client/distributions/DistributionsApiTest.java b/src/test/java/com/crowdin/client/distributions/DistributionsApiTest.java index 2f09fe08f..b621fe076 100644 --- a/src/test/java/com/crowdin/client/distributions/DistributionsApiTest.java +++ b/src/test/java/com/crowdin/client/distributions/DistributionsApiTest.java @@ -5,8 +5,10 @@ import com.crowdin.client.core.model.ResponseList; import com.crowdin.client.core.model.ResponseObject; import com.crowdin.client.distributions.model.AddDistributionRequest; +import com.crowdin.client.distributions.model.AddDistributionStringsBasedRequest; import com.crowdin.client.distributions.model.Distribution; import com.crowdin.client.distributions.model.DistributionRelease; +import com.crowdin.client.distributions.model.DistributionStringsBasedRelease; import com.crowdin.client.distributions.model.ExportMode; import com.crowdin.client.framework.RequestMock; import com.crowdin.client.framework.TestClient; @@ -25,19 +27,24 @@ public class DistributionsApiTest extends TestClient { private final Long projectId = 3L; + private final Long stringsBasedProjectId = 4L; private final String hash = "asccvfd"; private final String name = "distribution 1"; + private final String name2 = "distribution 2"; @Override public List getMocks() { return Arrays.asList( RequestMock.build(this.url + "/projects/" + projectId + "/distributions", HttpGet.METHOD_NAME, "api/distributions/listDistributions.json"), RequestMock.build(this.url + "/projects/" + projectId + "/distributions", HttpPost.METHOD_NAME, "api/distributions/addDistribution.json", "api/distributions/distribution.json"), + RequestMock.build(this.url + "/projects/" + stringsBasedProjectId + "/distributions", HttpPost.METHOD_NAME, "api/distributions/addDistributionStringsBased.json", "api/distributions/distribution.json"), RequestMock.build(this.url + "/projects/" + projectId + "/distributions/" + hash, HttpGet.METHOD_NAME, "api/distributions/distribution.json"), RequestMock.build(this.url + "/projects/" + projectId + "/distributions/" + hash, HttpDelete.METHOD_NAME), RequestMock.build(this.url + "/projects/" + projectId + "/distributions/" + hash, HttpPatch.METHOD_NAME, "api/distributions/editDistribution.json", "api/distributions/distribution.json"), RequestMock.build(this.url + "/projects/" + projectId + "/distributions/" + hash + "/release", HttpGet.METHOD_NAME, "api/distributions/release.json"), - RequestMock.build(this.url + "/projects/" + projectId + "/distributions/" + hash + "/release", HttpPost.METHOD_NAME, "api/distributions/releaseRequest.json", "api/distributions/release.json") + RequestMock.build(this.url + "/projects/" + projectId + "/distributions/" + hash + "/release", HttpPost.METHOD_NAME, "api/distributions/releaseRequest.json", "api/distributions/release.json"), + RequestMock.build(this.url + "/projects/" + stringsBasedProjectId + "/distributions/" + hash + "/release", HttpGet.METHOD_NAME, "api/distributions/releaseStringsBased.json"), + RequestMock.build(this.url + "/projects/" + stringsBasedProjectId + "/distributions/" + hash + "/release", HttpPost.METHOD_NAME, "api/distributions/releaseRequest.json", "api/distributions/releaseStringsBased.json") ); } @@ -62,6 +69,17 @@ public void addDistributionTest() { assertEquals(distributionResponseObject.getData().getExportMode(), "bundle"); } + @Test + public void addDistributionStringsBasedTest() { + AddDistributionStringsBasedRequest request = new AddDistributionStringsBasedRequest(); + request.setName(name2); + request.setBundleIds(Arrays.asList(1,2,3)); + ResponseObject distributionResponseObject = this.getDistributionsApi().addDistributionStringsBased(stringsBasedProjectId, request); + assertEquals(distributionResponseObject.getData().getHash(), hash); + assertEquals(distributionResponseObject.getData().getName(), name); + assertEquals(distributionResponseObject.getData().getExportMode(), "bundle"); + } + @Test public void getDistributionTest() { ResponseObject distributionResponseObject = this.getDistributionsApi().getDistribution(projectId, hash); @@ -91,9 +109,21 @@ public void getDistributionReleaseTest() { assertEquals(distributionRelease.getData().getProgress(), new Integer(100)); } + @Test + public void getDistributionReleaseStringsBasedTest() { + ResponseObject distributionRelease = this.getDistributionsApi().getDistributionStringsBasedRelease(stringsBasedProjectId, hash); + assertEquals(distributionRelease.getData().getProgress(), new Integer(100)); + } + @Test public void createDistributionReleaseTest() { ResponseObject distributionRelease = this.getDistributionsApi().createDistributionRelease(projectId, hash); assertEquals(distributionRelease.getData().getProgress(), new Integer(100)); } + + @Test + public void createDistributionReleaseStringsBasedTest() { + ResponseObject distributionRelease = this.getDistributionsApi().createDistributionStringsBasedRelease(stringsBasedProjectId, hash); + assertEquals(distributionRelease.getData().getProgress(), new Integer(100)); + } } diff --git a/src/test/java/com/crowdin/client/labels/LabelsApiTest.java b/src/test/java/com/crowdin/client/labels/LabelsApiTest.java index 0f2e684d7..985df4361 100644 --- a/src/test/java/com/crowdin/client/labels/LabelsApiTest.java +++ b/src/test/java/com/crowdin/client/labels/LabelsApiTest.java @@ -64,7 +64,7 @@ public List getMocks() { @Test public void listLabelsTest() { - ResponseList