1package pagerduty 2 3import ( 4 "encoding/json" 5 "io" 6) 7 8// IncidentDetail contains a representation of the incident associated with the action that caused this webhook message. 9type IncidentDetail struct { 10 ID string `json:"id"` 11 IncidentNumber uint `json:"incident_number"` 12 CreatedOn string `json:"created_on"` 13 Status string `json:"status"` 14 HTMLUrl string `json:"html_url"` 15 Service string `json:"service"` 16 AssignedToUser *json.RawMessage `json:"assigned_to_user"` 17 AssignedTo []string `json:"assigned_to"` 18 TriggerSummaryData *json.RawMessage `json:"trigger_summary_data"` 19 TriggerDetailsHTMLUrl string `json:"trigger_details_html_url"` 20} 21 22// WebhookPayload is a single message array for a webhook. 23type WebhookPayload struct { 24 ID string `json:"id"` 25 Type string `json:"type"` 26 CreatedOn string `json:"created_on"` 27 Data *json.RawMessage `json:"data"` 28} 29 30// DecodeWebhook decodes a webhook from a response object. 31func DecodeWebhook(r io.Reader) (*WebhookPayload, error) { 32 var payload WebhookPayload 33 if err := json.NewDecoder(r).Decode(&payload); err != nil { 34 return nil, err 35 } 36 return &payload, nil 37} 38