Skip to content

Commit

Permalink
Update status property type behavior (#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
dstotijn authored Sep 3, 2022
1 parent a543e39 commit e399b89
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
22 changes: 21 additions & 1 deletion database.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ type (
SelectMetadata struct {
Options []SelectOptions `json:"options"`
}
StatusMetadata struct {
Options []SelectOptions `json:"options"`
Groups []StatusGroup `json:"groups"`
}
FormulaMetadata struct {
Expression string `json:"expression"`
}
Expand Down Expand Up @@ -92,6 +96,13 @@ type SelectOptions struct {
Color Color `json:"color,omitempty"`
}

type StatusGroup struct {
ID string `json:"id,omitempty"`
Name string `json:"name,omitempty"`
Color Color `json:"color,omitempty"`
OptionIDs []string `json:"option_ids,omitempty"`
}

type FormulaResult struct {
Type FormulaResultType `json:"type"`

Expand Down Expand Up @@ -139,7 +150,6 @@ type DatabaseProperty struct {
URL *EmptyMetadata `json:"url,omitempty"`
Email *EmptyMetadata `json:"email,omitempty"`
PhoneNumber *EmptyMetadata `json:"phone_number,omitempty"`
Status *EmptyMetadata `json:"status,omitempty"`
CreatedTime *EmptyMetadata `json:"created_time,omitempty"`
CreatedBy *EmptyMetadata `json:"created_by,omitempty"`
LastEditedTime *EmptyMetadata `json:"last_edited_time,omitempty"`
Expand All @@ -151,6 +161,7 @@ type DatabaseProperty struct {
Formula *FormulaMetadata `json:"formula,omitempty"`
Relation *RelationMetadata `json:"relation,omitempty"`
Rollup *RollupMetadata `json:"rollup,omitempty"`
Status *StatusMetadata `json:"status,omitempty"`
}

// DatabaseQuery is used for quering a database.
Expand Down Expand Up @@ -195,6 +206,7 @@ type DatabaseQueryPropertyFilter struct {
Checkbox *CheckboxDatabaseQueryFilter `json:"checkbox,omitempty"`
Select *SelectDatabaseQueryFilter `json:"select,omitempty"`
MultiSelect *MultiSelectDatabaseQueryFilter `json:"multi_select,omitempty"`
Status *StatusDatabaseQueryFilter `json:"status,omitempty"`
People *PeopleDatabaseQueryFilter `json:"people,omitempty"`
Files *FilesDatabaseQueryFilter `json:"files,omitempty"`
Relation *RelationDatabaseQueryFilter `json:"relation,omitempty"`
Expand Down Expand Up @@ -253,6 +265,13 @@ type MultiSelectDatabaseQueryFilter struct {
IsNotEmpty bool `json:"is_not_empty,omitempty"`
}

type StatusDatabaseQueryFilter struct {
Equals string `json:"equals,omitempty"`
DoesNotEqual string `json:"does_not_equal,omitempty"`
IsEmpty bool `json:"is_empty,omitempty"`
IsNotEmpty bool `json:"is_not_empty,omitempty"`
}

type DatePropertyFilter struct {
Equals *time.Time `json:"equals,omitempty"`
Before *time.Time `json:"before,omitempty"`
Expand Down Expand Up @@ -343,6 +362,7 @@ const (
DBPropTypeURL DatabasePropertyType = "url"
DBPropTypeEmail DatabasePropertyType = "email"
DBPropTypePhoneNumber DatabasePropertyType = "phone_number"
DBPropTypeStatus DatabasePropertyType = "status"
DBPropTypeFormula DatabasePropertyType = "formula"
DBPropTypeRelation DatabasePropertyType = "relation"
DBPropTypeRollup DatabasePropertyType = "rollup"
Expand Down
2 changes: 2 additions & 0 deletions page.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@ func (prop DatabasePageProperty) Value() interface{} {
return prop.Email
case DBPropTypePhoneNumber:
return prop.PhoneNumber
case DBPropTypeStatus:
return prop.Status
case DBPropTypeFormula:
return prop.Formula
case DBPropTypeRelation:
Expand Down

0 comments on commit e399b89

Please sign in to comment.