getBoard method

Future<MondayBoard> getBoard(
  1. String boardId
)

Implementation

Future<MondayBoard> getBoard(String boardId) async {
  final intBoardId = int.tryParse(boardId);
  if (intBoardId == null) {
    throw Exception('Board ID must be numeric. Given: $boardId');
  }

  final query = '''
  query {
    boards(ids: [$intBoardId]) {
      id
      name
      description
      state
      owner {
        id
        name
      }
      columns {
        id
        title
        type
      }
    }
  }
''';

  final responseJson = await postQuery(query);
  final boardsJson = responseJson['data']['boards'] as List<dynamic>;
  if (boardsJson.isEmpty) {
    throw Exception('Board not found: $boardId');
  }

  return MondayBoard.fromJson(boardsJson.first as Map<String, dynamic>);
}