Skip to content

Commit

Permalink
Add support for is_inline for databases (#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
dstotijn authored Aug 14, 2022
1 parent 8519fee commit df02b41
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
12 changes: 10 additions & 2 deletions client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -1059,7 +1060,8 @@ func TestCreateDatabase(t *testing.T) {
"external": {
"url": "https://example.com/image.png"
}
}
},
"is_inline": true
}`,
)
},
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -1131,6 +1134,7 @@ func TestCreateDatabase(t *testing.T) {
URL: "https://example.com/image.png",
},
},
IsInline: true,
},
expError: nil,
},
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -1350,7 +1355,8 @@ func TestUpdateDatabase(t *testing.T) {
"external": {
"url": "https://example.com/image.png"
}
}
},
"is_inline": true
}`,
)
},
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -1423,6 +1430,7 @@ func TestUpdateDatabase(t *testing.T) {
URL: "https://example.com/image.png",
},
},
IsInline: true,
},
expError: nil,
},
Expand Down
5 changes: 5 additions & 0 deletions database.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -300,6 +301,7 @@ type CreateDatabaseParams struct {
Properties DatabaseProperties
Icon *Icon
Cover *Cover
IsInline bool
}

type (
Expand Down Expand Up @@ -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{
Expand All @@ -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)
Expand All @@ -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.
Expand Down

0 comments on commit df02b41

Please sign in to comment.