Edits history of script submission #3003 for ' Update a Board (trello)'

  • nativets
    One script reply has been approved by the moderators
    Ap­pro­ved
    type Trello = {
      key: string;
      token: string;
    };
    /**
     * Update a Board
     * Update an existing board by id
     */
    export async function main(
      auth: Trello,
      id: string,
      name: string | undefined,
      desc: string | undefined,
      closed: string | undefined,
      subscribed: string | undefined,
      idOrganization: string | undefined,
      prefs_permissionLevel: string | undefined,
      prefs_selfJoin: string | undefined,
      prefs_cardCovers: string | undefined,
      prefs_hideVotes: string | undefined,
      prefs_invitations: string | undefined,
      prefs_voting: string | undefined,
      prefs_comments: string | undefined,
      prefs_background: string | undefined,
      prefs_cardAging: string | undefined,
      prefs_calendarFeedEnabled: string | undefined,
      labelNames_green: string | undefined,
      labelNames_yellow: string | undefined,
      labelNames_orange: string | undefined,
      labelNames_red: string | undefined,
      labelNames_purple: string | undefined,
      labelNames_blue: string | undefined
    ) {
      const url = new URL(`https://api.trello.com/1/boards/${id}`);
      for (const [k, v] of [
        ["name", name],
        ["desc", desc],
        ["closed", closed],
        ["subscribed", subscribed],
        ["idOrganization", idOrganization],
        ["prefs/permissionLevel", prefs_permissionLevel],
        ["prefs/selfJoin", prefs_selfJoin],
        ["prefs/cardCovers", prefs_cardCovers],
        ["prefs/hideVotes", prefs_hideVotes],
        ["prefs/invitations", prefs_invitations],
        ["prefs/voting", prefs_voting],
        ["prefs/comments", prefs_comments],
        ["prefs/background", prefs_background],
        ["prefs/cardAging", prefs_cardAging],
        ["prefs/calendarFeedEnabled", prefs_calendarFeedEnabled],
        ["labelNames/green", labelNames_green],
        ["labelNames/yellow", labelNames_yellow],
        ["labelNames/orange", labelNames_orange],
        ["labelNames/red", labelNames_red],
        ["labelNames/purple", labelNames_purple],
        ["labelNames/blue", labelNames_blue],
        ["key", auth.key],
        ["token", auth.token],
      ]) {
        if (v !== undefined && v !== "") {
          url.searchParams.append(k, v);
        }
      }
      const response = await fetch(url, {
        method: "PUT",
        headers: {
          Authorization: undefined,
        },
        body: undefined,
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.text();
    }
    

    Submitted by hugo697 398 days ago

  • nativets
    type Trello = {
      key: string;
      token: string;
    };
    /**
     * Update a Board
     * Update an existing board by id
     */
    export async function main(
      auth: Trello,
      id: string,
      name: string | undefined,
      desc: string | undefined,
      closed: string | undefined,
      subscribed: string | undefined,
      idOrganization: string | undefined,
      prefs_permissionLevel: string | undefined,
      prefs_selfJoin: string | undefined,
      prefs_cardCovers: string | undefined,
      prefs_hideVotes: string | undefined,
      prefs_invitations: string | undefined,
      prefs_voting: string | undefined,
      prefs_comments: string | undefined,
      prefs_background: string | undefined,
      prefs_cardAging: string | undefined,
      prefs_calendarFeedEnabled: string | undefined,
      labelNames_green: string | undefined,
      labelNames_yellow: string | undefined,
      labelNames_orange: string | undefined,
      labelNames_red: string | undefined,
      labelNames_purple: string | undefined,
      labelNames_blue: string | undefined
    ) {
      const url = new URL(`https://api.trello.com/1/boards/${id}`);
      for (const [k, v] of [
        ["name", name],
        ["desc", desc],
        ["closed", closed],
        ["subscribed", subscribed],
        ["idOrganization", idOrganization],
        ["prefs/permissionLevel", prefs_permissionLevel],
        ["prefs/selfJoin", prefs_selfJoin],
        ["prefs/cardCovers", prefs_cardCovers],
        ["prefs/hideVotes", prefs_hideVotes],
        ["prefs/invitations", prefs_invitations],
        ["prefs/voting", prefs_voting],
        ["prefs/comments", prefs_comments],
        ["prefs/background", prefs_background],
        ["prefs/cardAging", prefs_cardAging],
        ["prefs/calendarFeedEnabled", prefs_calendarFeedEnabled],
        ["labelNames/green", labelNames_green],
        ["labelNames/yellow", labelNames_yellow],
        ["labelNames/orange", labelNames_orange],
        ["labelNames/red", labelNames_red],
        ["labelNames/purple", labelNames_purple],
        ["labelNames/blue", labelNames_blue],
        ["key", auth.key],
        ["token", auth.token],
      ]) {
        if (v !== undefined && v !== "") {
          url.searchParams.append(k, v);
        }
      }
      const response = await fetch(url, {
        method: "PUT",
        headers: {
          Authorization: undefined,
        },
        body: undefined,
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.text();
    }
    

    Submitted by hugo697 953 days ago