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

Added support for button property #175

Merged
merged 1 commit into from
Mar 5, 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 .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
Loading