//native
type Zoho = {
token: string;
};
/**
* Update a Shipment Order
* Update details of an existing Shipment Order in Zoho Inventory.
*/
export async function main(
auth: Zoho,
shipmentorder_id: string,
organization_id: string | undefined,
package_ids: string | undefined,
salesorder_id: string | undefined,
body: {
shipment_number: string;
date: string;
reference_number?: string;
contact_persons?: { contact_person_id?: number }[];
delivery_method: string;
tracking_number?: string;
shipping_charge?: number;
exchange_rate?: number;
template_id?: number;
notes?: string;
custom_fields?: { customfield_id?: number; value?: string }[];
},
) {
const url = new URL(
`https://www.zohoapis.com/inventory/v1/shipmentorders/${shipmentorder_id}`,
);
for (const [k, v] of [
["organization_id", organization_id],
["package_ids", package_ids],
["salesorder_id", salesorder_id],
]) {
if (v !== undefined && v !== "" && k !== undefined) {
url.searchParams.append(k, v);
}
}
const response = await fetch(url, {
method: "PUT",
headers: {
"Content-Type": "application/json",
Authorization: "Zoho-oauthtoken " + auth.token,
},
body: JSON.stringify(body),
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 235 days ago