Edits history of script submission #17407 for ' Update shape item (miro)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Miro = {
      token: string;
    };
    /**
     * Update shape item
     * Updates a flowchart shape 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?: { content?: string; shape?: string };
        style?: {
          borderColor?: string;
          borderOpacity?: string;
          borderStyle?: "normal" | "dotted" | "dashed";
          borderWidth?: string;
          color?: string;
          fillColor?: string;
          fillOpacity?: string;
          fontFamily?:
            | "arial"
            | "abril_fatface"
            | "bangers"
            | "eb_garamond"
            | "georgia"
            | "graduate"
            | "gravitas_one"
            | "fredoka_one"
            | "nixie_one"
            | "open_sans"
            | "permanent_marker"
            | "pt_sans"
            | "pt_sans_narrow"
            | "pt_serif"
            | "rammetto_one"
            | "roboto"
            | "roboto_condensed"
            | "roboto_slab"
            | "caveat"
            | "times_new_roman"
            | "titan_one"
            | "lemon_tuesday"
            | "roboto_mono"
            | "noto_sans"
            | "plex_sans"
            | "plex_serif"
            | "plex_mono"
            | "spoof"
            | "tiempos_text"
            | "formular";
          fontSize?: string;
          textAlign?: "left" | "right" | "center";
          textAlignVertical?: "top" | "middle" | "bottom";
        };
        position?: { x?: number; y?: number };
        geometry?: { height?: number; rotation?: number; width?: number };
        parent?: { id?: string };
      },
    ) {
      const url = new URL(
        `https://api.miro.com//v2-experimental/boards/${board_id}/shapes/${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