//native
type Zoho = {
token: string;
};
/**
* List recurring expenses
* List all the Expenses with pagination.
*/
export async function main(
auth: Zoho,
organization_id: string | undefined,
recurrence_name: string | undefined,
last_created_date: string | undefined,
next_expense_date: string | undefined,
status: string | undefined,
account_id: string | undefined,
account_name: string | undefined,
amount: string | undefined,
customer_name: string | undefined,
customer_id: string | undefined,
paid_through_account_id: string | undefined,
filter_by: string | undefined,
search_text: string | undefined,
sort_column: string | undefined,
) {
const url = new URL(`https://www.zohoapis.com/books/v3/recurringexpenses`);
for (const [k, v] of [
["organization_id", organization_id],
["recurrence_name", recurrence_name],
["last_created_date", last_created_date],
["next_expense_date", next_expense_date],
["status", status],
["account_id", account_id],
["account_name", account_name],
["amount", amount],
["customer_name", customer_name],
["customer_id", customer_id],
["paid_through_account_id", paid_through_account_id],
["filter_by", filter_by],
["search_text", search_text],
["sort_column", sort_column],
]) {
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