0

Update a Currency

by
Published Oct 17, 2025

Update the details of a currency.

Script zoho Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Zoho = {
3
  token: string;
4
};
5
/**
6
 * Update a Currency
7
 * Update the details of a currency.
8
 */
9
export async function main(
10
  auth: Zoho,
11
  currency_id: string,
12
  organization_id: string | undefined,
13
  body: {
14
    currency_code: string;
15
    currency_symbol: string;
16
    price_precision?: number;
17
    currency_format?: string;
18
  },
19
) {
20
  const url = new URL(
21
    `https://www.zohoapis.com/inventory/v1/settings/currencies/${currency_id}`,
22
  );
23
  for (const [k, v] of [["organization_id", organization_id]]) {
24
    if (v !== undefined && v !== "" && k !== undefined) {
25
      url.searchParams.append(k, v);
26
    }
27
  }
28
  const response = await fetch(url, {
29
    method: "PUT",
30
    headers: {
31
      "Content-Type": "application/json",
32
      Authorization: "Zoho-oauthtoken " + auth.token,
33
    },
34
    body: JSON.stringify(body),
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