AsAPIWebhook to return webhook as graphql response object
()
| 28 | |
| 29 | // AsAPIWebhook to return webhook as graphql response object |
| 30 | func (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 | } |
no test coverage detected