MCPcopy Index your code
hub / github.com/NdoleStudio/httpsms / Update

Method Update

api/pkg/services/webhook_service.go:157–179  ·  view source on GitHub ↗

Update an entities.Webhook

(ctx context.Context, params *WebhookUpdateParams)

Source from the content-addressed store, hash-verified

155
156// Update an entities.Webhook
157func (service *WebhookService) Update(ctx context.Context, params *WebhookUpdateParams) (*entities.Webhook, error) {
158 ctx, span, ctxLogger := service.tracer.StartWithLogger(ctx, service.logger)
159 defer span.End()
160
161 webhook, err := service.repository.Load(ctx, params.UserID, params.WebhookID)
162 if err != nil {
163 msg := fmt.Sprintf("cannot load webhook with userID [%s] and phoneID [%s]", params.UserID, params.WebhookID)
164 return nil, service.tracer.WrapErrorSpan(span, stacktrace.PropagateWithCode(err, stacktrace.GetCode(err), msg))
165 }
166
167 webhook.URL = params.URL
168 webhook.SigningKey = params.SigningKey
169 webhook.Events = params.Events
170 webhook.PhoneNumbers = params.PhoneNumbers
171
172 if err = service.repository.Save(ctx, webhook); err != nil {
173 msg := fmt.Sprintf("cannot save webhook with id [%s] after update", webhook.ID)
174 return nil, service.tracer.WrapErrorSpan(span, stacktrace.Propagate(err, msg))
175 }
176
177 ctxLogger.Info(fmt.Sprintf("webhook updated with id [%s] in the [%T]", webhook.ID, service.repository))
178 return webhook, nil
179}
180
181// Send an event to a subscribed webhook
182func (service *WebhookService) Send(ctx context.Context, userID entities.UserID, event cloudevents.Event, phoneNumber string) error {

Callers

nothing calls this directly

Calls 5

StartWithLoggerMethod · 0.65
LoadMethod · 0.65
WrapErrorSpanMethod · 0.65
SaveMethod · 0.65
InfoMethod · 0.65

Tested by

no test coverage detected