Edits history of script submission #3572 for ' Get notification schemes paginated (jira)'

  • nativets
    One script reply has been approved by the moderators
    Ap­pro­ved
    type Jira = {
      username: string;
      password: string;
      domain: string;
    };
    /**
     * Get notification schemes paginated
     * Returns a [paginated](#pagination) list of [notification schemes](https://confluence.atlassian.com/x/8YdKLg) ordered by the display name.
    
    *Note that you should allow for events without recipients to appear in responses.*
    
    **[Permissions](#permissions) required:** Permission to access Jira, however, the user must have permission to administer at least one project associated with a notification scheme for it to be returned.
     */
    export async function main(
      auth: Jira,
      startAt: string | undefined,
      maxResults: string | undefined,
      id: string | undefined,
      projectId: string | undefined,
      onlyDefault: string | undefined,
      expand: string | undefined
    ) {
      const url = new URL(
        `https://${auth.domain}.atlassian.net/rest/api/2/notificationscheme`
      );
      for (const [k, v] of [
        ["startAt", startAt],
        ["maxResults", maxResults],
        ["id", id],
        ["projectId", projectId],
        ["onlyDefault", onlyDefault],
        ["expand", expand],
      ]) {
        if (v !== undefined && v !== "") {
          url.searchParams.append(k, v);
        }
      }
      const response = await fetch(url, {
        method: "GET",
        headers: {
          Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
        },
        body: undefined,
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.json();
    }
    

    Submitted by hugo697 396 days ago

  • nativets
    type Jira = {
      username: string;
      password: string;
      domain: string;
    };
    /**
     * Get notification schemes paginated
     * Returns a [paginated](#pagination) list of [notification schemes](https://confluence.atlassian.com/x/8YdKLg) ordered by the display name.
    
    *Note that you should allow for events without recipients to appear in responses.*
    
    **[Permissions](#permissions) required:** Permission to access Jira, however, the user must have permission to administer at least one project associated with a notification scheme for it to be returned.
     */
    export async function main(
      auth: Jira,
      startAt: string | undefined,
      maxResults: string | undefined,
      id: string | undefined,
      projectId: string | undefined,
      onlyDefault: string | undefined,
      expand: string | undefined
    ) {
      const url = new URL(
        `https://${auth.domain}.atlassian.net/rest/api/2/notificationscheme`
      );
      for (const [k, v] of [
        ["startAt", startAt],
        ["maxResults", maxResults],
        ["id", id],
        ["projectId", projectId],
        ["onlyDefault", onlyDefault],
        ["expand", expand],
      ]) {
        if (v !== undefined && v !== "") {
          url.searchParams.append(k, v);
        }
      }
      const response = await fetch(url, {
        method: "GET",
        headers: {
          Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
        },
        body: undefined,
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.json();
    }
    

    Submitted by hugo697 948 days ago