diff --git a/client_test.go b/client_test.go index 31bba72..a9e81d2 100644 --- a/client_test.go +++ b/client_test.go @@ -2257,6 +2257,13 @@ func TestUpdatePage(t *testing.T) { }, }, }, + "People": notion.DatabasePageProperty{ + People: []notion.User{ + notion.User{ + BaseUser: notion.BaseUser{ID: "user-id"}, + }, + }, + }, }, }, respBody: func(_ *http.Request) io.Reader { @@ -2267,8 +2274,8 @@ func TestUpdatePage(t *testing.T) { "created_time": "2021-05-14T09:15:46.796Z", "last_edited_time": "2021-05-22T15:54:31.116Z", "parent": { - "type": "page_id", - "page_id": "b0668f48-8d66-4733-9bdb-2f82215707f7" + "type": "database_id", + "database_id": "b0668f48-8d66-4733-9bdb-2f82215707f7" }, "archived": false, "url": "https://www.notion.so/Avocado-251d2b5f268c4de2afe9c71ff92ca95c", @@ -2295,6 +2302,22 @@ func TestUpdatePage(t *testing.T) { "href": null } ] + }, + "People": { + "id": "people", + "type": "people", + "people": [ + { + "object": "user", + "id": "user-id", + "name": "name", + "avatar_url": null, + "type": "person", + "person": { + "email": "person@organization.com" + } + } + ] } } }`, @@ -2312,6 +2335,13 @@ func TestUpdatePage(t *testing.T) { }, }, }, + "People": map[string]interface{}{ + "people": []interface{}{ + map[string]interface{}{ + "id": "user-id", + }, + }, + }, }, }, expResponse: notion.Page{ @@ -2320,11 +2350,13 @@ func TestUpdatePage(t *testing.T) { LastEditedTime: mustParseTime(time.RFC3339Nano, "2021-05-22T15:54:31.116Z"), URL: "https://www.notion.so/Avocado-251d2b5f268c4de2afe9c71ff92ca95c", Parent: notion.Parent{ - Type: notion.ParentTypePage, - PageID: "b0668f48-8d66-4733-9bdb-2f82215707f7", + Type: notion.ParentTypeDatabase, + DatabaseID: "b0668f48-8d66-4733-9bdb-2f82215707f7", }, - Properties: notion.PageProperties{ - Title: notion.PageTitle{ + Properties: notion.DatabasePageProperties{ + "title": notion.DatabasePageProperty{ + ID: "title", + Type: notion.DBPropTypeTitle, Title: []notion.RichText{ { Type: notion.RichTextTypeText, @@ -2338,6 +2370,20 @@ func TestUpdatePage(t *testing.T) { }, }, }, + "People": notion.DatabasePageProperty{ + ID: "people", + Type: notion.DBPropTypePeople, + People: []notion.User{ + notion.User{ + BaseUser: notion.BaseUser{ID: "user-id"}, + Type: notion.UserTypePerson, + Name: "name", + AvatarURL: "", + Person: ¬ion.Person{Email: "person@organization.com"}, + Bot: nil, + }, + }, + }, }, }, expError: nil, diff --git a/user.go b/user.go index c4d2f32..2a1dc5e 100644 --- a/user.go +++ b/user.go @@ -37,12 +37,12 @@ type BaseUser struct { type User struct { BaseUser - Type UserType `json:"type"` - Name string `json:"name"` - AvatarURL string `json:"avatar_url"` + Type UserType `json:"type,omitempty"` + Name string `json:"name,omitempty"` + AvatarURL string `json:"avatar_url,omitempty"` - Person *Person `json:"person"` - Bot *Bot `json:"bot"` + Person *Person `json:"person,omitempty"` + Bot *Bot `json:"bot,omitempty"` } // ListUsersResponse contains results (users) and pagination data returned from a list request.