0

List estimates

by
Published Oct 17, 2025

List all estimates 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 estimates
7
 * List all estimates with pagination.
8
 */
9
export async function main(
10
  auth: Zoho,
11
  organization_id: string | undefined,
12
  estimate_number: string | undefined,
13
  reference_number: string | undefined,
14
  customer_name: string | undefined,
15
  total: string | undefined,
16
  customer_id: string | undefined,
17
  item_id: string | undefined,
18
  item_name: string | undefined,
19
  item_description: string | undefined,
20
  custom_field: string | undefined,
21
  expiry_date: string | undefined,
22
  date: string | undefined,
23
  status: string | undefined,
24
  filter_by: string | undefined,
25
  search_text: string | undefined,
26
  sort_column: string | undefined,
27
  zcrm_potential_id: string | undefined,
28
) {
29
  const url = new URL(`https://www.zohoapis.com/books/v3/estimates`);
30
  for (const [k, v] of [
31
    ["organization_id", organization_id],
32
    ["estimate_number", estimate_number],
33
    ["reference_number", reference_number],
34
    ["customer_name", customer_name],
35
    ["total", total],
36
    ["customer_id", customer_id],
37
    ["item_id", item_id],
38
    ["item_name", item_name],
39
    ["item_description", item_description],
40
    ["custom_field", custom_field],
41
    ["expiry_date", expiry_date],
42
    ["date", date],
43
    ["status", status],
44
    ["filter_by", filter_by],
45
    ["search_text", search_text],
46
    ["sort_column", sort_column],
47
    ["zcrm_potential_id", zcrm_potential_id],
48
  ]) {
49
    if (v !== undefined && v !== "" && k !== undefined) {
50
      url.searchParams.append(k, v);
51
    }
52
  }
53
  const response = await fetch(url, {
54
    method: "GET",
55
    headers: {
56
      Authorization: "Zoho-oauthtoken " + auth.token,
57
    },
58
    body: undefined,
59
  });
60
  if (!response.ok) {
61
    const text = await response.text();
62
    throw new Error(`${response.status} ${text}`);
63
  }
64
  return await response.json();
65
}
66