0

Add comment

by
Published Oct 17, 2025

Add a comment for a retainer invoice.

Script zoho Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Zoho = {
3
  token: string;
4
};
5
/**
6
 * Add comment
7
 * Add a comment for a retainer invoice.
8
 */
9
export async function main(
10
  auth: Zoho,
11
  retainerinvoice_id: string,
12
  organization_id: string | undefined,
13
  body: {
14
    description?: string;
15
    payment_expected_date?: string;
16
    show_comment_to_clients?: false | true;
17
  },
18
) {
19
  const url = new URL(
20
    `https://www.zohoapis.com/inventory/v1/retainerinvoices/${retainerinvoice_id}/comments`,
21
  );
22
  for (const [k, v] of [["organization_id", organization_id]]) {
23
    if (v !== undefined && v !== "" && k !== undefined) {
24
      url.searchParams.append(k, v);
25
    }
26
  }
27
  const response = await fetch(url, {
28
    method: "POST",
29
    headers: {
30
      "Content-Type": "application/json",
31
      Authorization: "Zoho-oauthtoken " + auth.token,
32
    },
33
    body: JSON.stringify(body),
34
  });
35
  if (!response.ok) {
36
    const text = await response.text();
37
    throw new Error(`${response.status} ${text}`);
38
  }
39
  return await response.json();
40
}
41