Skip to content
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

Add button property support into property_config #180

Merged
merged 1 commit into from
Sep 4, 2024
Merged
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
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
Loading