From ab55fc69f6c49dca98d0dd040c1b327ffa0b1108 Mon Sep 17 00:00:00 2001 From: Basil Peace Date: Tue, 3 Sep 2024 20:45:17 +0300 Subject: [PATCH] Add button property support into property_config --- const.go | 1 + property_config.go | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/const.go b/const.go index 15137a6..8586436 100644 --- a/const.go +++ b/const.go @@ -34,6 +34,7 @@ const ( PropertyConfigStatus PropertyConfigType = "status" PropertyConfigUniqueID PropertyConfigType = "unique_id" PropertyConfigVerification PropertyConfigType = "verification" + PropertyConfigButton PropertyConfigType = "button" ) const ( diff --git a/property_config.go b/property_config.go index f3cfc5a..9a3f674 100644 --- a/property_config.go +++ b/property_config.go @@ -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 { @@ -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))