trieb-work / zoho-ts

Zoho Inventory, Invoice and Books Typescript library with several predefined functions
Apache License 2.0
13 stars 5 forks source link

Check API result of salesOrder.confirm #14

Open tilman opened 2 years ago

tilman commented 2 years ago

https://github.com/trieb-work/zoho-ts/blob/f86ffbdeb18566c6e130f8528d5f12fd5ccfb721/src/service/salesOrder.ts#L160

The zoho client does not check the json return and status code. I would suggest to throw an error if the status code is not 200 or if the returned json has some errors like in this example response:

{"code":0,"message":"Sales order status has been changed to Confirmed.","data":{"ava_invoice_ids":[],"email_errors_info":[{"code":36007,"ids":["116240000001641005","116240000001641027","116240000001641045"],"message":"Invalid sales order status."}],"email_success_info":{"message":"The status of the Sales order has been changed to Open."}}}