forked from jomei/notionapi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathobject.go
80 lines (59 loc) · 1.49 KB
/
object.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
package notionapi
import "time"
type ObjectType string
func (ot ObjectType) String() string {
return string(ot)
}
type ObjectID string
func (oID ObjectID) String() string {
return string(oID)
}
type Object interface {
GetObject() ObjectType
}
type Color string
func (c Color) String() string {
return string(c)
}
type RichText struct {
Type ObjectType `json:"type,omitempty"`
Text Text `json:"text"`
Annotations *Annotations `json:"annotations,omitempty"`
PlainText string `json:"plain_text,omitempty"`
Href string `json:"href,omitempty"`
}
type Text struct {
Content string `json:"content"`
Link string `json:"link,omitempty"`
}
type Annotations struct {
Bold bool `json:"bold"`
Italic bool `json:"italic"`
Strikethrough bool `json:"strikethrough"`
Underline bool `json:"underline"`
Code bool `json:"code"`
Color Color `json:"color"`
}
type Paragraph []RichText
type FormulaObject struct {
Value string `json:"value"`
}
type RelationObject struct {
Database DatabaseID `json:"database"`
SyncedPropertyName string `json:"synced_property_name"`
}
type FunctionType string
func (ft FunctionType) String() string {
return string(ft)
}
type Cursor string
func (c Cursor) String() string {
return string(c)
}
type Date time.Time
func (d *Date) String() string {
return time.Time(*d).Format(time.RFC3339)
}
func (d *Date) MarshalText() ([]byte, error) {
return []byte(d.String()), nil
}