webhook.go 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. RowStatus RowStatus
  11. Name string
  12. URL string
  13. }
  14. type FindWebhook struct {
  15. ID *int32
  16. CreatorID *int32
  17. }
  18. type UpdateWebhook struct {
  19. ID int32
  20. RowStatus *RowStatus
  21. Name *string
  22. URL *string
  23. }
  24. type DeleteWebhook struct {
  25. ID int32
  26. }
  27. func (s *Store) CreateWebhook(ctx context.Context, create *Webhook) (*Webhook, error) {
  28. return s.driver.CreateWebhook(ctx, create)
  29. }
  30. func (s *Store) ListWebhooks(ctx context.Context, find *FindWebhook) ([]*Webhook, error) {
  31. return s.driver.ListWebhooks(ctx, find)
  32. }
  33. func (s *Store) GetWebhook(ctx context.Context, find *FindWebhook) (*Webhook, error) {
  34. list, err := s.ListWebhooks(ctx, find)
  35. if err != nil {
  36. return nil, err
  37. }
  38. if len(list) == 0 {
  39. return nil, nil
  40. }
  41. return list[0], nil
  42. }
  43. func (s *Store) UpdateWebhook(ctx context.Context, update *UpdateWebhook) (*Webhook, error) {
  44. return s.driver.UpdateWebhook(ctx, update)
  45. }
  46. func (s *Store) DeleteWebhook(ctx context.Context, delete *DeleteWebhook) error {
  47. return s.driver.DeleteWebhook(ctx, delete)
  48. }