Repository: seratch/notion-sdk-jvm
Pull request #109 (2023-10-15 13:28:15)

PropertyFilter: add rollup option
Rollup property search spec can be found at: https://developers.notion.com/reference/post-database-query-filter#rollup

In short:

* Rollup properties have content of any other kind.
* Filters consume the same properties like all the other filters (except for the "property" field, which is already specified)

So a new `RollupFilter` class was created with an inner class `RollupFilter.Content` for the content spec.
That calss was registered as `rollup` in `PropertyFilter`.


Patch:
diff --git a/core/src/main/kotlin/notion/api/v1/model/databases/query/filter/PropertyFilter.kt b/core/src/main/kotlin/notion/api/v1/model/databases/query/filter/PropertyFilter.kt
index a987df1..fee9f4f 100644
--- a/core/src/main/kotlin/notion/api/v1/model/databases/query/filter/PropertyFilter.kt
+++ b/core/src/main/kotlin/notion/api/v1/model/databases/query/filter/PropertyFilter.kt
@@ -25,4 +25,5 @@ constructor(
     var relation: RelationFilter? = null,
     var formula: FormulaFilter? = null,
     var status: StatusFilter? = null,
+    var rollup: RollupFilter? = null,
 ) : QueryTopLevelFilter, CompoundFilterElement
diff --git a/core/src/main/kotlin/notion/api/v1/model/databases/query/filter/condition/RollupFilter.kt b/core/src/main/kotlin/notion/api/v1/model/databases/query/filter/condition/RollupFilter.kt
new file mode 100644
index 0000000..a775231
--- /dev/null
+++ b/core/src/main/kotlin/notion/api/v1/model/databases/query/filter/condition/RollupFilter.kt
@@ -0,0 +1,34 @@
+package notion.api.v1.model.databases.query.filter.condition
+
+open class RollupFilter
+@JvmOverloads
+constructor(
+    var any: Content? = null,
+    var every: Content? = null,
+    var none: Content? = null,
+) {
+  open class Content
+  @JvmOverloads
+  constructor(
+      var title: TextFilter? = null,
+      var richText: TextFilter? = null,
+      var url: TextFilter? = null,
+      var email: TextFilter? = null,
+      var phoneNumber: TextFilter? = null,
+      var number: NumberFilter? = null,
+      var checkbox: CheckboxFilter? = null,
+      var select: SelectFilter? = null,
+      var multiSelect: MultiSelectFilter? = null,
+      var date: DateFilter? = null,
+      var timestamp: String? = null, // "created_time", "last_edited_time"
+      var createdTime: TimestampFilter? = null,
+      var lastEditedTime: TimestampFilter? = null,
+      var createdBy: PeopleFilter? = null,
+      var lastEditedBy: PeopleFilter? = null,
+      var file: FilesFilter? = null,
+      var relation: RelationFilter? = null,
+      var formula: FormulaFilter? = null,
+      var status: StatusFilter? = null,
+      var rollup: RollupFilter? = null,
+  )
+}
diff --git a/core/src/main/kotlin/notion/api/v1/model/pages/PageProperty.kt b/core/src/main/kotlin/notion/api/v1/model/pages/PageProperty.kt
index 23d49b4..d3f1ab5 100644
--- a/core/src/main/kotlin/notion/api/v1/model/pages/PageProperty.kt
+++ b/core/src/main/kotlin/notion/api/v1/model/pages/PageProperty.kt
@@ -106,5 +106,6 @@ constructor(
       val number: Number? = null,
       val array: List<PageProperty>? = null,
       val function: String? = null,
+      val date: Date? = null,
   )
 }


Test patch:
diff --git a/core/src/test/kotlin/tests/model/PagesTest.kt b/core/src/test/kotlin/tests/model/PagesTest.kt
index c74bd66..47a6d93 100644
--- a/core/src/test/kotlin/tests/model/PagesTest.kt
+++ b/core/src/test/kotlin/tests/model/PagesTest.kt
@@ -44,6 +44,19 @@ class PagesTest {
         }
       ]
     },
+    "Rollup Property": {
+      "id": "da010d01-6406-43d1-ae03-4b4b6989bbd9",
+      "type": "rollup",
+      "rollup": {
+        "type": "date",
+        "function": "opaque_value",
+        "date": {
+          "start": "2023-03-09T00:00:00.000+00:00",
+          "end": null,
+          "time_zone": null
+        }
+      }
+    },
     "Due": {
       "id": "da010d01-6406-43d1-ae03-4b4b6989bbd8",
       "date": {