Edits history of script submission #14312 for ' Add classification (box)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Box = {
      token: string;
    };
    /**
     * Add classification
     * Adds one or more new classifications to the list of classifications
    available to the enterprise.
    
    This API can also be called by including the enterprise ID in the
    URL explicitly, for example
    `/metadata_templates/enterprise_12345/securityClassification-6VMVochwUWo/schema`.
     */
    export async function main(
      auth: Box,
      body: {
        op: "addEnumOption";
        fieldKey: "Box__Security__Classification__Key";
        data: {
          key: string;
          staticConfig?: {
            classification?: {
              classificationDefinition?: string;
              colorID?: number;
            };
          };
        };
      }[],
    ) {
      const url = new URL(
        `https://api.box.com/2.0/metadata_templates/enterprise/securityClassification-6VMVochwUWo/schema#add`,
      );
    
      const response = await fetch(url, {
        method: "PUT",
        headers: {
          "Content-Type": "application/json",
          Authorization: "Bearer " + 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