Skip to content

Commit

Permalink
Add GetID func to PropertyConfig interface (#172)
Browse files Browse the repository at this point in the history
  • Loading branch information
jomei authored Feb 26, 2024
1 parent f7607a9 commit 81b8861
Showing 1 changed file with 108 additions and 19 deletions.
127 changes: 108 additions & 19 deletions property_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ type PropertyConfigType string

type PropertyConfig interface {
GetType() PropertyConfigType
GetID() PropertyID
}

type TitlePropertyConfig struct {
Expand All @@ -21,6 +22,10 @@ func (p TitlePropertyConfig) GetType() PropertyConfigType {
return p.Type
}

func (p TitlePropertyConfig) GetID() PropertyID {
return p.ID
}

type RichTextPropertyConfig struct {
ID PropertyID `json:"id,omitempty"`
Type PropertyConfigType `json:"type"`
Expand All @@ -31,8 +36,12 @@ func (p RichTextPropertyConfig) GetType() PropertyConfigType {
return p.Type
}

func (p RichTextPropertyConfig) GetID() PropertyID {
return p.ID
}

type NumberPropertyConfig struct {
ID ObjectID `json:"id,omitempty"`
ID PropertyID `json:"id,omitempty"`
Type PropertyConfigType `json:"type"`
Number NumberFormat `json:"number"`
}
Expand All @@ -51,8 +60,12 @@ func (p NumberPropertyConfig) GetType() PropertyConfigType {
return p.Type
}

func (p NumberPropertyConfig) GetID() PropertyID {
return p.ID
}

type SelectPropertyConfig struct {
ID ObjectID `json:"id,omitempty"`
ID PropertyID `json:"id,omitempty"`
Type PropertyConfigType `json:"type"`
Select Select `json:"select"`
}
Expand All @@ -61,8 +74,12 @@ func (p SelectPropertyConfig) GetType() PropertyConfigType {
return p.Type
}

func (p SelectPropertyConfig) GetID() PropertyID {
return p.ID
}

type MultiSelectPropertyConfig struct {
ID ObjectID `json:"id,omitempty"`
ID PropertyID `json:"id,omitempty"`
Type PropertyConfigType `json:"type"`
MultiSelect Select `json:"multi_select"`
}
Expand All @@ -75,8 +92,12 @@ func (p MultiSelectPropertyConfig) GetType() PropertyConfigType {
return p.Type
}

func (p MultiSelectPropertyConfig) GetID() PropertyID {
return p.ID
}

type DatePropertyConfig struct {
ID ObjectID `json:"id,omitempty"`
ID PropertyID `json:"id,omitempty"`
Type PropertyConfigType `json:"type"`
Date struct{} `json:"date"`
}
Expand All @@ -85,8 +106,12 @@ func (p DatePropertyConfig) GetType() PropertyConfigType {
return p.Type
}

func (p DatePropertyConfig) GetID() PropertyID {
return p.ID
}

type PeoplePropertyConfig struct {
ID ObjectID `json:"id,omitempty"`
ID PropertyID `json:"id,omitempty"`
Type PropertyConfigType `json:"type"`
People struct{} `json:"people"`
}
Expand All @@ -95,8 +120,12 @@ func (p PeoplePropertyConfig) GetType() PropertyConfigType {
return p.Type
}

func (p PeoplePropertyConfig) GetID() PropertyID {
return p.ID
}

type FilesPropertyConfig struct {
ID ObjectID `json:"id,omitempty"`
ID PropertyID `json:"id,omitempty"`
Type PropertyConfigType `json:"type"`
Files struct{} `json:"files"`
}
Expand All @@ -105,8 +134,12 @@ func (p FilesPropertyConfig) GetType() PropertyConfigType {
return p.Type
}

func (p FilesPropertyConfig) GetID() PropertyID {
return p.ID
}

type CheckboxPropertyConfig struct {
ID ObjectID `json:"id,omitempty"`
ID PropertyID `json:"id,omitempty"`
Type PropertyConfigType `json:"type"`
Checkbox struct{} `json:"checkbox"`
}
Expand All @@ -115,8 +148,12 @@ func (p CheckboxPropertyConfig) GetType() PropertyConfigType {
return p.Type
}

func (p CheckboxPropertyConfig) GetID() PropertyID {
return p.ID
}

type URLPropertyConfig struct {
ID ObjectID `json:"id,omitempty"`
ID PropertyID `json:"id,omitempty"`
Type PropertyConfigType `json:"type"`
URL struct{} `json:"url"`
}
Expand All @@ -125,6 +162,10 @@ func (p URLPropertyConfig) GetType() PropertyConfigType {
return p.Type
}

func (p URLPropertyConfig) GetID() PropertyID {
return p.ID
}

type EmailPropertyConfig struct {
ID PropertyID `json:"id,omitempty"`
Type PropertyConfigType `json:"type"`
Expand All @@ -135,8 +176,12 @@ func (p EmailPropertyConfig) GetType() PropertyConfigType {
return p.Type
}

func (p EmailPropertyConfig) GetID() PropertyID {
return p.ID
}

type PhoneNumberPropertyConfig struct {
ID ObjectID `json:"id,omitempty"`
ID PropertyID `json:"id,omitempty"`
Type PropertyConfigType `json:"type"`
PhoneNumber struct{} `json:"phone_number"`
}
Expand All @@ -145,8 +190,12 @@ func (p PhoneNumberPropertyConfig) GetType() PropertyConfigType {
return p.Type
}

func (p PhoneNumberPropertyConfig) GetID() PropertyID {
return p.ID
}

type FormulaPropertyConfig struct {
ID ObjectID `json:"id,omitempty"`
ID PropertyID `json:"id,omitempty"`
Type PropertyConfigType `json:"type"`
Formula FormulaConfig `json:"formula"`
}
Expand All @@ -159,6 +208,10 @@ func (p FormulaPropertyConfig) GetType() PropertyConfigType {
return p.Type
}

func (p FormulaPropertyConfig) GetID() PropertyID {
return p.ID
}

type RelationPropertyConfig struct {
Type PropertyConfigType `json:"type"`
Relation RelationConfig `json:"relation"`
Expand Down Expand Up @@ -187,8 +240,12 @@ func (p RelationPropertyConfig) GetType() PropertyConfigType {
return p.Type
}

func (p RelationPropertyConfig) GetID() PropertyID {
return ""
}

type RollupPropertyConfig struct {
ID ObjectID `json:"id,omitempty"`
ID PropertyID `json:"id,omitempty"`
Type PropertyConfigType `json:"type"`
Rollup RollupConfig `json:"rollup"`
}
Expand All @@ -205,8 +262,12 @@ func (p RollupPropertyConfig) GetType() PropertyConfigType {
return p.Type
}

func (p RollupPropertyConfig) GetID() PropertyID {
return p.ID
}

type CreatedTimePropertyConfig struct {
ID ObjectID `json:"id,omitempty"`
ID PropertyID `json:"id,omitempty"`
Type PropertyConfigType `json:"type"`
CreatedTime struct{} `json:"created_time"`
}
Expand All @@ -215,8 +276,12 @@ func (p CreatedTimePropertyConfig) GetType() PropertyConfigType {
return p.Type
}

func (p CreatedTimePropertyConfig) GetID() PropertyID {
return p.ID
}

type CreatedByPropertyConfig struct {
ID ObjectID `json:"id"`
ID PropertyID `json:"id"`
Type PropertyConfigType `json:"type"`
CreatedBy struct{} `json:"created_by"`
}
Expand All @@ -225,8 +290,12 @@ func (p CreatedByPropertyConfig) GetType() PropertyConfigType {
return p.Type
}

func (p CreatedByPropertyConfig) GetID() PropertyID {
return p.ID
}

type LastEditedTimePropertyConfig struct {
ID ObjectID `json:"id"`
ID PropertyID `json:"id"`
Type PropertyConfigType `json:"type"`
LastEditedTime struct{} `json:"last_edited_time"`
}
Expand All @@ -235,8 +304,12 @@ func (p LastEditedTimePropertyConfig) GetType() PropertyConfigType {
return p.Type
}

func (p LastEditedTimePropertyConfig) GetID() PropertyID {
return p.ID
}

type LastEditedByPropertyConfig struct {
ID ObjectID `json:"id"`
ID PropertyID `json:"id"`
Type PropertyConfigType `json:"type"`
LastEditedBy struct{} `json:"last_edited_by"`
}
Expand All @@ -245,8 +318,12 @@ func (p LastEditedByPropertyConfig) GetType() PropertyConfigType {
return p.Type
}

func (p LastEditedByPropertyConfig) GetID() PropertyID {
return p.ID
}

type StatusPropertyConfig struct {
ID ObjectID `json:"id"`
ID PropertyID `json:"id"`
Type PropertyConfigType `json:"type"`
Status StatusConfig `json:"status"`
}
Expand All @@ -255,6 +332,10 @@ func (p StatusPropertyConfig) GetType() PropertyConfigType {
return p.Type
}

func (p StatusPropertyConfig) GetID() PropertyID {
return p.ID
}

type StatusConfig struct {
Options []Option `json:"options"`
Groups []GroupConfig `json:"groups"`
Expand All @@ -268,7 +349,7 @@ type GroupConfig struct {
}

type UniqueIDPropertyConfig struct {
ID ObjectID `json:"id,omitempty"`
ID PropertyID `json:"id,omitempty"`
Type PropertyConfigType `json:"type"`
UniqueID UniqueIDConfig `json:"unique_id"`
}
Expand All @@ -277,12 +358,16 @@ type UniqueIDConfig struct {
Prefix string `json:"prefix"`
}

func (i UniqueIDPropertyConfig) GetType() PropertyConfigType {
func (p UniqueIDPropertyConfig) GetType() PropertyConfigType {
return ""
}

func (p UniqueIDPropertyConfig) GetID() PropertyID {
return p.ID
}

type VerificationPropertyConfig struct {
ID ObjectID `json:"id,omitempty"`
ID PropertyID `json:"id,omitempty"`
Type PropertyConfigType `json:"type,omitempty"`
Verification Verification `json:"verification"`
}
Expand All @@ -291,6 +376,10 @@ func (p VerificationPropertyConfig) GetType() PropertyConfigType {
return p.Type
}

func (p VerificationPropertyConfig) GetID() PropertyID {
return p.ID
}

type PropertyConfigs map[string]PropertyConfig

func (p *PropertyConfigs) UnmarshalJSON(data []byte) error {
Expand Down

0 comments on commit 81b8861

Please sign in to comment.