//native
type Zoho = {
token: string;
};
/**
* List items
* Get the list of all active items with pagination.
*/
export async function main(
auth: Zoho,
organization_id: string | undefined,
name: string | undefined,
description: string | undefined,
rate: string | undefined,
tax_id: string | undefined,
tax_name: string | undefined,
is_taxable: string | undefined,
tax_exemption_id: string | undefined,
account_id: string | undefined,
filter_by: string | undefined,
search_text: string | undefined,
sort_column: string | undefined,
sat_item_key_code: string | undefined,
unitkey_code: string | undefined,
) {
const url = new URL(`https://www.zohoapis.com/books/v3/items`);
for (const [k, v] of [
["organization_id", organization_id],
["name", name],
["description", description],
["rate", rate],
["tax_id", tax_id],
["tax_name", tax_name],
["is_taxable", is_taxable],
["tax_exemption_id", tax_exemption_id],
["account_id", account_id],
["filter_by", filter_by],
["search_text", search_text],
["sort_column", sort_column],
["sat_item_key_code", sat_item_key_code],
["unitkey_code", unitkey_code],
]) {
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