//native
type Zoho = {
token: string;
};
/**
* List sales orders
* List all sales orders.
*/
export async function main(
auth: Zoho,
organization_id: string | undefined,
sort_column: string | undefined,
search_text: string | undefined,
filter_by: string | undefined,
salesorder_number: string | undefined,
item_name: string | undefined,
item_id: string | undefined,
item_description: string | undefined,
reference_number: string | undefined,
customer_name: string | undefined,
total: string | undefined,
date: string | undefined,
shipment_date: string | undefined,
status: string | undefined,
customer_id: string | undefined,
salesperson_id: string | undefined,
salesorder_ids: string | undefined,
zcrm_potential_id: string | undefined,
last_modified_time: string | undefined,
accept: string | undefined,
print: string | undefined,
customview_id: string | undefined,
) {
const url = new URL(`https://www.zohoapis.com/books/v3/salesorders`);
for (const [k, v] of [
["organization_id", organization_id],
["sort_column", sort_column],
["search_text", search_text],
["filter_by", filter_by],
["salesorder_number", salesorder_number],
["item_name", item_name],
["item_id", item_id],
["item_description", item_description],
["reference_number", reference_number],
["customer_name", customer_name],
["total", total],
["date", date],
["shipment_date", shipment_date],
["status", status],
["customer_id", customer_id],
["salesperson_id", salesperson_id],
["salesorder_ids", salesorder_ids],
["zcrm_potential_id", zcrm_potential_id],
["last_modified_time", last_modified_time],
["accept", accept],
["print", print],
["customview_id", customview_id],
]) {
if (v !== undefined && v !== "" && k !== undefined) {
url.searchParams.append(k, v);
}
}
const response = await fetch(url, {
method: "GET",
headers: {
Authorization: "Zoho-oauthtoken " + auth.token,
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 235 days ago