mirror of
https://github.com/dstotijn/go-notion.git
synced 2025-06-10 23:47:33 +02:00
parent
14d2e8c377
commit
c675641a4c
160
client_test.go
160
client_test.go
@ -477,6 +477,86 @@ func TestQueryDatabase(t *testing.T) {
|
||||
"type": "number",
|
||||
"number": 42
|
||||
},
|
||||
"People": {
|
||||
"id": "1#nc",
|
||||
"type": "people",
|
||||
"people": [
|
||||
{
|
||||
"id": "be32e790-8292-46df-a248-b784fdf483cf",
|
||||
"name": "Jane Doe",
|
||||
"avatar_url": "https://example.com/image.png",
|
||||
"type": "person",
|
||||
"person": {
|
||||
"email": "jane@example.com"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"Files": {
|
||||
"id": "!$9x",
|
||||
"type": "files",
|
||||
"files": [
|
||||
{
|
||||
"name": "foobar.pdf"
|
||||
}
|
||||
]
|
||||
},
|
||||
"Checkbox": {
|
||||
"id": "49S@",
|
||||
"type": "checkbox",
|
||||
"checkbox": true
|
||||
},
|
||||
"URL": {
|
||||
"id": "93$$",
|
||||
"type": "url",
|
||||
"url": "https://example.com"
|
||||
},
|
||||
"Email": {
|
||||
"id": "xb3Q",
|
||||
"type": "email",
|
||||
"email": "jane@example.com"
|
||||
},
|
||||
"PhoneNumber": {
|
||||
"id": "c2#Q",
|
||||
"type": "phone_number",
|
||||
"phone_number": "867-5309"
|
||||
},
|
||||
"CreatedTime": {
|
||||
"id": "s#0s",
|
||||
"type": "created_time",
|
||||
"created_time": "2021-05-24T15:44:09.123Z"
|
||||
},
|
||||
"CreatedBy": {
|
||||
"id": "49S@",
|
||||
"type": "created_by",
|
||||
"created_by": {
|
||||
"id": "be32e790-8292-46df-a248-b784fdf483cf",
|
||||
"name": "Jane Doe",
|
||||
"avatar_url": "https://example.com/image.png",
|
||||
"type": "person",
|
||||
"person": {
|
||||
"email": "jane@example.com"
|
||||
}
|
||||
}
|
||||
},
|
||||
"LastEditedTime": {
|
||||
"id": "x#0s",
|
||||
"type": "last_edited_time",
|
||||
"last_edited_time": "2021-05-24T15:44:09.123Z"
|
||||
},
|
||||
"LastEditedBy": {
|
||||
"id": "x9S@",
|
||||
"type": "last_edited_by",
|
||||
"last_edited_by": {
|
||||
"id": "be32e790-8292-46df-a248-b784fdf483cf",
|
||||
"name": "Jane Doe",
|
||||
"avatar_url": "https://example.com/image.png",
|
||||
"type": "person",
|
||||
"person": {
|
||||
"email": "jane@example.com"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Calculation": {
|
||||
"id": "s(4f",
|
||||
"type": "formula",
|
||||
@ -576,6 +656,35 @@ func TestQueryDatabase(t *testing.T) {
|
||||
Type: notion.DBPropTypeNumber,
|
||||
Number: notion.Float64Ptr(42),
|
||||
},
|
||||
"People": notion.DatabasePageProperty{
|
||||
ID: "1#nc",
|
||||
Type: notion.DBPropTypePeople,
|
||||
People: []notion.User{
|
||||
{
|
||||
ID: "be32e790-8292-46df-a248-b784fdf483cf",
|
||||
Name: "Jane Doe",
|
||||
AvatarURL: notion.StringPtr("https://example.com/image.png"),
|
||||
Type: "person",
|
||||
Person: ¬ion.Person{
|
||||
Email: "jane@example.com",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"Files": notion.DatabasePageProperty{
|
||||
ID: "!$9x",
|
||||
Type: notion.DBPropTypeFiles,
|
||||
Files: []notion.File{
|
||||
{
|
||||
Name: "foobar.pdf",
|
||||
},
|
||||
},
|
||||
},
|
||||
"Checkbox": notion.DatabasePageProperty{
|
||||
ID: "49S@",
|
||||
Type: notion.DBPropTypeCheckbox,
|
||||
Checkbox: notion.BoolPtr(true),
|
||||
},
|
||||
"Calculation": notion.DatabasePageProperty{
|
||||
ID: "s(4f",
|
||||
Type: notion.DBPropTypeFormula,
|
||||
@ -584,6 +693,57 @@ func TestQueryDatabase(t *testing.T) {
|
||||
Number: notion.Float64Ptr(float64(42)),
|
||||
},
|
||||
},
|
||||
"URL": notion.DatabasePageProperty{
|
||||
ID: "93$$",
|
||||
Type: notion.DBPropTypeURL,
|
||||
URL: notion.StringPtr("https://example.com"),
|
||||
},
|
||||
"Email": notion.DatabasePageProperty{
|
||||
ID: "xb3Q",
|
||||
Type: notion.DBPropTypeEmail,
|
||||
Email: notion.StringPtr("jane@example.com"),
|
||||
},
|
||||
"PhoneNumber": notion.DatabasePageProperty{
|
||||
ID: "c2#Q",
|
||||
Type: notion.DBPropTypePhoneNumber,
|
||||
PhoneNumber: notion.StringPtr("867-5309"),
|
||||
},
|
||||
"CreatedTime": notion.DatabasePageProperty{
|
||||
ID: "s#0s",
|
||||
Type: notion.DBPropTypeCreatedTime,
|
||||
CreatedTime: notion.TimePtr(mustParseTime(time.RFC3339Nano, "2021-05-24T15:44:09.123Z")),
|
||||
},
|
||||
"CreatedBy": notion.DatabasePageProperty{
|
||||
ID: "49S@",
|
||||
Type: notion.DBPropTypeCreatedBy,
|
||||
CreatedBy: ¬ion.User{
|
||||
ID: "be32e790-8292-46df-a248-b784fdf483cf",
|
||||
Name: "Jane Doe",
|
||||
AvatarURL: notion.StringPtr("https://example.com/image.png"),
|
||||
Type: "person",
|
||||
Person: ¬ion.Person{
|
||||
Email: "jane@example.com",
|
||||
},
|
||||
},
|
||||
},
|
||||
"LastEditedTime": notion.DatabasePageProperty{
|
||||
ID: "x#0s",
|
||||
Type: notion.DBPropTypeLastEditedTime,
|
||||
LastEditedTime: notion.TimePtr(mustParseTime(time.RFC3339Nano, "2021-05-24T15:44:09.123Z")),
|
||||
},
|
||||
"LastEditedBy": notion.DatabasePageProperty{
|
||||
ID: "x9S@",
|
||||
Type: notion.DBPropTypeLastEditedBy,
|
||||
LastEditedBy: ¬ion.User{
|
||||
ID: "be32e790-8292-46df-a248-b784fdf483cf",
|
||||
Name: "Jane Doe",
|
||||
AvatarURL: notion.StringPtr("https://example.com/image.png"),
|
||||
Type: "person",
|
||||
Person: ¬ion.Person{
|
||||
Email: "jane@example.com",
|
||||
},
|
||||
},
|
||||
},
|
||||
"Relation": notion.DatabasePageProperty{
|
||||
ID: "Cxl[",
|
||||
Type: notion.DBPropTypeRelation,
|
||||
|
36
database.go
36
database.go
@ -73,46 +73,10 @@ type People struct {
|
||||
People []User `json:"people"`
|
||||
}
|
||||
|
||||
type Files struct {
|
||||
Files []File `json:"people"`
|
||||
}
|
||||
|
||||
type File struct {
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
type Checkbox struct {
|
||||
Checkbox bool `json:"checked"`
|
||||
}
|
||||
|
||||
type URL struct {
|
||||
URL string `json:"url"`
|
||||
}
|
||||
|
||||
type Email struct {
|
||||
Email string `json:"email"`
|
||||
}
|
||||
|
||||
type PhoneNumber struct {
|
||||
PhoneNumber string `json:"phone_number"`
|
||||
}
|
||||
|
||||
type CreatedTime struct {
|
||||
CreatedTime time.Time `json:"created_time"`
|
||||
}
|
||||
|
||||
type CreatedBy struct {
|
||||
CreatedBy User `json:"created_by"`
|
||||
}
|
||||
|
||||
type LastEditedTime struct {
|
||||
LastEditedTime time.Time `json:"last_edited_time"`
|
||||
}
|
||||
|
||||
type LastEditedBy struct {
|
||||
LastEditedBy User `json:"last_edited_by"`
|
||||
}
|
||||
|
||||
type DatabaseProperty struct {
|
||||
ID string `json:"id"`
|
||||
Type DatabasePropertyType `json:"type"`
|
||||
|
20
page.go
20
page.go
@ -54,16 +54,16 @@ type DatabasePageProperty struct {
|
||||
Formula *FormulaResult `json:"formula,omitempty"`
|
||||
Relation []Relation `json:"relation,omitempty"`
|
||||
Rollup *RollupResult `json:"rollup,omitempty"`
|
||||
People *People `json:"people,omitempty"`
|
||||
Files *Files `json:"files,omitempty"`
|
||||
Checkbox *Checkbox `json:"checkbox,omitempty"`
|
||||
URL *URL `json:"url,omitempty"`
|
||||
Email *Email `json:"email,omitempty"`
|
||||
PhoneNumber *PhoneNumber `json:"phone_number,omitempty"`
|
||||
CreatedTime *CreatedTime `json:"created_time,omitempty"`
|
||||
CreatedBy *CreatedBy `json:"created_by,omitempty"`
|
||||
LastEditedTime *LastEditedTime `json:"last_edited_time,omitempty"`
|
||||
LastEditedBy *LastEditedBy `json:"last_edited_by,omitempty"`
|
||||
People []User `json:"people,omitempty"`
|
||||
Files []File `json:"files,omitempty"`
|
||||
Checkbox *bool `json:"checkbox,omitempty"`
|
||||
URL *string `json:"url,omitempty"`
|
||||
Email *string `json:"email,omitempty"`
|
||||
PhoneNumber *string `json:"phone_number,omitempty"`
|
||||
CreatedTime *time.Time `json:"created_time,omitempty"`
|
||||
CreatedBy *User `json:"created_by,omitempty"`
|
||||
LastEditedTime *time.Time `json:"last_edited_time,omitempty"`
|
||||
LastEditedBy *User `json:"last_edited_by,omitempty"`
|
||||
}
|
||||
|
||||
// CreatePageParams are the params used for creating a page.
|
||||
|
Loading…
x
Reference in New Issue
Block a user