Skip to content

hotfix: RichText.Type has its own enum #189

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions block_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func TestBlockClient(t *testing.T) {
IsToggleable bool `json:"is_toggleable,omitempty"`
}{[]notionapi.RichText{
{
Type: notionapi.ObjectTypeText,
Type: notionapi.RichTextTypeText,
Text: &notionapi.Text{Content: "Hello"},
},
}, nil, "", false,
Expand Down Expand Up @@ -114,7 +114,7 @@ func TestBlockClient(t *testing.T) {
Paragraph: notionapi.Paragraph{
RichText: []notionapi.RichText{
{
Type: notionapi.ObjectTypeText,
Type: notionapi.RichTextTypeText,
Text: &notionapi.Text{Content: "AAAAAA"},
Annotations: &notionapi.Annotations{
Bold: true,
Expand Down Expand Up @@ -259,7 +259,7 @@ func TestBlockClient(t *testing.T) {
Paragraph: notionapi.Paragraph{
RichText: []notionapi.RichText{
{
Type: notionapi.ObjectTypeText,
Type: notionapi.RichTextTypeText,
Text: &notionapi.Text{
Content: "Hello",
},
Expand Down
8 changes: 4 additions & 4 deletions comment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func TestCommentClient(t *testing.T) {
},
RichText: []notionapi.RichText{
{
Type: notionapi.ObjectTypeText,
Type: notionapi.RichTextTypeText,
Text: &notionapi.Text{Content: "content"},
},
},
Expand All @@ -70,7 +70,7 @@ func TestCommentClient(t *testing.T) {
},
RichText: []notionapi.RichText{
{
Type: notionapi.ObjectTypeText,
Type: notionapi.RichTextTypeText,
Text: &notionapi.Text{Content: "content"},
},
},
Expand Down Expand Up @@ -122,7 +122,7 @@ func TestCommentClient(t *testing.T) {
},
RichText: []notionapi.RichText{
{
Type: notionapi.ObjectTypeText,
Type: notionapi.RichTextTypeText,
Text: &notionapi.Text{Content: "Hello world"},
},
},
Expand All @@ -140,7 +140,7 @@ func TestCommentClient(t *testing.T) {
},
RichText: []notionapi.RichText{
{
Type: notionapi.ObjectTypeText,
Type: notionapi.RichTextTypeText,
Text: &notionapi.Text{Content: "Hello world"},
},
},
Expand Down
6 changes: 6 additions & 0 deletions const.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
18 changes: 9 additions & 9 deletions database_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func TestDatabaseClient(t *testing.T) {
LastEditedBy: user,
Title: []notionapi.RichText{
{
Type: notionapi.ObjectTypeText,
Type: notionapi.RichTextTypeText,
Text: &notionapi.Text{Content: "Test Database"},
Annotations: &notionapi.Annotations{Color: "default"},
PlainText: "Test Database",
Expand Down Expand Up @@ -179,7 +179,7 @@ func TestDatabaseClient(t *testing.T) {
request: &notionapi.DatabaseUpdateRequest{
Title: []notionapi.RichText{
{
Type: notionapi.ObjectTypeText,
Type: notionapi.RichTextTypeText,
Text: &notionapi.Text{Content: "patch"},
},
},
Expand All @@ -202,7 +202,7 @@ func TestDatabaseClient(t *testing.T) {
},
Title: []notionapi.RichText{
{
Type: notionapi.ObjectTypeText,
Type: notionapi.RichTextTypeText,
Text: &notionapi.Text{Content: "patch"},
},
},
Expand Down Expand Up @@ -262,7 +262,7 @@ func TestDatabaseClient(t *testing.T) {
},
Title: []notionapi.RichText{
{
Type: notionapi.ObjectTypeText,
Type: notionapi.RichTextTypeText,
Text: &notionapi.Text{Content: "Grocery List"},
},
},
Expand All @@ -286,7 +286,7 @@ func TestDatabaseClient(t *testing.T) {
},
Title: []notionapi.RichText{
{
Type: notionapi.ObjectTypeText,
Type: notionapi.RichTextTypeText,
Text: &notionapi.Text{Content: "Grocery List"},
PlainText: "Grocery List",
Annotations: &notionapi.Annotations{Color: notionapi.ColorDefault},
Expand Down Expand Up @@ -318,7 +318,7 @@ func TestDatabaseClient(t *testing.T) {
},
Title: []notionapi.RichText{
{
Type: notionapi.ObjectTypeText,
Type: notionapi.RichTextTypeText,
Text: &notionapi.Text{Content: "Grocery List"},
},
},
Expand All @@ -342,7 +342,7 @@ func TestDatabaseClient(t *testing.T) {
},
Title: []notionapi.RichText{
{
Type: notionapi.ObjectTypeText,
Type: notionapi.RichTextTypeText,
Text: &notionapi.Text{Content: "Grocery List"},
PlainText: "Grocery List",
Annotations: &notionapi.Annotations{Color: notionapi.ColorDefault},
Expand Down Expand Up @@ -374,7 +374,7 @@ func TestDatabaseClient(t *testing.T) {
},
Title: []notionapi.RichText{
{
Type: notionapi.ObjectTypeText,
Type: notionapi.RichTextTypeText,
Text: &notionapi.Text{Content: "Grocery List"},
},
},
Expand All @@ -398,7 +398,7 @@ func TestDatabaseClient(t *testing.T) {
},
Title: []notionapi.RichText{
{
Type: notionapi.ObjectTypeText,
Type: notionapi.RichTextTypeText,
Text: &notionapi.Text{Content: "Grocery List"},
PlainText: "Grocery List",
Annotations: &notionapi.Annotations{Color: notionapi.ColorDefault},
Expand Down
8 changes: 7 additions & 1 deletion object.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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"`
Expand Down
8 changes: 4 additions & 4 deletions page_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ func TestPageClient(t *testing.T) {
Type: notionapi.PropertyTypeRichText,
RichText: []notionapi.RichText{
{
Type: notionapi.ObjectTypeText,
Type: notionapi.RichTextTypeText,
Text: &notionapi.Text{Content: "patch"},
},
},
Expand Down Expand Up @@ -386,7 +386,7 @@ func TestPageCreateRequest_MarshallJSON(t *testing.T) {
"Summary": notionapi.TextProperty{
Text: []notionapi.RichText{
{
Type: notionapi.ObjectTypeText,
Type: notionapi.RichTextTypeText,
Text: &notionapi.Text{
Content: "Some content",
},
Expand Down Expand Up @@ -435,7 +435,7 @@ func TestPageCreateRequest_MarshallJSON(t *testing.T) {
"Summary": notionapi.TextProperty{
Text: []notionapi.RichText{
{
Type: notionapi.ObjectTypeText,
Type: notionapi.RichTextTypeText,
Text: &notionapi.Text{
Content: "Some content",
},
Expand All @@ -460,7 +460,7 @@ func TestPageCreateRequest_MarshallJSON(t *testing.T) {
Heading2: notionapi.Heading{
RichText: []notionapi.RichText{
{
Type: notionapi.ObjectTypeText,
Type: notionapi.RichTextTypeText,
Text: &notionapi.Text{Content: "Lacinato"},
},
},
Expand Down
Loading