0

List vendor credit refunds

by
Published Oct 17, 2025

List all refunds 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 credit refunds
7
 * List all refunds with pagination.
8
 */
9
export async function main(
10
  auth: Zoho,
11
  organization_id: string | undefined,
12
  customer_id: string | undefined,
13
  last_modified_time: string | undefined,
14
  sort_column: string | undefined,
15
) {
16
  const url = new URL(
17
    `https://www.zohoapis.com/inventory/v1/vendorcredits/refunds`,
18
  );
19
  for (const [k, v] of [
20
    ["organization_id", organization_id],
21
    ["customer_id", customer_id],
22
    ["last_modified_time", last_modified_time],
23
    ["sort_column", sort_column],
24
  ]) {
25
    if (v !== undefined && v !== "" && k !== undefined) {
26
      url.searchParams.append(k, v);
27
    }
28
  }
29
  const response = await fetch(url, {
30
    method: "GET",
31
    headers: {
32
      Authorization: "Zoho-oauthtoken " + auth.token,
33
    },
34
    body: undefined,
35
  });
36
  if (!response.ok) {
37
    const text = await response.text();
38
    throw new Error(`${response.status} ${text}`);
39
  }
40
  return await response.json();
41
}
42