diff --git a/block_test.go b/block_test.go index 5c0aac8..1706060 100644 --- a/block_test.go +++ b/block_test.go @@ -84,7 +84,7 @@ func TestBlockClient(t *testing.T) { IsToggleable bool `json:"is_toggleable,omitempty"` }{[]notionapi.RichText{ { - Type: notionapi.ObjectTypeText, + Type: notionapi.RichTextTypeText, Text: ¬ionapi.Text{Content: "Hello"}, }, }, nil, "", false, @@ -114,7 +114,7 @@ func TestBlockClient(t *testing.T) { Paragraph: notionapi.Paragraph{ RichText: []notionapi.RichText{ { - Type: notionapi.ObjectTypeText, + Type: notionapi.RichTextTypeText, Text: ¬ionapi.Text{Content: "AAAAAA"}, Annotations: ¬ionapi.Annotations{ Bold: true, @@ -259,7 +259,7 @@ func TestBlockClient(t *testing.T) { Paragraph: notionapi.Paragraph{ RichText: []notionapi.RichText{ { - Type: notionapi.ObjectTypeText, + Type: notionapi.RichTextTypeText, Text: ¬ionapi.Text{ Content: "Hello", }, diff --git a/comment_test.go b/comment_test.go index 52ae1a1..2093fd6 100644 --- a/comment_test.go +++ b/comment_test.go @@ -52,7 +52,7 @@ func TestCommentClient(t *testing.T) { }, RichText: []notionapi.RichText{ { - Type: notionapi.ObjectTypeText, + Type: notionapi.RichTextTypeText, Text: ¬ionapi.Text{Content: "content"}, }, }, @@ -70,7 +70,7 @@ func TestCommentClient(t *testing.T) { }, RichText: []notionapi.RichText{ { - Type: notionapi.ObjectTypeText, + Type: notionapi.RichTextTypeText, Text: ¬ionapi.Text{Content: "content"}, }, }, @@ -122,7 +122,7 @@ func TestCommentClient(t *testing.T) { }, RichText: []notionapi.RichText{ { - Type: notionapi.ObjectTypeText, + Type: notionapi.RichTextTypeText, Text: ¬ionapi.Text{Content: "Hello world"}, }, }, @@ -140,7 +140,7 @@ func TestCommentClient(t *testing.T) { }, RichText: []notionapi.RichText{ { - Type: notionapi.ObjectTypeText, + Type: notionapi.RichTextTypeText, Text: ¬ionapi.Text{Content: "Hello world"}, }, }, diff --git a/const.go b/const.go index 3bd7b79..eaa0933 100644 --- a/const.go +++ b/const.go @@ -260,6 +260,12 @@ const ( RollupTypeArray RollupType = "array" ) +const ( + RichTextTypeText RichTextType = "text" + RichTextTypeMention RichTextType = "mention" + RichTextTypeEquation RichTextType = "equation" +) + const ( MentionTypeDatabase MentionType = "database" MentionTypePage MentionType = "page" diff --git a/database_test.go b/database_test.go index 0f8ddfc..590a2a2 100644 --- a/database_test.go +++ b/database_test.go @@ -47,7 +47,7 @@ func TestDatabaseClient(t *testing.T) { LastEditedBy: user, Title: []notionapi.RichText{ { - Type: notionapi.ObjectTypeText, + Type: notionapi.RichTextTypeText, Text: ¬ionapi.Text{Content: "Test Database"}, Annotations: ¬ionapi.Annotations{Color: "default"}, PlainText: "Test Database", @@ -179,7 +179,7 @@ func TestDatabaseClient(t *testing.T) { request: ¬ionapi.DatabaseUpdateRequest{ Title: []notionapi.RichText{ { - Type: notionapi.ObjectTypeText, + Type: notionapi.RichTextTypeText, Text: ¬ionapi.Text{Content: "patch"}, }, }, @@ -202,7 +202,7 @@ func TestDatabaseClient(t *testing.T) { }, Title: []notionapi.RichText{ { - Type: notionapi.ObjectTypeText, + Type: notionapi.RichTextTypeText, Text: ¬ionapi.Text{Content: "patch"}, }, }, @@ -262,7 +262,7 @@ func TestDatabaseClient(t *testing.T) { }, Title: []notionapi.RichText{ { - Type: notionapi.ObjectTypeText, + Type: notionapi.RichTextTypeText, Text: ¬ionapi.Text{Content: "Grocery List"}, }, }, @@ -286,7 +286,7 @@ func TestDatabaseClient(t *testing.T) { }, Title: []notionapi.RichText{ { - Type: notionapi.ObjectTypeText, + Type: notionapi.RichTextTypeText, Text: ¬ionapi.Text{Content: "Grocery List"}, PlainText: "Grocery List", Annotations: ¬ionapi.Annotations{Color: notionapi.ColorDefault}, @@ -318,7 +318,7 @@ func TestDatabaseClient(t *testing.T) { }, Title: []notionapi.RichText{ { - Type: notionapi.ObjectTypeText, + Type: notionapi.RichTextTypeText, Text: ¬ionapi.Text{Content: "Grocery List"}, }, }, @@ -342,7 +342,7 @@ func TestDatabaseClient(t *testing.T) { }, Title: []notionapi.RichText{ { - Type: notionapi.ObjectTypeText, + Type: notionapi.RichTextTypeText, Text: ¬ionapi.Text{Content: "Grocery List"}, PlainText: "Grocery List", Annotations: ¬ionapi.Annotations{Color: notionapi.ColorDefault}, @@ -374,7 +374,7 @@ func TestDatabaseClient(t *testing.T) { }, Title: []notionapi.RichText{ { - Type: notionapi.ObjectTypeText, + Type: notionapi.RichTextTypeText, Text: ¬ionapi.Text{Content: "Grocery List"}, }, }, @@ -398,7 +398,7 @@ func TestDatabaseClient(t *testing.T) { }, Title: []notionapi.RichText{ { - Type: notionapi.ObjectTypeText, + Type: notionapi.RichTextTypeText, Text: ¬ionapi.Text{Content: "Grocery List"}, PlainText: "Grocery List", Annotations: ¬ionapi.Annotations{Color: notionapi.ColorDefault}, diff --git a/object.go b/object.go index 4bf9578..0e20736 100644 --- a/object.go +++ b/object.go @@ -35,6 +35,12 @@ func (c Color) MarshalText() ([]byte, error) { return []byte(c), nil } +type RichTextType string + +func (rtType RichTextType) String() string { + return string(rtType) +} + type MentionType string func (mType MentionType) String() string { @@ -71,7 +77,7 @@ type Mention struct { } type RichText struct { - Type ObjectType `json:"type,omitempty"` + Type RichTextType `json:"type,omitempty"` Text *Text `json:"text,omitempty"` Mention *Mention `json:"mention,omitempty"` Equation *Equation `json:"equation,omitempty"` diff --git a/page_test.go b/page_test.go index 9a91937..2093d5f 100644 --- a/page_test.go +++ b/page_test.go @@ -275,7 +275,7 @@ func TestPageClient(t *testing.T) { Type: notionapi.PropertyTypeRichText, RichText: []notionapi.RichText{ { - Type: notionapi.ObjectTypeText, + Type: notionapi.RichTextTypeText, Text: ¬ionapi.Text{Content: "patch"}, }, }, @@ -386,7 +386,7 @@ func TestPageCreateRequest_MarshallJSON(t *testing.T) { "Summary": notionapi.TextProperty{ Text: []notionapi.RichText{ { - Type: notionapi.ObjectTypeText, + Type: notionapi.RichTextTypeText, Text: ¬ionapi.Text{ Content: "Some content", }, @@ -435,7 +435,7 @@ func TestPageCreateRequest_MarshallJSON(t *testing.T) { "Summary": notionapi.TextProperty{ Text: []notionapi.RichText{ { - Type: notionapi.ObjectTypeText, + Type: notionapi.RichTextTypeText, Text: ¬ionapi.Text{ Content: "Some content", }, @@ -460,7 +460,7 @@ func TestPageCreateRequest_MarshallJSON(t *testing.T) { Heading2: notionapi.Heading{ RichText: []notionapi.RichText{ { - Type: notionapi.ObjectTypeText, + Type: notionapi.RichTextTypeText, Text: ¬ionapi.Text{Content: "Lacinato"}, }, },