Edits history of script submission #1886 for ' List pending organization invitations (github)'

  • nativets
    One script reply has been approved by the moderators
    Ap­pro­ved
    type Github = {
      token: string;
    };
    /**
     * List pending organization invitations
     * The return hash contains a `role` field which refers to the Organization Invitation role and will be one of the following values: `direct_member`, `admin`, `billing_manager`, or `hiring_manager`. If the invitee is not a GitHub member, the `login` field in the return hash will be `null`.
     */
    export async function main(
      auth: Github,
      org: string,
      per_page: string | undefined,
      page: string | undefined,
      role:
        | "all"
        | "admin"
        | "direct_member"
        | "billing_manager"
        | "hiring_manager"
        | undefined,
      invitation_source: "all" | "member" | "scim" | undefined
    ) {
      const url = new URL(`https://api.github.com/orgs/${org}/invitations`);
      for (const [k, v] of [
        ["per_page", per_page],
        ["page", page],
        ["role", role],
        ["invitation_source", invitation_source],
      ]) {
        if (v !== undefined && v !== "") {
          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 367 days ago

  • nativets
    type Github = {
      token: string;
    };
    /**
     * List pending organization invitations
     * The return hash contains a `role` field which refers to the Organization Invitation role and will be one of the following values: `direct_member`, `admin`, `billing_manager`, or `hiring_manager`. If the invitee is not a GitHub member, the `login` field in the return hash will be `null`.
     */
    export async function main(
      auth: Github,
      org: string,
      per_page: string | undefined,
      page: string | undefined,
      role:
        | "all"
        | "admin"
        | "direct_member"
        | "billing_manager"
        | "hiring_manager"
        | undefined,
      invitation_source: "all" | "member" | "scim" | undefined
    ) {
      const url = new URL(`https://api.github.com/orgs/${org}/invitations`);
      for (const [k, v] of [
        ["per_page", per_page],
        ["page", page],
        ["role", role],
        ["invitation_source", invitation_source],
      ]) {
        if (v !== undefined && v !== "") {
          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 927 days ago