fetch method

Future<NotionResponse> fetch(
  1. String id, {
  2. String? startCursor,
  3. int? pageSize,
})

Retrieve the block children from block with id.

A startCursor can be defined to specify the page where to start. Also a pageSize can be defined to limit the result. The max value is 100.

See more at https://developers.notion.com/reference/get-block-children

Implementation

Future<NotionResponse> fetch(
  String id, {
  String? startCursor,
  int? pageSize,
}) async {
  Map<String, dynamic> query = {};
  if (startCursor != null) {
    query['start_cursor'] = startCursor;
  }
  if (pageSize != null && pageSize >= 0 && pageSize <= 100) {
    query['page_size'] = pageSize.toString();
  }

  http.Response response = await http
      .get(Uri.https(host, '/$v/$path/$id/children', query), headers: {
    'Authorization': 'Bearer $token',
    'Notion-Version': dateVersion,
  });

  return NotionResponse.fromResponse(response);
}