Edits history of script submission #14447 for ' List Slack integration mappings (box)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Box = {
      token: string;
    };
    /**
     * List Slack integration mappings
     * Lists [Slack integration mappings](https://support.box.com/hc/en-us/articles/4415585987859-Box-as-the-Content-Layer-for-Slack) in a users' enterprise.
    
    You need Admin or Co-Admin role to
    use this endpoint.
     */
    export async function main(
      auth: Box,
      marker: string | undefined,
      limit: string | undefined,
      partner_item_type: "channel" | undefined,
      partner_item_id: string | undefined,
      box_item_id: string | undefined,
      box_item_type: "folder" | undefined,
      is_manually_created: string | undefined,
    ) {
      const url = new URL(`https://api.box.com/2.0/integration_mappings/slack`);
      for (const [k, v] of [
        ["marker", marker],
        ["limit", limit],
        ["partner_item_type", partner_item_type],
        ["partner_item_id", partner_item_id],
        ["box_item_id", box_item_id],
        ["box_item_type", box_item_type],
        ["is_manually_created", is_manually_created],
      ]) {
        if (v !== undefined && v !== "" && k !== undefined) {
          url.searchParams.append(k, v);
        }
      }
      const response = await fetch(url, {
        method: "GET",
        headers: {
          Authorization: "Bearer " + auth.token,
        },
        body: undefined,
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.json();
    }
    

    Submitted by hugo697 235 days ago