0

List vendor credits

by
Published Oct 17, 2025

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