Edits history of script submission #22073 for ' Update currency (zoho)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Zoho = {
      token: string;
    };
    /**
     * Update currency
     *
     */
    export async function main(
      auth: Zoho,
      id: string,
      body: {
        currencies: {
          iso_code: string;
          symbol: string;
          created_time: string;
          is_active: false | true;
          exchange_rate: string;
          format: {
            decimal_separator: "Comma" | "Period";
            thousand_separator: "Comma" | "Period" | "Space";
            decimal_places: "0" | "2" | "3";
          };
          created_by: { name: string; id: string; email?: string };
          prefix_symbol: false | true;
          is_base: false | true;
          modified_time: string;
          name: string;
          modified_by: { name: string; id: string; email?: string };
          id: string;
        }[];
      },
    ) {
      const url = new URL(`https://zohoapis.com/crm/v8/org/currencies/${id}`);
    
      const response = await fetch(url, {
        method: "PUT",
        headers: {
          "Content-Type": "application/json",
          Authorization: "Zoho-oauthtoken " + auth.token,
        },
        body: JSON.stringify(body),
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.json();
    }
    

    Submitted by hugo697 235 days ago