1package pagerduty 2 3import ( 4 "github.com/google/go-querystring/query" 5) 6 7// Notification is a message containing the details of the incident. 8type Notification struct { 9 ID string `json:"id"` 10 Type string 11 StartedAt string `json:"started_at"` 12 Address string 13 User APIObject 14} 15 16// ListNotificationOptions is the data structure used when calling the ListNotifications API endpoint. 17type ListNotificationOptions struct { 18 APIListObject 19 TimeZone string `url:"time_zone,omitempty"` 20 Since string `url:"since,omitempty"` 21 Until string `url:"until,omitempty"` 22 Filter string `url:"filter,omitempty"` 23 Includes []string `url:"include,omitempty"` 24} 25 26// ListNotificationsResponse is the data structure returned from the ListNotifications API endpoint. 27type ListNotificationsResponse struct { 28 APIListObject 29 Notifications []Notification 30} 31 32// ListNotifications lists notifications for a given time range, optionally filtered by type (sms_notification, email_notification, phone_notification, or push_notification). 33func (c *Client) ListNotifications(o ListNotificationOptions) (*ListNotificationsResponse, error) { 34 v, err := query.Values(o) 35 if err != nil { 36 return nil, err 37 } 38 resp, err := c.get("/notifications?" + v.Encode()) 39 if err != nil { 40 return nil, err 41 } 42 var result ListNotificationsResponse 43 return &result, c.decodeJSON(resp, &result) 44} 45