webhook.go 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. package store
  2. import (
  3. "context"
  4. )
  5. type Webhook struct {
  6. ID int32
  7. CreatedTs int64
  8. UpdatedTs int64
  9. CreatorID int32
  10. Name string
  11. URL string
  12. }
  13. type FindWebhook struct {
  14. ID *int32
  15. CreatorID *int32
  16. }
  17. type UpdateWebhook struct {
  18. ID int32
  19. Name *string
  20. URL *string
  21. }
  22. type DeleteWebhook struct {
  23. ID int32
  24. }
  25. func (s *Store) CreateWebhook(ctx context.Context, create *Webhook) (*Webhook, error) {
  26. return s.driver.CreateWebhook(ctx, create)
  27. }
  28. func (s *Store) ListWebhooks(ctx context.Context, find *FindWebhook) ([]*Webhook, error) {
  29. return s.driver.ListWebhooks(ctx, find)
  30. }
  31. func (s *Store) GetWebhook(ctx context.Context, find *FindWebhook) (*Webhook, error) {
  32. list, err := s.ListWebhooks(ctx, find)
  33. if err != nil {
  34. return nil, err
  35. }
  36. if len(list) == 0 {
  37. return nil, nil
  38. }
  39. return list[0], nil
  40. }
  41. func (s *Store) UpdateWebhook(ctx context.Context, update *UpdateWebhook) (*Webhook, error) {
  42. return s.driver.UpdateWebhook(ctx, update)
  43. }
  44. func (s *Store) DeleteWebhook(ctx context.Context, delete *DeleteWebhook) error {
  45. return s.driver.DeleteWebhook(ctx, delete)
  46. }