mirror of
https://github.com/dstotijn/go-notion.git
synced 2025-06-08 23:46:12 +02:00
Add description
field to Database
struct type (#34)
This commit is contained in:
parent
df02b41099
commit
b6e74a67d2
@ -995,6 +995,13 @@ func TestCreateDatabase(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
Description: []notion.RichText{
|
||||
{
|
||||
Text: ¬ion.Text{
|
||||
Content: "Lorem ipsum dolor sit amet.",
|
||||
},
|
||||
},
|
||||
},
|
||||
Properties: notion.DatabaseProperties{
|
||||
"Title": notion.DatabaseProperty{
|
||||
Type: notion.DBPropTypeTitle,
|
||||
@ -1040,6 +1047,25 @@ func TestCreateDatabase(t *testing.T) {
|
||||
"href": null
|
||||
}
|
||||
],
|
||||
"description": [
|
||||
{
|
||||
"type": "text",
|
||||
"text": {
|
||||
"content": "Lorem ipsum dolor sit amet.",
|
||||
"link": null
|
||||
},
|
||||
"annotations": {
|
||||
"bold": false,
|
||||
"italic": false,
|
||||
"strikethrough": false,
|
||||
"underline": false,
|
||||
"code": false,
|
||||
"color": "default"
|
||||
},
|
||||
"plain_text": "Lorem ipsum dolor sit amet.",
|
||||
"href": null
|
||||
}
|
||||
],
|
||||
"properties": {
|
||||
"Title": {
|
||||
"id": "title",
|
||||
@ -1078,6 +1104,13 @@ func TestCreateDatabase(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
"description": []interface{}{
|
||||
map[string]interface{}{
|
||||
"text": map[string]interface{}{
|
||||
"content": "Lorem ipsum dolor sit amet.",
|
||||
},
|
||||
},
|
||||
},
|
||||
"properties": map[string]interface{}{
|
||||
"Title": map[string]interface{}{
|
||||
"type": "title",
|
||||
@ -1117,6 +1150,18 @@ func TestCreateDatabase(t *testing.T) {
|
||||
PlainText: "Foobar",
|
||||
},
|
||||
},
|
||||
Description: []notion.RichText{
|
||||
{
|
||||
Type: notion.RichTextTypeText,
|
||||
Text: ¬ion.Text{
|
||||
Content: "Lorem ipsum dolor sit amet.",
|
||||
},
|
||||
Annotations: ¬ion.Annotations{
|
||||
Color: notion.ColorDefault,
|
||||
},
|
||||
PlainText: "Lorem ipsum dolor sit amet.",
|
||||
},
|
||||
},
|
||||
Properties: notion.DatabaseProperties{
|
||||
"Title": notion.DatabaseProperty{
|
||||
ID: "title",
|
||||
@ -1284,6 +1329,13 @@ func TestUpdateDatabase(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
Description: []notion.RichText{
|
||||
{
|
||||
Text: ¬ion.Text{
|
||||
Content: "Updated description.",
|
||||
},
|
||||
},
|
||||
},
|
||||
Properties: map[string]*notion.DatabaseProperty{
|
||||
"New": {
|
||||
Type: notion.DBPropTypeRichText,
|
||||
@ -1330,6 +1382,25 @@ func TestUpdateDatabase(t *testing.T) {
|
||||
"href": null
|
||||
}
|
||||
],
|
||||
"description": [
|
||||
{
|
||||
"type": "text",
|
||||
"text": {
|
||||
"content": "Updated description.",
|
||||
"link": null
|
||||
},
|
||||
"annotations": {
|
||||
"bold": false,
|
||||
"italic": false,
|
||||
"strikethrough": false,
|
||||
"underline": false,
|
||||
"code": false,
|
||||
"color": "default"
|
||||
},
|
||||
"plain_text": "Updated description.",
|
||||
"href": null
|
||||
}
|
||||
],
|
||||
"properties": {
|
||||
"Name": {
|
||||
"id": "title",
|
||||
@ -1369,6 +1440,13 @@ func TestUpdateDatabase(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
"description": []interface{}{
|
||||
map[string]interface{}{
|
||||
"text": map[string]interface{}{
|
||||
"content": "Updated description.",
|
||||
},
|
||||
},
|
||||
},
|
||||
"properties": map[string]interface{}{
|
||||
"New": map[string]interface{}{
|
||||
"type": "rich_text",
|
||||
@ -1405,6 +1483,18 @@ func TestUpdateDatabase(t *testing.T) {
|
||||
PlainText: "Grocery List",
|
||||
},
|
||||
},
|
||||
Description: []notion.RichText{
|
||||
{
|
||||
Type: notion.RichTextTypeText,
|
||||
Text: ¬ion.Text{
|
||||
Content: "Updated description.",
|
||||
},
|
||||
Annotations: ¬ion.Annotations{
|
||||
Color: notion.ColorDefault,
|
||||
},
|
||||
PlainText: "Updated description.",
|
||||
},
|
||||
},
|
||||
Properties: notion.DatabaseProperties{
|
||||
"Name": notion.DatabaseProperty{
|
||||
ID: "title",
|
||||
|
41
database.go
41
database.go
@ -16,6 +16,7 @@ type Database struct {
|
||||
LastEditedBy BaseUser `json:"last_edited_by"`
|
||||
URL string `json:"url"`
|
||||
Title []RichText `json:"title"`
|
||||
Description []RichText `json:"description"`
|
||||
Properties DatabaseProperties `json:"properties"`
|
||||
Parent Parent `json:"parent"`
|
||||
Icon *Icon `json:"icon,omitempty"`
|
||||
@ -298,6 +299,7 @@ type DatabaseQuerySort struct {
|
||||
type CreateDatabaseParams struct {
|
||||
ParentPageID string
|
||||
Title []RichText
|
||||
Description []RichText
|
||||
Properties DatabaseProperties
|
||||
Icon *Icon
|
||||
Cover *Cover
|
||||
@ -472,12 +474,13 @@ func (p CreateDatabaseParams) Validate() error {
|
||||
// MarshalJSON implements json.Marshaler.
|
||||
func (p CreateDatabaseParams) MarshalJSON() ([]byte, error) {
|
||||
type CreatePageParamsDTO struct {
|
||||
Parent Parent `json:"parent"`
|
||||
Title []RichText `json:"title,omitempty"`
|
||||
Properties DatabaseProperties `json:"properties"`
|
||||
Icon *Icon `json:"icon,omitempty"`
|
||||
Cover *Cover `json:"cover,omitempty"`
|
||||
IsInline bool `json:"is_inline,omitempty"`
|
||||
Parent Parent `json:"parent"`
|
||||
Title []RichText `json:"title,omitempty"`
|
||||
Description []RichText `json:"description,omitempty"`
|
||||
Properties DatabaseProperties `json:"properties"`
|
||||
Icon *Icon `json:"icon,omitempty"`
|
||||
Cover *Cover `json:"cover,omitempty"`
|
||||
IsInline bool `json:"is_inline,omitempty"`
|
||||
}
|
||||
|
||||
parent := Parent{
|
||||
@ -486,12 +489,13 @@ func (p CreateDatabaseParams) MarshalJSON() ([]byte, error) {
|
||||
}
|
||||
|
||||
dto := CreatePageParamsDTO{
|
||||
Parent: parent,
|
||||
Title: p.Title,
|
||||
Properties: p.Properties,
|
||||
Icon: p.Icon,
|
||||
Cover: p.Cover,
|
||||
IsInline: p.IsInline,
|
||||
Parent: parent,
|
||||
Title: p.Title,
|
||||
Description: p.Description,
|
||||
Properties: p.Properties,
|
||||
Icon: p.Icon,
|
||||
Cover: p.Cover,
|
||||
IsInline: p.IsInline,
|
||||
}
|
||||
|
||||
return json.Marshal(dto)
|
||||
@ -499,12 +503,13 @@ func (p CreateDatabaseParams) MarshalJSON() ([]byte, error) {
|
||||
|
||||
// UpdateDatabaseParams are the params used for updating a database.
|
||||
type UpdateDatabaseParams struct {
|
||||
Title []RichText `json:"title,omitempty"`
|
||||
Properties map[string]*DatabaseProperty `json:"properties,omitempty"`
|
||||
Icon *Icon `json:"icon,omitempty"`
|
||||
Cover *Cover `json:"cover,omitempty"`
|
||||
Archived *bool `json:"archived,omitempty"`
|
||||
IsInline *bool `json:"is_inline,omitempty"`
|
||||
Title []RichText `json:"title,omitempty"`
|
||||
Description []RichText `json:"description,omitempty"`
|
||||
Properties map[string]*DatabaseProperty `json:"properties,omitempty"`
|
||||
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.
|
||||
|
Loading…
x
Reference in New Issue
Block a user