Skip to content

Commit 74e249c

Browse files
Added support for button property (#175)
1 parent 81b8861 commit 74e249c

4 files changed

Lines changed: 21 additions & 0 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
*.dll
55
*.so
66
*.dylib
7+
.idea
78

89
# Test binary, built with `go test -c`
910
*.test

const.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ const (
6060
PropertyTypeStatus PropertyType = "status"
6161
PropertyTypeUniqueID PropertyType = "unique_id"
6262
PropertyTypeVerification PropertyType = "verification"
63+
PropertyTypeButton PropertyType = "button"
6364
)
6465

6566
const (

object.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,3 +212,6 @@ type Verification struct {
212212
VerifiedBy *User `json:"verified_by,omitempty"`
213213
Date *DateObject `json:"date,omitempty"`
214214
}
215+
216+
type Button struct {
217+
}

property.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,20 @@ func (p VerificationProperty) GetType() PropertyType {
393393
return p.Type
394394
}
395395

396+
type ButtonProperty struct {
397+
ID ObjectID `json:"id,omitempty"`
398+
Type PropertyType `json:"type,omitempty"`
399+
Button Button `json:"button"`
400+
}
401+
402+
func (p ButtonProperty) GetID() string {
403+
return p.ID.String()
404+
}
405+
406+
func (p ButtonProperty) GetType() PropertyType {
407+
return p.Type
408+
}
409+
396410
type Properties map[string]Property
397411

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

0 commit comments

Comments
 (0)