Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: add callback url to job params #94

Merged
merged 5 commits into from
Nov 28, 2023

Conversation

triartleet
Copy link

@triartleet triartleet commented Nov 13, 2023

@PavelLoparev regarding commit #2 (change endpoint to download all files translations): Even after the fix, I did not manage to write a .zip to my filesystem although I did not dig much into the code. Is writing non-raw responses supported atm? If not, do you have any plan of working on it in the near future?

For now, I consider it out of this MR's scope (no time) and will fetch translations separately by locales.

Let me know, thanks!

@PavelLoparev
Copy link
Contributor

PavelLoparev commented Nov 14, 2023

Hi @fllprbt, it appears Files API doc is wrong about having zipFileName query parameter for download all translations endpoint. We will fix the doc.

This param should be removed from the DownloadFileAllTranslationsParameters. If you try to download without that param api will respond with application/zip;charset=UTF-8 response like:

curl --location 'https://api.smartling.com/files-api/v2/projects/<projectId>/locales/all/file/zip?fileUri=<fileName>.<fileExtension>' \
--header 'Authorization: Bearer ...'

PK��������� nW����������������zh-CN/<fileName>.<fileExtension>�����<?xml version="1.0" encoding="UTF-8"?>
<zh-CN file content here>
PK��g�����������PK��������� nW����������������da-DK/<fileName>.<fileExtension>�����<?xml version="1.0" encoding="UTF-8"?>
<da-DK file content here>
...

And then you probably can save it as you need (didn't dig deeper, I just checked this sdk method returns exactly the same content as curl/postman call)

@PavelLoparev
Copy link
Contributor

PavelLoparev commented Nov 14, 2023

Is writing non-raw responses supported atm?

For now, it supports receiving raw response body as response.text() or parsed dtos from response json.

@dimitrystd
Copy link
Contributor

Hi All,
I didn't review the PR, but the zip word caught my attention. I strongly recommend not using zip in integrations. Because TMS must prepare all translated files before actual download, downloading a zip file may increase response time. When the user interacts with TMS, using zip makes sense. However, for automation, robustness is the top priority. Tens of short HTTP requests (with predictable response time) are preferable to one request when response time can range from seconds to minutes.

P.S. @conall-smartling for visibility. There are a couple of related tickets #89, #92.

@triartleet
Copy link
Author

triartleet commented Nov 17, 2023

Hi @fllprbt, it appears Files API doc is wrong about having zipFileName query parameter for download all translations endpoint. We will fix the doc.

This param should be removed from the DownloadFileAllTranslationsParameters. If you try to download without that param api will respond with application/zip;charset=UTF-8 response like:

curl --location 'https://api.smartling.com/files-api/v2/projects/<projectId>/locales/all/file/zip?fileUri=<fileName>.<fileExtension>' \
--header 'Authorization: Bearer ...'

PK��������� nW����������������zh-CN/<fileName>.<fileExtension>�����<?xml version="1.0" encoding="UTF-8"?>se
<zh-CN file content here>
PK��g�����������PK��������� nW����������������da-DK/<fileName>.<fileExtension>�����<?xml version="1.0" encoding="UTF-8"?>
<da-DK file content here>
...

And then you probably can save it as you need (didn't dig wdeeper, I just checked this sdk method returns exactly the same content as curl/postman

Right, i also had such glyphs back when i had tested it; had tried to parse it then as zip and failed but did not investigate it much...

@triartleet
Copy link
Author

@PavelLoparev could you review this MR please? Added also the list batches helper

@PavelLoparev PavelLoparev self-requested a review November 27, 2023 10:27
Copy link
Contributor

@PavelLoparev PavelLoparev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @fllprbt, could you please remove zipFileName query parameter from DownloadFileAllTranslationsParameters class?

looks ok other than that

@triartleet
Copy link
Author

done!

@PavelLoparev
Copy link
Contributor

PavelLoparev commented Nov 27, 2023

@fllprbt Sorry overlooked one thing. The list batches endpoint also receives query parameters. As I see list batches method only receives project id so it's not possible to get all the batches without pagination for now. I think parameters class with available pagination parameters and filters should be added.

* remove breking test for downloadAllTranslation zipFileName removed param
@triartleet
Copy link
Author

triartleet commented Nov 27, 2023

Done.

Btw we would like eventually have something similar here: https://github.com/Smartling/api-sdk-nodejs/blob/master/api/jobs/index.ts#L57C63-L57C85

Since a params object can be passed, does it mean that we can use params.set to set these manually in case the specific helpers do not exist?

@PavelLoparev
Copy link
Contributor

Done.

Btw we would like eventually have something similar here: https://github.com/Smartling/api-sdk-nodejs/blob/master/api/jobs/index.ts#L57C63-L57C85

Since a params object can be passed, does it mean that we can use params.set to set these manually in case the specific helpers do not exist?

yes, you can use .set() method but I would prefer to just to add anything that is missing/needed for you through the PRs.

@PavelLoparev PavelLoparev merged commit 7ffdbc8 into Smartling:master Nov 28, 2023
@PavelLoparev
Copy link
Contributor

2.4.0 is released

@cipsicko
Copy link

cipsicko commented Dec 5, 2023

Hi, the setCallbackUrl method was added without setCallBackMethod that is mandatory otherwise an error occurs.
https://api-reference.smartling.com/#tag/Jobs/operation/addJob

@triartleet
Copy link
Author

triartleet commented Dec 5, 2023

Hi, the setCallbackUrl method was added without setCallBackMethod that is mandatory otherwise an error occurs. https://api-reference.smartling.com/#tag/Jobs/operation/addJob

Sorry, missed that from docs. Can fix myself this Friday if no anyone else does

@cipsicko
Copy link

cipsicko commented Dec 6, 2023

Hi, the setCallbackUrl method was added without setCallBackMethod that is mandatory otherwise an error occurs. https://api-reference.smartling.com/#tag/Jobs/operation/addJob

Sorry, missed that from docs. Can fix myself this Friday if no anyone else does

I can do it but i'm stucked here #95

@PavelLoparev
Copy link
Contributor

This is going to be addressed in #100

@PavelLoparev
Copy link
Contributor

As for downloading zip: #117

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants