1
0
mirror of https://github.com/dstotijn/go-notion.git synced 2025-06-19 00:17:44 +02:00

Add support for is_inline for databases (#33)

This commit is contained in:
David Stotijn
2022-08-14 11:43:19 +02:00
committed by GitHub
parent 8519feef2f
commit df02b41099
2 changed files with 15 additions and 2 deletions

View File

@ -1011,6 +1011,7 @@ func TestCreateDatabase(t *testing.T) {
URL: "https://example.com/image.png",
},
},
IsInline: true,
},
respBody: func(_ *http.Request) io.Reader {
return strings.NewReader(
@ -1059,7 +1060,8 @@ func TestCreateDatabase(t *testing.T) {
"external": {
"url": "https://example.com/image.png"
}
}
},
"is_inline": true
}`,
)
},
@ -1092,6 +1094,7 @@ func TestCreateDatabase(t *testing.T) {
"url": "https://example.com/image.png",
},
},
"is_inline": true,
},
expResponse: notion.Database{
ID: "b89664e3-30b4-474a-9cce-c72a4827d1e4",
@ -1131,6 +1134,7 @@ func TestCreateDatabase(t *testing.T) {
URL: "https://example.com/image.png",
},
},
IsInline: true,
},
expError: nil,
},
@ -1297,6 +1301,7 @@ func TestUpdateDatabase(t *testing.T) {
URL: "https://example.com/image.png",
},
},
IsInline: notion.BoolPtr(true),
},
respBody: func(_ *http.Request) io.Reader {
return strings.NewReader(
@ -1350,7 +1355,8 @@ func TestUpdateDatabase(t *testing.T) {
"external": {
"url": "https://example.com/image.png"
}
}
},
"is_inline": true
}`,
)
},
@ -1380,6 +1386,7 @@ func TestUpdateDatabase(t *testing.T) {
"url": "https://example.com/image.png",
},
},
"is_inline": true,
},
expResponse: notion.Database{
ID: "668d797c-76fa-4934-9b05-ad288df2d136",
@ -1423,6 +1430,7 @@ func TestUpdateDatabase(t *testing.T) {
URL: "https://example.com/image.png",
},
},
IsInline: true,
},
expError: nil,
},

View File

@ -21,6 +21,7 @@ type Database struct {
Icon *Icon `json:"icon,omitempty"`
Cover *Cover `json:"cover,omitempty"`
Archived bool `json:"archived"`
IsInline bool `json:"is_inline"`
}
// DatabaseProperties is a mapping of properties defined on a database.
@ -300,6 +301,7 @@ type CreateDatabaseParams struct {
Properties DatabaseProperties
Icon *Icon
Cover *Cover
IsInline bool
}
type (
@ -475,6 +477,7 @@ func (p CreateDatabaseParams) MarshalJSON() ([]byte, error) {
Properties DatabaseProperties `json:"properties"`
Icon *Icon `json:"icon,omitempty"`
Cover *Cover `json:"cover,omitempty"`
IsInline bool `json:"is_inline,omitempty"`
}
parent := Parent{
@ -488,6 +491,7 @@ func (p CreateDatabaseParams) MarshalJSON() ([]byte, error) {
Properties: p.Properties,
Icon: p.Icon,
Cover: p.Cover,
IsInline: p.IsInline,
}
return json.Marshal(dto)
@ -500,6 +504,7 @@ type UpdateDatabaseParams struct {
Icon *Icon `json:"icon,omitempty"`
Cover *Cover `json:"cover,omitempty"`
Archived *bool `json:"archived,omitempty"`
IsInline *bool `json:"is_inline,omitempty"`
}
// Validate validates params for updating a database.