Edits history of script submission #20458 for ' Deactivate User (smartsheet)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Smartsheet = {
      token: string;
      baseUrl: string;
    };
    /**
     * Deactivate User
     * Deactivates the user associated with the current Smartsheet plan, blocking the user from using Smartsheet in any way.
     */
    export async function main(
      auth: Smartsheet,
      userId: string,
    ) {
      const url = new URL(`${auth.baseUrl}/users/${userId}/deactivate`);
    
      const response = await fetch(url, {
        method: "POST",
        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