Edits history of script submission #17391 for ' Update app card item (miro)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Miro = {
      token: string;
    };
    /**
     * Update app card item
     * Updates an app card item on a board based on the data and style properties provided in the request body.Required scope boards:write Rate limiting Level 2
     */
    export async function main(
      auth: Miro,
      board_id: string,
      item_id: string,
      body: {
        data?: {
          description?: string;
          fields?: {
            fillColor?: string;
            iconShape?: "round" | "square";
            iconUrl?: string;
            textColor?: string;
            tooltip?: string;
            value?: string;
          }[];
          status?: "disconnected" | "connected" | "disabled";
          title?: string;
        };
        style?: { fillColor?: string };
        position?: { x?: number; y?: number };
        geometry?: { height?: number; rotation?: number; width?: number };
        parent?: { id?: string };
      },
    ) {
      const url = new URL(
        `https://api.miro.com//v2/boards/${board_id}/app_cards/${item_id}`,
      );
    
      const response = await fetch(url, {
        method: "PATCH",
        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