0

List a retainer invoices

by
Published Oct 17, 2025

List all retainer invoices with pagination.

Script zoho Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Zoho = {
3
  token: string;
4
};
5
/**
6
 * List a retainer invoices
7
 * List all retainer invoices with pagination.
8
 */
9
export async function main(
10
  auth: Zoho,
11
  organization_id: string | undefined,
12
  print: string | undefined,
13
  sort_column: string | undefined,
14
  filter_by: string | undefined,
15
  sort_order: string | undefined,
16
  page: string | undefined,
17
) {
18
  const url = new URL(`https://www.zohoapis.com/inventory/v1/retainerinvoices`);
19
  for (const [k, v] of [
20
    ["organization_id", organization_id],
21
    ["print", print],
22
    ["sort_column", sort_column],
23
    ["filter_by", filter_by],
24
    ["sort_order", sort_order],
25
    ["page", page],
26
  ]) {
27
    if (v !== undefined && v !== "" && k !== undefined) {
28
      url.searchParams.append(k, v);
29
    }
30
  }
31
  const response = await fetch(url, {
32
    method: "GET",
33
    headers: {
34
      Authorization: "Zoho-oauthtoken " + auth.token,
35
    },
36
    body: undefined,
37
  });
38
  if (!response.ok) {
39
    const text = await response.text();
40
    throw new Error(`${response.status} ${text}`);
41
  }
42
  return await response.json();
43
}
44