@@ -3,7 +3,7 @@ package webhooks
33import (
44 "fmt"
55
6- "github.com/android-sms-gateway/client-go/smsgateway"
6+ "github.com/android-sms-gateway/client-go/smsgateway/webhooks "
77 "github.com/capcom6/go-helpers/slices"
88 "github.com/capcom6/sms-gateway/internal/sms-gateway/modules/db"
99 "github.com/capcom6/sms-gateway/internal/sms-gateway/modules/devices"
@@ -46,7 +46,7 @@ func NewService(params ServiceParams) *Service {
4646 }
4747}
4848
49- func (s * Service ) Select (userID string , filters ... SelectFilter ) ([]smsgateway .Webhook , error ) {
49+ func (s * Service ) Select (userID string , filters ... SelectFilter ) ([]webhooks .Webhook , error ) {
5050 filters = append (filters , WithUserID (userID ))
5151
5252 items , err := s .webhooks .Select (filters ... )
@@ -57,7 +57,11 @@ func (s *Service) Select(userID string, filters ...SelectFilter) ([]smsgateway.W
5757 return slices .Map (items , webhookToDTO ), nil
5858}
5959
60- func (s * Service ) Replace (userID string , webhook * smsgateway.Webhook ) error {
60+ func (s * Service ) Replace (userID string , webhook * webhooks.Webhook ) error {
61+ if ! webhooks .IsValidEventType (webhook .Event ) {
62+ return newValidationError ("event" , string (webhook .Event ), fmt .Errorf ("enum value expected" ))
63+ }
64+
6165 if webhook .ID == "" {
6266 webhook .ID = s .idgen ()
6367 }
0 commit comments