Edits history of script submission #22037 for ' Update an organization (zoho)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Zoho = {
      token: string;
    };
    /**
     * Update an organization
     * Update the details of an organization.
     */
    export async function main(
      auth: Zoho,
      organization_id: string,
      body: {
        name?: string;
        fiscal_year_start_month?: string;
        is_logo_uploaded?: false | true;
        time_zone?: string;
        date_format?: string;
        field_separator?: string;
        language_code?: string;
        org_address?: string;
        remit_to_address?: string;
        address?: {
          street_address1?: string;
          street_address2?: string;
          city?: string;
          state?: string;
          country?: string;
          zip?: string;
        }[];
        contact_name?: string;
        phone?: string;
        fax?: string;
        website?: string;
        email?: string;
        currency_id?: string;
        companyid_label?: string;
        companyid_value?: string;
        taxid_label?: string;
        taxid_value?: string;
        custom_fields?: { index?: number; value?: string; label?: string }[];
      },
    ) {
      const url = new URL(
        `https://www.zohoapis.com/inventory/v1/organizations/${organization_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