Skip to content

Commit

Permalink
Add button property support into property_config
Browse files Browse the repository at this point in the history
  • Loading branch information
grv87 authored and jomei committed Sep 4, 2024
1 parent 12c1355 commit ab55fc6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions const.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const (
PropertyConfigStatus PropertyConfigType = "status"
PropertyConfigUniqueID PropertyConfigType = "unique_id"
PropertyConfigVerification PropertyConfigType = "verification"
PropertyConfigButton PropertyConfigType = "button"
)

const (
Expand Down
16 changes: 16 additions & 0 deletions property_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,20 @@ func (p VerificationPropertyConfig) GetID() PropertyID {
return p.ID
}

type ButtonPropertyConfig struct {
ID PropertyID `json:"id"`
Type PropertyConfigType `json:"type"`
Button struct{} `json:"button"`
}

func (p ButtonPropertyConfig) GetType() PropertyConfigType {
return p.Type
}

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

type PropertyConfigs map[string]PropertyConfig

func (p *PropertyConfigs) UnmarshalJSON(data []byte) error {
Expand Down Expand Up @@ -447,6 +461,8 @@ func parsePropertyConfigs(raw map[string]interface{}) (PropertyConfigs, error) {
p = &UniqueIDPropertyConfig{}
case PropertyConfigVerification:
p = &VerificationPropertyConfig{}
case PropertyConfigButton:
p = &ButtonPropertyConfig{}
default:

return nil, fmt.Errorf("unsupported property type: %s", rawProperty["type"].(string))
Expand Down

0 comments on commit ab55fc6

Please sign in to comment.