Skip to content

Commit f02be05

Browse files
shivaji17jomei
authored andcommitted
Added BlockID and Workspace to Parent object
1 parent d262c63 commit f02be05

File tree

5 files changed

+12
-8
lines changed

5 files changed

+12
-8
lines changed

const.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ const (
180180
ParentTypeDatabaseID ParentType = "database_id"
181181
ParentTypePageID ParentType = "page_id"
182182
ParentTypeWorkspace ParentType = "workspace"
183+
ParentTypeBlockID ParentType = "block_id"
183184
)
184185

185186
const (

database_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,8 @@ func TestDatabaseClient(t *testing.T) {
195195
CreatedBy: user,
196196
LastEditedBy: user,
197197
Parent: notionapi.Parent{
198-
Type: "page_id",
199-
PageID: "48f8fee9-cd79-4180-bc2f-ec0398253067",
198+
Type: "block_id",
199+
BlockID: "48f8fee9-cd79-4180-bc2f-ec0398253067",
200200
},
201201
Title: []notionapi.RichText{
202202
{
@@ -265,8 +265,8 @@ func TestDatabaseClient(t *testing.T) {
265265
CreatedBy: user,
266266
LastEditedBy: user,
267267
Parent: notionapi.Parent{
268-
Type: "page_id",
269-
PageID: "a7744006-9233-4cd0-bf44-3a49de2c01b5",
268+
Type: "block_id",
269+
BlockID: "a7744006-9233-4cd0-bf44-3a49de2c01b5",
270270
},
271271
Title: []notionapi.RichText{
272272
{

page.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,13 @@ func (p *Page) GetObject() ObjectType {
101101

102102
type ParentType string
103103

104+
// Ref: https://developers.notion.com/reference/parent-object
104105
type Parent struct {
105106
Type ParentType `json:"type,omitempty"`
106107
PageID PageID `json:"page_id,omitempty"`
107108
DatabaseID DatabaseID `json:"database_id,omitempty"`
109+
BlockID BlockID `json:"block_id,omitempty"`
110+
Workspace bool `json:"workspace,omitempty"`
108111
}
109112

110113
type PageCreateRequest struct {

testdata/database_create.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
}
4242
],
4343
"parent": {
44-
"type": "page_id",
45-
"page_id": "a7744006-9233-4cd0-bf44-3a49de2c01b5"
44+
"type": "block_id",
45+
"block_id": "a7744006-9233-4cd0-bf44-3a49de2c01b5"
4646
}
4747
}

testdata/database_update.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
"id": "some_id"
1313
},
1414
"parent": {
15-
"type": "page_id",
16-
"page_id": "48f8fee9-cd79-4180-bc2f-ec0398253067"
15+
"type": "block_id",
16+
"block_id": "48f8fee9-cd79-4180-bc2f-ec0398253067"
1717
},
1818
"icon": {
1919
"type": "emoji",

0 commit comments

Comments
 (0)