MCPcopy Create free account
hub / github.com/authorizerdev/authorizer / AsAPIWebhook

Method AsAPIWebhook

internal/storage/schemas/webhook.go:30–51  ·  view source on GitHub ↗

AsAPIWebhook to return webhook as graphql response object

()

Source from the content-addressed store, hash-verified

28
29// AsAPIWebhook to return webhook as graphql response object
30func (w *Webhook) AsAPIWebhook() *model.Webhook {
31 headersMap := make(map[string]interface{})
32 _ = json.Unmarshal([]byte(w.Headers), &headersMap)
33 id := w.ID
34 if strings.Contains(id, Collections.Webhook+"/") {
35 id = strings.TrimPrefix(id, Collections.Webhook+"/")
36 }
37 // set default title to event name without dot(.)
38 if w.EventDescription == "" {
39 w.EventDescription = strings.Join(strings.Split(w.EventName, "."), " ")
40 }
41 return &model.Webhook{
42 ID: id,
43 EventName: refs.NewStringRef(w.EventName),
44 EventDescription: refs.NewStringRef(w.EventDescription),
45 Endpoint: refs.NewStringRef(w.EndPoint),
46 Headers: headersMap,
47 Enabled: refs.NewBoolRef(w.Enabled),
48 CreatedAt: refs.NewInt64Ref(w.CreatedAt),
49 UpdatedAt: refs.NewInt64Ref(w.UpdatedAt),
50 }
51}

Callers 2

WebhookMethod · 0.80
WebhooksMethod · 0.80

Calls 3

NewStringRefFunction · 0.92
NewBoolRefFunction · 0.92
NewInt64RefFunction · 0.92

Tested by

no test coverage detected