Edits history of script submission #17285 for ' Create board (miro)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Miro = {
      token: string;
    };
    /**
     * Create board
     * Creates a board with the specified name and sharing policies.Note You can only create up to 3 team boards with the free plan.Required scope boards:write Rate limiting Level 3
     */
    export async function main(
      auth: Miro,
      body: {
        description?: string;
        name?: string;
        policy?: {
          permissionsPolicy?: {
            collaborationToolsStartAccess?:
              | "all_editors"
              | "board_owners_and_coowners";
            copyAccess?: "anyone" | "team_members" | "team_editors" | "board_owner";
            sharingAccess?:
              | "team_members_with_editing_rights"
              | "owner_and_coowners";
          };
          sharingPolicy?: {
            access?: "private" | "view" | "edit" | "comment";
            inviteToAccountAndBoardLinkAccess?:
              | "viewer"
              | "commenter"
              | "editor"
              | "no_access";
            organizationAccess?: "private" | "view" | "edit" | "comment";
            teamAccess?: "private" | "view" | "edit" | "comment";
          };
        };
        teamId?: string;
        projectId?: string;
      },
    ) {
      const url = new URL(`https://api.miro.com//v2/boards`);
    
      const response = await fetch(url, {
        method: "POST",
        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