//native
type Zoho = {
token: string;
};
/**
* List estimates
* List all estimates with pagination.
*/
export async function main(
auth: Zoho,
organization_id: string | undefined,
estimate_number: string | undefined,
reference_number: string | undefined,
customer_name: string | undefined,
total: string | undefined,
customer_id: string | undefined,
item_id: string | undefined,
item_name: string | undefined,
item_description: string | undefined,
custom_field: string | undefined,
expiry_date: string | undefined,
date: string | undefined,
status: string | undefined,
filter_by: string | undefined,
search_text: string | undefined,
sort_column: string | undefined,
zcrm_potential_id: string | undefined,
) {
const url = new URL(`https://www.zohoapis.com/books/v3/estimates`);
for (const [k, v] of [
["organization_id", organization_id],
["estimate_number", estimate_number],
["reference_number", reference_number],
["customer_name", customer_name],
["total", total],
["customer_id", customer_id],
["item_id", item_id],
["item_name", item_name],
["item_description", item_description],
["custom_field", custom_field],
["expiry_date", expiry_date],
["date", date],
["status", status],
["filter_by", filter_by],
["search_text", search_text],
["sort_column", sort_column],
["zcrm_potential_id", zcrm_potential_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