Skip to content

Gh 54 user object #55

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 52 additions & 6 deletions client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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",
Expand All @@ -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": "[email protected]"
}
}
]
}
}
}`,
Expand All @@ -2312,6 +2335,13 @@ func TestUpdatePage(t *testing.T) {
},
},
},
"People": map[string]interface{}{
"people": []interface{}{
map[string]interface{}{
"id": "user-id",
},
},
},
},
},
expResponse: notion.Page{
Expand All @@ -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,
Expand All @@ -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: &notion.Person{Email: "[email protected]"},
Bot: nil,
},
},
},
},
},
expError: nil,
Expand Down
10 changes: 5 additions & 5 deletions user.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down