Edits history of script submission #2926 for ' Get Boards in an Organization (trello)'

  • nativets
    One script reply has been approved by the moderators
    Ap­pro­ved
    type Trello = {
      key: string;
      token: string;
    };
    /**
     * Get Boards in an Organization
     * List the boards in a Workspace
     */
    export async function main(
      auth: Trello,
      id: string,
      filter:
        | "all"
        | "open"
        | "closed"
        | "members"
        | "organization"
        | "public"
        | undefined,
      fields:
        | "id"
        | "name"
        | "desc"
        | "descData"
        | "closed"
        | "idMemberCreator"
        | "idOrganization"
        | "pinned"
        | "url"
        | "shortUrl"
        | "prefs"
        | "labelNames"
        | "starred"
        | "limits"
        | "memberships"
        | "enterpriseOwned"
        | undefined
    ) {
      const url = new URL(`https://api.trello.com/1/organizations/${id}/boards`);
      for (const [k, v] of [
        ["filter", filter],
        ["fields", fields],
        ["key", auth.key],
        ["token", auth.token],
      ]) {
        if (v !== undefined && v !== "") {
          url.searchParams.append(k, v);
        }
      }
      const response = await fetch(url, {
        method: "GET",
        headers: {
          Authorization: undefined,
        },
        body: undefined,
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.json();
    }
    

    Submitted by hugo697 398 days ago

  • nativets
    type Trello = {
      key: string;
      token: string;
    };
    /**
     * Get Boards in an Organization
     * List the boards in a Workspace
     */
    export async function main(
      auth: Trello,
      id: string,
      filter:
        | "all"
        | "open"
        | "closed"
        | "members"
        | "organization"
        | "public"
        | undefined,
      fields:
        | "id"
        | "name"
        | "desc"
        | "descData"
        | "closed"
        | "idMemberCreator"
        | "idOrganization"
        | "pinned"
        | "url"
        | "shortUrl"
        | "prefs"
        | "labelNames"
        | "starred"
        | "limits"
        | "memberships"
        | "enterpriseOwned"
        | undefined
    ) {
      const url = new URL(`https://api.trello.com/1/organizations/${id}/boards`);
      for (const [k, v] of [
        ["filter", filter],
        ["fields", fields],
        ["key", auth.key],
        ["token", auth.token],
      ]) {
        if (v !== undefined && v !== "") {
          url.searchParams.append(k, v);
        }
      }
      const response = await fetch(url, {
        method: "GET",
        headers: {
          Authorization: undefined,
        },
        body: undefined,
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.json();
    }
    

    Submitted by hugo697 953 days ago