update method

Future<NotionResponse> update(
  1. String id, {
  2. Properties? properties,
  3. bool? archived,
})

Update the properties of the page with an specified id. Can also mark the page as archived.

The page should contain the property to update.

Archive a page is the equivalent to delete it according to API reference.

See more at https://developers.notion.com/reference/patch-page

Implementation

Future<NotionResponse> update(
  String id, {
  Properties? properties,
  bool? archived,
}) async {
  Properties _properties = properties ?? Properties.empty();
  http.Response res = await http.patch(Uri.https(host, '/$v/$path/$id'),
      body: jsonEncode({
        'properties': _properties.toJson(),
        if (archived != null) 'archived': archived,
      }),
      headers: {
        'Authorization': 'Bearer $token',
        'Content-Type': 'application/json',
        'Notion-Version': dateVersion,
      });

  return NotionResponse.fromResponse(res);
}