Edits history of script submission #20514 for ' List Filtered Events (smartsheet)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Smartsheet = {
      token: string;
      baseUrl: string;
    };
    /**
     * List Filtered Events
     * Gets the events that are occurring in a Smartsheet organization account for resources to which the current user has access to.
     */
    export async function main(
      auth: Smartsheet,
      body: {
        sheetIds?: string[];
        workspaceIds?: string[];
        since?: string;
        to?: string;
        streamPosition?: string;
        maxCount?: number;
        numericDates?: false | true;
        managedPlanId?: number;
      },
    ) {
      const url = new URL(`${auth.baseUrl}/filteredEvents`);
    
      const response = await fetch(url, {
        method: "POST",
        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