Relation が Pagination 対応になったようです。NotionRubyMapping ではこの対応のために、relation を取得できる仕組みを作りたいなと考えています。
最新の更新は以下のとおりです。
relation プロパティ値は Retrieve a page endpoint で取得された時にも、 has_more プロパティを持つようになりました。関連が 25 ページを越える時には、 has_more が true になって返ってきます(それ未満の時には false が返ります)。workspace_name プロパティが追加されました。もし、bot の owner.type が "workspace" の場合には、ボットを所有しているworkspace.name が表示されます。逆に、 owner.type が "user" の場合には、 workspace.name は nullになります。このページを取得し、リレーションプロパティの中身を確認してみました。確かに has_more が入っていますね。現状の NotionRubyMapping では JSON が "id" のみだった時に Retrieve a page property item endpoint を呼ぶようにしているのですが、has_more をチェックして true の時に呼び出すように変更すればいい感じですかね。v0.6.8 は細々とした修正を入れてリリース予定なのですが、これも一緒に入れておきます。
# ページを取得
page = Page.find "<https://hkob.notion.site/2022-9-26-10-10-7e47>
8b17949543d3b34df783aa8658a5"
=> NotionRubyMapping::Page-7e478b17949543d3b34df783aa8658a5
# プロパティの中のリレーションだけを表示
print JSON.pretty_generate(page.json["properties"]["前のリリース"])
{
"id": "kr%7BA",
"type": "relation",
"relation": [
{
"id": "79ed443c-fe92-4116-bf5b-aa582a711630"
}
],
"has_more": false
}=> nil
まだ内部検証中の 0.6.8 で導入している find_me で試してみました。確かに workspace_name が入っていますね。
bot = UserObject.find_me
=> NotionRubyMapping::UserObject-40673a87d8ed41e0aa557f0e8ace24cd
irb(main):005:0> print JSON.pretty_generate(bot.json)
{
"object": "user",
"id": "40673a87-d8ed-41e0-aa55-7f0e8ace24cd",
"name": "input_tasks",
"avatar_url": "<https://s3-us-west-2.amazonaws.com/public.notion-static.com/d1f637eb-7242-43c1-9500-747bac40275a/1ea5da4c6b0b10c5ed42b763c162fcd9.png>",
"type": "bot",
"bot": {
"owner": {
"type": "workspace",
"workspace": true
},
"workspace_name": "Hiroyuki's Notion"
}
}=> nil