//native
type Zoho = {
token: string;
};
/**
* List recurring bills
* List all recurring bills with pagination.
*/
export async function main(
auth: Zoho,
organization_id: string | undefined,
recurring_bill_id: string | undefined,
vendor_id: string | undefined,
vendor_name: string | undefined,
status: string | undefined,
recurrence_name: string | undefined,
currency_id: string | undefined,
currency_code: string | undefined,
currency_symbol: string | undefined,
start_date: string | undefined,
end_date: string | undefined,
source_of_supply: string | undefined,
place_of_supply: string | undefined,
destination_of_supply: string | undefined,
gst_treatment: string | undefined,
gst_no: string | undefined,
tax_treatment: string | undefined,
vat_treatment: string | undefined,
vat_reg_no: string | undefined,
is_abn_quoted: string | undefined,
abn: string | undefined,
is_reverse_charge_applied: string | undefined,
pricebook_id: string | undefined,
pricebook_name: string | undefined,
is_inclusive_tax: string | undefined,
line_items: string | undefined,
is_tds_applied: string | undefined,
notes: string | undefined,
terms: string | undefined,
payment_terms: string | undefined,
payment_terms_label: string | undefined,
custom_fields: string | undefined,
acquisition_vat_summary: string | undefined,
reverse_charge_vat_summary: string | undefined,
acquisition_vat_total: string | undefined,
reverse_charge_vat_total: string | undefined,
created_time: string | undefined,
created_by_id: string | undefined,
last_modified_time: string | undefined,
discount: string | undefined,
discount_account_id: string | undefined,
is_discount_before_tax: string | undefined,
) {
const url = new URL(`https://www.zohoapis.com/books/v3/recurringbills`);
for (const [k, v] of [
["organization_id", organization_id],
["recurring_bill_id", recurring_bill_id],
["vendor_id", vendor_id],
["vendor_name", vendor_name],
["status", status],
["recurrence_name", recurrence_name],
["currency_id", currency_id],
["currency_code", currency_code],
["currency_symbol", currency_symbol],
["start_date", start_date],
["end_date", end_date],
["source_of_supply", source_of_supply],
["place_of_supply", place_of_supply],
["destination_of_supply", destination_of_supply],
["gst_treatment", gst_treatment],
["gst_no", gst_no],
["tax_treatment", tax_treatment],
["vat_treatment", vat_treatment],
["vat_reg_no", vat_reg_no],
["is_abn_quoted", is_abn_quoted],
["abn", abn],
["is_reverse_charge_applied", is_reverse_charge_applied],
["pricebook_id", pricebook_id],
["pricebook_name", pricebook_name],
["is_inclusive_tax", is_inclusive_tax],
["line_items", line_items],
["is_tds_applied", is_tds_applied],
["notes", notes],
["terms", terms],
["payment_terms", payment_terms],
["payment_terms_label", payment_terms_label],
["custom_fields", custom_fields],
["acquisition_vat_summary", acquisition_vat_summary],
["reverse_charge_vat_summary", reverse_charge_vat_summary],
["acquisition_vat_total", acquisition_vat_total],
["reverse_charge_vat_total", reverse_charge_vat_total],
["created_time", created_time],
["created_by_id", created_by_id],
["last_modified_time", last_modified_time],
["discount", discount],
["discount_account_id", discount_account_id],
["is_discount_before_tax", is_discount_before_tax],
]) {
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