Skip to content

Commit

Permalink
chore: update Crowdin API client to 1.11.0 (#626)
Browse files Browse the repository at this point in the history
  • Loading branch information
katerina20 committed Aug 28, 2023
1 parent 6887f03 commit 46fc50f
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 16 deletions.
5 changes: 3 additions & 2 deletions src/main/java/com/crowdin/cli/client/ClientBundle.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.crowdin.cli.client;

import com.crowdin.client.bundles.model.AddBundleRequest;
import com.crowdin.client.bundles.model.Bundle;
import com.crowdin.client.bundles.model.BundleExport;

Expand All @@ -11,13 +12,13 @@ public interface ClientBundle extends Client {

List<Bundle> listBundle();

Bundle addBundle(Bundle request);
Bundle addBundle(AddBundleRequest addBundleRequest);

Optional<Bundle> getBundle(Long id);

URL downloadBundle(Long id, String exportId);

BundleExport startExportingBundle(Long id, Bundle bundle);
BundleExport startExportingBundle(Long id);

BundleExport checkExportingBundle(Long tmId, String exportId);

Expand Down
9 changes: 5 additions & 4 deletions src/main/java/com/crowdin/cli/client/CrowdinClientBundle.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.crowdin.cli.client;


import com.crowdin.client.bundles.model.AddBundleRequest;
import com.crowdin.client.bundles.model.Bundle;
import com.crowdin.client.bundles.model.BundleExport;

Expand All @@ -24,9 +25,9 @@ public List<Bundle> listBundle() {
}

@Override
public Bundle addBundle(Bundle bundleRequest) {
public Bundle addBundle(AddBundleRequest addBundleRequest) {
return executeRequest(() -> this.client.getBundlesApi()
.addBundle(Long.valueOf(projectId), bundleRequest)
.addBundle(Long.valueOf(projectId), addBundleRequest)
.getData());
}

Expand All @@ -49,9 +50,9 @@ public URL downloadBundle(Long id, String exportId) {
}

@Override
public BundleExport startExportingBundle(Long id, Bundle bundle) {
public BundleExport startExportingBundle(Long id) {
return executeRequest(() -> this.client.getBundlesApi()
.exportBundle(Long.valueOf(projectId), id, bundle)
.exportBundle(Long.valueOf(projectId), id)
.getData());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.crowdin.cli.commands.NewAction;
import com.crowdin.cli.commands.Outputter;
import com.crowdin.cli.properties.ProjectProperties;
import com.crowdin.client.bundles.model.AddBundleRequest;
import com.crowdin.client.bundles.model.Bundle;
import lombok.AllArgsConstructor;

Expand Down Expand Up @@ -33,7 +34,7 @@ class BundleAddAction implements NewAction<ProjectProperties, ClientBundle> {
@Override
public void act(Outputter out, ProjectProperties pb, ClientBundle client) {
Bundle bundle;
Bundle addBundleRequest = new Bundle();
AddBundleRequest addBundleRequest = new AddBundleRequest();
Optional.ofNullable(name).ifPresent(addBundleRequest::setName);
Optional.ofNullable(format).ifPresent(addBundleRequest::setFormat);
Optional.ofNullable(source).ifPresent(addBundleRequest::setSourcePatterns);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public DownloadBundleAction(Long id, FilesInterface files, boolean plainView, bo
public void act(Outputter out, ProjectProperties pb, ClientBundle client) {
this.out = out;
Bundle bundle = getBundle(client);
BundleExport status = this.buildBundle(out, client, bundle.getId(), bundle);
BundleExport status = this.buildBundle(out, client, bundle.getId());
to = new File("bundle-" + status.getIdentifier() + ".zip");
downloadBundle(client, bundle.getId(), status.getIdentifier());
out.println(OK.withIcon(String.format(RESOURCE_BUNDLE.getString("message.bundle.download_success"), bundle.getId(), bundle.getName())));
Expand Down Expand Up @@ -78,15 +78,15 @@ private Bundle getBundle(ClientBundle client) {
.orElseThrow(() -> new RuntimeException(RESOURCE_BUNDLE.getString("error.bundle.not_found_by_id")));
}

private BundleExport buildBundle(Outputter out, ClientBundle client, Long bundleId, Bundle request) {
private BundleExport buildBundle(Outputter out, ClientBundle client, Long bundleId) {
return ConsoleSpinner.execute(
out,
"message.spinner.building_bundle",
"error.bundle.build_bundle",
this.noProgress,
false,
() -> {
BundleExport status = client.startExportingBundle(bundleId, request);
BundleExport status = client.startExportingBundle(bundleId);

while (!status.getStatus().equalsIgnoreCase("finished")) {
ConsoleSpinner.update(String.format(RESOURCE_BUNDLE.getString("message.spinner.building_bundle_percents"), status.getProgress()));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.crowdin.cli.client;

import com.crowdin.client.bundles.model.AddBundleRequest;
import com.crowdin.client.bundles.model.Bundle;
import com.crowdin.client.bundles.model.BundleResponseList;
import com.crowdin.client.bundles.model.BundleResponseObject;
Expand Down Expand Up @@ -63,7 +64,7 @@ public void testAddBundle() {
when(httpClientMock.post(eq(addBundleUrl), any(), any(), eq(BundleResponseObject.class)))
.thenReturn(response);

client.addBundle(new Bundle());
client.addBundle(new AddBundleRequest());

verify(httpClientMock).post(eq(addBundleUrl), any(), any(), eq(BundleResponseObject.class));
verifyNoMoreInteractions(httpClientMock);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import com.crowdin.cli.properties.PropertiesWithFiles;
import com.crowdin.cli.utils.Utils;

import com.crowdin.client.bundles.model.AddBundleRequest;
import com.crowdin.client.bundles.model.Bundle;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
Expand Down Expand Up @@ -36,7 +37,7 @@ public void testBundleAdd(String name, String format, List<String> source, List<
.setBasePath(Utils.PATH_SEPARATOR);
PropertiesWithFiles pb = pbBuilder.build();

Bundle request = new Bundle();
AddBundleRequest request = new AddBundleRequest();
request.setName(name);
request.setFormat(format);
request.setExportPattern(translation);
Expand Down Expand Up @@ -74,7 +75,7 @@ public void testAddBundleThrows() {
PropertiesWithFiles pb = pbBuilder.build();
ClientBundle client = mock(ClientBundle.class);

Bundle request = new Bundle();
AddBundleRequest request = new AddBundleRequest();
request.setName("");
request.setFormat("");
request.setExportPattern(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public void testDownloadBundle() {
when(client.getBundle(bundle.getId()))
.thenReturn(Optional.of(bundle));

when(client.startExportingBundle(bundle.getId(), bundle))
when(client.startExportingBundle(bundle.getId()))
.thenReturn(export);

FilesInterface files = mock(FilesInterface.class);
Expand All @@ -67,7 +67,7 @@ public void testDownloadBundle() {
action.act(Outputter.getDefault(), pb, client);

verify(client).getBundle(bundle.getId());
verify(client).startExportingBundle(bundle.getId(), bundle);
verify(client).startExportingBundle(bundle.getId());
verify(client).downloadBundle(bundle.getId(), null);
verifyNoMoreInteractions(client);
}
Expand Down
2 changes: 1 addition & 1 deletion versions.properties
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ version.com.h3xstream.findsecbugs..findsecbugs-plugin=1.12.0

version.com.github.fge..json-patch=1.13

version.com.github.crowdin..crowdin-api-client-java=1.6.2
version.com.github.crowdin..crowdin-api-client-java=1.11.0

plugin.org.asciidoctor.jvm.convert=3.3.2

Expand Down

0 comments on commit 46fc50f

Please sign in to comment.