Giter Club home page Giter Club logo

crowdin-api-client-java's People

Contributors

akashpambhar avatar andrii-bodnar avatar aveti79 avatar besomhead avatar decarteadam avatar dependabot[bot] avatar durdush avatar frombetelgeuse avatar imraklr avatar innomaxx avatar jsoref avatar katelynkunzmann avatar katerina20 avatar kvaithin avatar mesutgk15 avatar mitrofmep avatar mrandersonn avatar mslowiak avatar nazar-1 avatar pickbas avatar s-alman avatar sabarish98 avatar samantatarun avatar sebaszjuh avatar sugan0tech avatar svetvalkov avatar thc202 avatar volodymyr95 avatar yevheniyj avatar yzerk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

crowdin-api-client-java's Issues

New source files Import Options

Crowdin Rest API Add File and Update or Restore File now support new ImportOptions types:

  • Html File Import Options
  • Html with Front Matter File Import Options
  • Mdx v1 File Import Options

These new Import Options should be added to this API client as well as the corresponding unit tests.

File ImportOptions improvements

We've added new possible import options for files:

  • Add File: new ImportOptions possible value - Docx File Import Options (including the response)

  • Update or Restore File: new ImportOptions possible value - Docx File Import Options (including the response)

  • Edit File: new /importOptions/* path parameters

So these changes should be reflected in this API Client.

Get 403 (Forbidden) while calling `com.crowdin.client.teams.TeamsApi.listTeams(TeamsApi.java:56)`

HttpException(error=HttpException.Error(code=403, message=Forbidden))
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
at com.fasterxml.jackson.databind.introspect.AnnotatedConstructor.call(AnnotatedConstructor.java:119)
at com.fasterxml.jackson.databind.deser.std.StdValueInstantiator.createUsingDefault(StdValueInstantiator.java:270)
at com.fasterxml.jackson.databind.deser.std.ThrowableDeserializer.deserializeFromObject(ThrowableDeserializer.java:149)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:164)
at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4526)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3468)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3436)
at com.crowdin.client.core.http.impl.json.CrowdinApiExceptionDeserializer.deserialize(CrowdinApiExceptionDeserializer.java:35)
at com.crowdin.client.core.http.impl.json.CrowdinApiExceptionDeserializer.deserialize(CrowdinApiExceptionDeserializer.java:17)
at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4526)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3468)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3436)
at com.crowdin.client.core.http.impl.json.JacksonJsonTransformer.parse(JacksonJsonTransformer.java:60)
at com.playtika.services.infra.translation.service.crowdin.http.ApacheHttpClient.request(ApacheHttpClient.java:91)
at com.playtika.services.infra.translation.service.crowdin.http.ApacheHttpClient.get(ApacheHttpClient.java:53)
at com.crowdin.client.teams.TeamsApi.listTeams(TeamsApi.java:56)

Bad crowdin api url

There is a dot before url in CrowdinApi class -> line 46
if (credentials.getOrganization() != null) { this.url = "https://" + credentials.getOrganization() + ".api.crowdin.com/api/v2"; } else { this.url = "https://api.crowdin.com/api/v2"; }

XmlFileImportOptions deserialization issue

XmlFileImportOptions contains field translatableElements.
In java com.crowdin.client.sourcefiles.model.XmlFileImportOptions it is represented as a list of Strings.
However, the api returns it as a key-value map what cause exception in deserialization.

Remove `limit` and `offset` parameters from `listWorkflowSteps` method

Crowdin returns error if I try to pass limit and offset
AFAIK Crowdin doesn't need them anymore.

public ResponseList<WorkflowStep> listWorkflowSteps(Long projectId, Integer limit, Integer offset) throws HttpException, HttpBadRequestException {
        Map<String, Optional<Integer>> queryParams = HttpRequestConfig.buildUrlParams("limit", Optional.ofNullable(limit), "offset", Optional.ofNullable(offset));
        WorkflowStepResponseList workflowStepResponseList = (WorkflowStepResponseList)this.httpClient.get(this.url + "/projects/" + projectId + "/workflow-steps", new HttpRequestConfig(queryParams), WorkflowStepResponseList.class);
        return WorkflowStepResponseList.to(workflowStepResponseList);
    }

Bad named object and wrong param

the object : ExportPrjoectTranslationRequest are bad named and in the object there is :
private String targetLanguageId; private String format; private List<Long> branchIds; private List<Long> directoryIds; private List<Long> fileIds; private Boolean skipUntranslatedStrings; private Boolean skipUntranslatedFiles; private Integer exportWithMinApprovalsCount;

But on the reference API v2 this is exportApprovedOnly instead exportWithMinApprovalsCount

Because when the client send request, it throw exception because
"errors": [ { "code": "notFound", "message": "Field 'exportWithMinApprovalsCount' Not Found" }

Distributions API changes

The Distribution creation API has been changed. Now you can create a distribution with the following parameters:

  • bundleIds - array of bundle ids

The following parameters have been deprecated:

  • format
  • exportPattern
  • labelIds

A Distribution response has also been changed. Now it contains the bundleIds field. The format, exportPattern, and labelIds fields are deprecated.

In addition, the fileIds request parameter is now optional.

All the changes are described in the API documentation.

Glossaries API updates

We're happy to announce a significant update for Crowdin Glossaries that allows managing the terminology in a more advanced way.

There are a lot of new things and some changes in the Crowdin API.

New APIs:

Updates:

The translationOfTermId is deprecated and the conceptId added in:

Edit Term - new path options

All of these changes should be reflected in this API Client.

Auto generated docs

As a Crowdin Java API client user, I would like to have online docs to navigate and explore the client resources, methods, parameters, etc.

Examples:

These docs should be generated using GH Actions and deployed to GH Pages. Workflow example: docs.yml

The possible tool for that is javadoc.

Steps:

  • Explore tools to generate such docs, and choose the best one.
  • Create a config and provide a command to generate the docs.
  • If needed, add additional annotations to the API Client code (ignore some unneeded methods in docs, add some method or parameters descriptions, etc).
  • Setup the GH workflow. @andrii-bodnar can help with that.
  • Setup the GH pages feature for the repo. @andrii-bodnar

Cannot construct instance of LanguagePermission in getProjectMember

While using this snippet:

    @Test
    fun testCrash() {
        val baseUrl = "https://translate.loophabits.org"
        val t = "YOUR_OWN_TOKEN"
        val organization = "loop-habit-tracker-api-test"
        val credentials = Credentials(t, organization, baseUrl)
        val client = Client(credentials)
        client.usersApi.getProjectMember(440668L, 14614530L)
    }

I get the following error:

HttpException(error=HttpException.Error(code=null, message=Cannot construct instance of `com.crowdin.client.users.model.LanguagePermission` (although at least one Creator exists): no String-argument constructor/factory method to deserialize from String value ('translator')
 at [Source: (String)"{"data":{"id":14614530,"username":"hiq2","fullName":"Quentin","role":"translator","permissions":{"tw":"translator","ar-BH":"translator","lg":"translator"},"avatarUrl":"https:\/\/crowdin-static.downloads.crowdin.com\/avatar\/14614530\/medium\/bb2591b51932e79e834e744523e847ba.png","joinedAt":"2021-02-08T09:27:24+00:00","timezone":"Europe\/Zurich"}}"; line: 1, column: 103] (through reference chain: com.crowdin.client.users.model.ProjectMemberResponseObject["data"]->com.crowdin.client.users.model.ProjectMember["permissions"]->java.util.LinkedHashMap["tw"])))
	at com.crowdin.client.core.http.exceptions.HttpException.fromMessage(HttpException.java:22)
	at com.crowdin.client.core.http.impl.http.ApacheHttpClient.request(ApacheHttpClient.java:132)
	at com.crowdin.client.core.http.impl.http.ApacheHttpClient.get(ApacheHttpClient.java:76)
	at com.crowdin.client.users.UsersApi.getProjectMember(UsersApi.java:52)

I'm interested in these permissions: I want to get the list of project members and which languages they translated, so that I can give them proper credit.

I'm using the latest version of the API client library (1.3.3).

Full usage sample?

In my project I got a "lang" folder with the files messages.txt (english original) and messages_de.txt which follow the Java properties format. I want to use crowdin to upload those files and download versions for other languages.

Please add documentation how to use the SDK to do this.

Exception while accessing project build

Using version 1.1.2.

Steps to reproduce the issue:

  1. Trigger a project build:
Long projectId = ...; // Valid project ID.
Credentials credentials = ...; // Valid credentials.
new Client(credentials).getTranslationsApi().buildProjectTranslation(projectId, new BuildProjectTranslationRequest());

(Let me know if you need the project ID used.)
2. Note that it fails with an exception:

HttpException(error=HttpException.Error(code=null, message=Cannot deserialize instance of `java.util.ArrayList` out of START_OBJECT token
 at [Source: (String)"{"data":{"id":1,"projectId":1234,"status":"inProgress","progress":0,"attributes":{"branchId":null,"targetLanguageIds":[],"exportTranslatedOnly":false,"skipUntranslatedFiles":false,"exportApprovedOnly":false}}}"; line: 1, column: 82] (through reference chain: com.crowdin.client.translations.model.ProjectBuildResponseObject["data"]->com.crowdin.client.translations.model.ProjectBuild["attributes"])))
  1. Attempting to use checkBuildStatus or listProjectBuilds will also result in a similar exception.

I'm not sure if this is a client issue or a server one, the API definition says that those API endpoints return a project build with a list of attributes but the server is currently just returning a single attribute (i.e. an object instead of a list). Is the client/API definition that's incorrect or the server should be really returning a list?

Translation Status: new `preTranslateAppliedTo` field in Progress API Methods' response

Crowdin has recently enhanced its response for the Progress API Methods:

For example:

{
  "data": [
    {
      "data": {
        "words": {
          "total": 7249,
          "translated": 3651,
+          "preTranslateAppliedTo": 1254,
          "approved": 3637
        },
        "phrases": {
          "total": 3041,
          "translated": 2631,
+          "preTranslateAppliedTo": 1254,
          "approved": 2622
        },
        "translationProgress": 86,
        "approvalProgress": 86,
        "languageId": "af"
      }
    }
  ],
  "pagination": {
    "offset": 0,
    "limit": 25
  }
}

The response of these methods now contains a new field preTranslateAppliedTo in the words and phrases objects.

These new fields should also be reflected in this API Client.

Task Settings Templates API support

Add the JavaScript File Export Options

Crowdin recently added the ability to configure the export options for JavaScript files. This is a great feature, but it's not yet supported by the API Client.

  • exportPattern - string, File export pattern. Defines file name and path in resulting translations bundle.
  • exportQuotes - string enum single or double. Defines quotes to be used in resulting translations bundle.

The new options need to be added to this API Client.

API Reference:

addTag method inconsistent to API

In API add tags endpoint accepts array of tags

[
  {
    "stringId": 0,
    "position": {}
  }
]

but client sends single object

public ResponseObject<Tag> addTag(Long projectId, Long screenshotId, AddTagRequest request) throws HttpException, HttpBadRequestException {
        TagResponseObject tagResponseObject = (TagResponseObject)this.httpClient.post(this.url + "/projects/" + projectId + "/screenshots/" + screenshotId + "/tags", request, new HttpRequestConfig(), TagResponseObject.class);
        return ResponseObject.of(tagResponseObject.getData());
    }

and thus we get error

HttpBadRequestException.Error(code=data, message=Expects each item in a collection to be an array or Traversable, integer provided)]

Bug: Wrong date is parsed when using JacksonJsonTransformer

How to reproduce the problem:

Write and run below test into BundleApiTest.java

    @Test
    public void downloadBundleTest() {
        TimeZone.setDefault(TimeZone.getTimeZone("GMT"));
        ResponseObject<DownloadLink> response = this.getBundlesApi().downloadBundle(projectId, bundleId, exportId);
        assertEquals(new Date(119, Calendar.SEPTEMBER, 20,10,31,21), response.getData().getExpireIn());
        assertEquals("test.com", response.getData().getUrl());
    }

Observed behaviour:

When I run this test, the result shows that Date expireIn from Json file downloadBundle.json which look like this:

{
  "data": {
    "url": "test.com",
    "expireIn": "2019-09-20T10:31:21+00:00"
  }
}

is parsed as Fri Sep 20 08:00:21 GMT 2019
Despite of hours difference what will direct us to problem with TimeZone, what is more important we don't getting minutes of hour read properly.

Expected behaviour:

What is expected when parsing given date of: 2019-09-20T10:31:21+00:00
is result looking like this: Fri Sep 20 10:31:21 GMT 2019.

Cannot deserialize instance of `com.crowdin.client.screenshots.model.Tag`

While trying to call
public ResponseObject<Tag> addTag(Long projectId, Long screenshotId, List<AddTagRequest> request)

Get the following error

HttpException(error=HttpException.Error(code=null, message=Cannot deserialize instance of `com.crowdin.client.screenshots.model.Tag` out of START_ARRAY token
 at [Source: (String)"{"data":[{"data":{"id":17,"screenshotId":19,"stringId":31649,"position":null,"createdAt":"2022-06-20T10:59:52+00:00"}},{"data":{"id":19,"screenshotId":19,"stringId":31651,"position":null,"createdAt":"2022-06-20T10:59:52+00:00"}},{"data":{"id":21,"screenshotId":19,"stringId":31653,"position":null,"createdAt":"2022-06-20T10:59:52+00:00"}},{"data":{"id":23,"screenshotId":19,"stringId":31655,"position":null,"createdAt":"2022-06-20T10:59:52+00:00"}},{"data":{"id":25,"screenshotId":19,"stringId":31657"[truncated 206 chars]; line: 1, column: 9] (through reference chain: com.crowdin.client.screenshots.model.TagResponseObject["data"])))
	at com.crowdin.client.core.http.exceptions.HttpException.fromMessage(HttpException.java:22)

Server returns List of tags while Java client expect only one tag in response !

Reports API changes

Crowdin recently released a big update of the reports functionality. Now, when calculating the price for translation in Cost Estimation and Translation Cost reports, we have introduced a new feature that allows you to include the cost of proofreading if the source text matches the Translation Memory (TM) or Machine Translation (MT) results.

The reports API was updated as well. The legacy Cost Estimate (including Fuzzy mode) and Translation Cost reports were deprecated in favor of the new Cost-Estimation Post-Editing and Translation Costs Post-Editing reports. The legacy reports will be removed in future releases.

API reference:

The Report Settings Template API was also affected (refer to the API Docs for details).

Deprecated forms should be marked as deprecated in this API Client, and the new forms should be added.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.