Repository: seratch/notion-sdk-jvm (kotlin)

Issue:
How to archive page via API?
Please give example рow to remove / archive page via API.

Pull request:
This pull request fixes #27

Patch:
diff --git a/core/src/main/kotlin/notion/api/v1/endpoint/PagesSupport.kt b/core/src/main/kotlin/notion/api/v1/endpoint/PagesSupport.kt
index 4537987..b6a896a 100644
--- a/core/src/main/kotlin/notion/api/v1/endpoint/PagesSupport.kt
+++ b/core/src/main/kotlin/notion/api/v1/endpoint/PagesSupport.kt
@@ -89,6 +89,7 @@ interface PagesSupport : EndpointsSupport {
   fun updatePageProperties(
       pageId: String,
       properties: Map<String, PageProperty>,
+      archived: Boolean? = null,
       icon: Icon? = null,
       cover: Cover? = null,
   ): Page {
@@ -96,6 +97,7 @@ interface PagesSupport : EndpointsSupport {
         UpdatePagePropertiesRequest(
             pageId = pageId,
             properties = properties,
+            archived = archived,
             icon = icon,
             cover = cover,
         ))
diff --git a/core/src/main/kotlin/notion/api/v1/request/pages/UpdatePagePropertiesRequest.kt b/core/src/main/kotlin/notion/api/v1/request/pages/UpdatePagePropertiesRequest.kt
index 493009c..75331b5 100644
--- a/core/src/main/kotlin/notion/api/v1/request/pages/UpdatePagePropertiesRequest.kt
+++ b/core/src/main/kotlin/notion/api/v1/request/pages/UpdatePagePropertiesRequest.kt
@@ -9,6 +9,7 @@ data class UpdatePagePropertiesRequest
 constructor(
     @Transient val pageId: String,
     val properties: Map<String, PageProperty>,
+    val archived: Boolean? = null,
     val icon: Icon? = null,
     val cover: Cover? = null,
 )
diff --git a/scala3/src/main/scala/notion/api/v1/ScalaNotionClient.scala b/scala3/src/main/scala/notion/api/v1/ScalaNotionClient.scala
index 8484511..0aa2680 100644
--- a/scala3/src/main/scala/notion/api/v1/ScalaNotionClient.scala
+++ b/scala3/src/main/scala/notion/api/v1/ScalaNotionClient.scala
@@ -179,12 +179,14 @@ case class ScalaNotionClient(
   def updatePageProperties(
       pageId: String,
       properties: Map[String, PageProperty],
+      archive: Boolean = false,
       icon: Icon = null,
       cover: Cover = null
   ): Page = {
     val request = new UpdatePagePropertiesRequest(
       pageId,
       properties.asJava,
+      if (archive) archive else null,
       icon,
       cover
     )


Test patch:
diff --git a/core/src/test/kotlin/integration_tests/PagesTest.kt b/core/src/test/kotlin/integration_tests/PagesTest.kt
index e1e299e..011833b 100644
--- a/core/src/test/kotlin/integration_tests/PagesTest.kt
+++ b/core/src/test/kotlin/integration_tests/PagesTest.kt
@@ -1,9 +1,6 @@
 package integration_tests
 
-import kotlin.test.assertEquals
-import kotlin.test.assertNotEquals
-import kotlin.test.assertNotNull
-import kotlin.test.assertTrue
+import kotlin.test.*
 import notion.api.v1.NotionClient
 import notion.api.v1.model.pages.Page
 import notion.api.v1.model.pages.PageParent
@@ -72,6 +69,11 @@ class PagesTest {
 
       val fetchedPage = client.retrievePage(newPage.id)
       assertEquals(patchResult.lastEditedTime, fetchedPage.lastEditedTime)
+      assertFalse(fetchedPage.archived!!)
+
+      val archivedPage =
+          client.updatePageProperties(pageId = newPage.id, properties = emptyMap(), archived = true)
+      assertTrue(archivedPage.archived!!)
     }
   }
 }
diff --git a/core/src/test/kotlin/integration_tests/SimpleTest.kt b/core/src/test/kotlin/integration_tests/SimpleTest.kt
index a710dcc..30cfcec 100644
--- a/core/src/test/kotlin/integration_tests/SimpleTest.kt
+++ b/core/src/test/kotlin/integration_tests/SimpleTest.kt
@@ -1,5 +1,6 @@
 package integration_tests
 
+import kotlin.test.assertFalse
 import kotlin.test.assertNotNull
 import kotlin.test.assertTrue
 import notion.api.v1.NotionClient
@@ -72,6 +73,11 @@ class SimpleTest {
 
       val fetchedPage = client.retrievePage(newPage.id)
       assertNotNull(fetchedPage)
+      assertFalse(fetchedPage.archived!!)
+
+      val archivedPage =
+          client.updatePageProperties(pageId = newPage.id, properties = emptyMap(), archived = true)
+      assertTrue(archivedPage.archived!!)
     }
   }
 }