ewngs / szamlazz.js

Node.js client for Szamlazz.hu
MIT License
38 stars 34 forks source link

Handle PDF as binary content in `reverseInvoice` method #24

Closed aron123 closed 1 year ago

aron123 commented 3 years ago

PDF content generated with reverseInvoice method was handled as a UTF8 string, so it can not be converted to the original binary format, and it cannot be saved directly to the filesystem as a valid PDF file.

I changed code to handle the response as binary content, so reverseInvoice returns PDF as a Buffer from now. This format is also consistent with the output of issueInvoice.

Incrementing major version number and extending changelog is necessary before merging this PR. Please let me know if you are ready to approve these changes, and I can do these steps too.

It closes #23

aron123 commented 3 years ago

I also simplified getResult a little bit.

Line cb(null, result, httpResponse) was redundant and was called at the end of every branches. Line 207 is not necessary anymore as pdf field is set in reverseInvoice method. (it is used by issueInvoice too so I put it back)

mondalaci commented 1 year ago

@aron123 Thanks for your contribution, and sorry for my fabulously late reply! Would you please rework your PR? The codebase has been ported to async/await and ECMAScript modules in the meantime.

aron123 commented 1 year ago

Yes, I will rework it.

aron123 commented 1 year ago

I've tested it, and found that you are already fixed this issue with the new major version. Only documentation changes are missed out, I did it here: #29