Edits history of script submission #14542 for ' Update Slack integration mapping (box)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Box = {
      token: string;
    };
    /**
     * Update Slack integration mapping
     * Updates a [Slack integration mapping](https://support.box.com/hc/en-us/articles/4415585987859-Box-as-the-Content-Layer-for-Slack).
    Supports updating the Box folder ID and options.
    
    You need Admin or Co-Admin role to
    use this endpoint.
     */
    export async function main(
      auth: Box,
      integration_mapping_id: string,
      body: {
        box_item?: { type: "folder"; id: string };
        options?: { is_access_management_disabled?: false | true };
      },
    ) {
      const url = new URL(
        `https://api.box.com/2.0/integration_mappings/slack/${integration_mapping_id}`,
      );
    
      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