Edits history of script submission #22089 for ' Update fiscal year (zoho)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Zoho = {
      token: string;
    };
    /**
     * Update fiscal year
     *
     */
    export async function main(
      auth: Zoho,
      body: {
        fiscal_year: {
          start_month:
            | "June"
            | "October"
            | "December"
            | "May"
            | "September"
            | "March"
            | "July"
            | "January"
            | "February"
            | "April"
            | "August"
            | "November";
          display_based_on: "start_month" | "end_month";
          id?: string;
        };
      },
    ) {
      const url = new URL(`https://zohoapis.com/crm/v8/settings/fiscal_year`);
    
      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