You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
795 B

  1. package events
  2. import "fmt"
  3. type ButtonPressed struct {
  4. ID string `json:"id"`
  5. SwipedID string `json:"swipedId,omitempty"`
  6. Name string `json:"name"`
  7. }
  8. func (e ButtonPressed) EventDescription() string {
  9. if e.SwipedID != "" {
  10. return fmt.Sprintf("ButtonPressed(name:%s, swipe:%s->%s)", e.Name, e.SwipedID, e.ID)
  11. } else {
  12. return fmt.Sprintf("ButtonPressed(name:%s, id:%s)", e.Name, e.ID)
  13. }
  14. }
  15. func (e ButtonPressed) TriggerKind() string {
  16. return "ButtonPressed:" + e.Name
  17. }
  18. func (e ButtonPressed) TriggerValue(key string) (string, bool) {
  19. switch key {
  20. case "name":
  21. return e.Name, true
  22. case "id":
  23. return e.ID, true
  24. case "swipedFromId", "swipedId":
  25. if e.SwipedID != "" {
  26. return e.SwipedID, true
  27. } else {
  28. return "", false
  29. }
  30. default:
  31. return "", false
  32. }
  33. }