Skip to content

Commit

Permalink
Added support for button property (#175)
Browse files Browse the repository at this point in the history
  • Loading branch information
manjurulhoque authored Mar 5, 2024
1 parent 81b8861 commit 74e249c
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*.dll
*.so
*.dylib
.idea

# Test binary, built with `go test -c`
*.test
Expand Down
1 change: 1 addition & 0 deletions const.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ const (
PropertyTypeStatus PropertyType = "status"
PropertyTypeUniqueID PropertyType = "unique_id"
PropertyTypeVerification PropertyType = "verification"
PropertyTypeButton PropertyType = "button"
)

const (
Expand Down
3 changes: 3 additions & 0 deletions object.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,3 +212,6 @@ type Verification struct {
VerifiedBy *User `json:"verified_by,omitempty"`
Date *DateObject `json:"date,omitempty"`
}

type Button struct {
}
16 changes: 16 additions & 0 deletions property.go
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,20 @@ func (p VerificationProperty) GetType() PropertyType {
return p.Type
}

type ButtonProperty struct {
ID ObjectID `json:"id,omitempty"`
Type PropertyType `json:"type,omitempty"`
Button Button `json:"button"`
}

func (p ButtonProperty) GetID() string {
return p.ID.String()
}

func (p ButtonProperty) GetType() PropertyType {
return p.Type
}

type Properties map[string]Property

func (p *Properties) UnmarshalJSON(data []byte) error {
Expand Down Expand Up @@ -485,6 +499,8 @@ func decodeProperty(raw map[string]interface{}) (Property, error) {
p = &UniqueIDProperty{}
case PropertyTypeVerification:
p = &VerificationProperty{}
case PropertyTypeButton:
p = &ButtonProperty{}
default:
return nil, fmt.Errorf("unsupported property type: %s", raw["type"].(string))
}
Expand Down

0 comments on commit 74e249c

Please sign in to comment.