Edits history of script submission #14785 for ' Remove Guest From Folder (clickup)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Clickup = {
      token: string;
    };
    /**
     * Remove Guest From Folder
     * Revoke a guest's access to a Folder. \
     \
    ***Note:** This endpoint is only available to Workspaces on our [Enterprise Plan](https://clickup.com/pricing).*
     */
    export async function main(
      auth: Clickup,
      folder_id: string,
      guest_id: string,
      include_shared: string | undefined,
    ) {
      const url = new URL(
        `https://api.clickup.com/api/v2/folder/${folder_id}/guest/${guest_id}`,
      );
      for (const [k, v] of [["include_shared", include_shared]]) {
        if (v !== undefined && v !== "" && k !== undefined) {
          url.searchParams.append(k, v);
        }
      }
      const response = await fetch(url, {
        method: "DELETE",
        headers: {
          Authorization: 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