Edits history of script submission #21259 for ' Create variables (zoho)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Zoho = {
      token: string;
    };
    /**
     * Create variables
     *
     */
    export async function main(
      auth: Zoho,
      body: {
        variables: {
          api_name: string;
          name: string;
          description: string;
          source: string;
          id: string;
          type:
            | "date"
            | "website"
            | "double"
            | "textarea"
            | "integer"
            | "percent"
            | "long"
            | "datetime"
            | "phone"
            | "checkbox"
            | "currency"
            | "text"
            | "email";
          variable_group: { id: string; api_name: string; name: string };
          read_only: false | true;
          value: {};
        }[];
      },
    ) {
      const url = new URL(`https://zohoapis.com/crm/v8/settings/variables`);
    
      const response = await fetch(url, {
        method: "POST",
        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