Skip to content

Commit

Permalink
couple of syntax and unmarshaling fixes. closes PagerDuty#232
Browse files Browse the repository at this point in the history
adding array definition to ResponderRequest

vet your code kids.
  • Loading branch information
Erog38 committed Apr 5, 2021
1 parent ab036b7 commit 697313a
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 14 deletions.
22 changes: 11 additions & 11 deletions incident.go
Original file line number Diff line number Diff line change
Expand Up @@ -392,8 +392,8 @@ type ListIncidentLogEntriesOptions struct {
Includes []string `url:"include,omitempty,brackets"`
IsOverview bool `url:"is_overview,omitempty"`
TimeZone string `url:"time_zone,omitempty"`
Since string `url:since,omitempty`
Until string `url:until,omitempty`
Since string `url:"since,omitempty"`
Until string `url:"until,omitempty"`
}

// ListIncidentLogEntries lists existing log entries for the specified incident.
Expand Down Expand Up @@ -439,19 +439,19 @@ type ResponderRequestTargets struct {

// ResponderRequestOptions defines the input options for the Create Responder function.
type ResponderRequestOptions struct {
From string `json:"-"`
Message string `json:"message"`
RequesterID string `json:"requester_id"`
Targets []ResponderRequestTarget `json:"responder_request_targets"`
From string `json:"-"`
Message string `json:"message"`
RequesterID string `json:"requester_id"`
Targets []ResponderRequestTargets `json:"responder_request_targets"`
}

// ResponderRequest contains the API structure for an incident responder request.
type ResponderRequest struct {
Incident Incident `json:"incident"`
Requester User `json:"requester,omitempty"`
RequestedAt string `json:"request_at,omitempty"`
Message string `json:"message,omitempty"`
Targets ResponderRequestTargets `json:"responder_request_targets"`
Incident Incident `json:"incident"`
Requester User `json:"requester,omitempty"`
RequestedAt string `json:"request_at,omitempty"`
Message string `json:"message,omitempty"`
Targets []ResponderRequestTargets `json:"responder_request_targets"`
}

// ResponderRequest will submit a request to have a responder join an incident.
Expand Down
4 changes: 2 additions & 2 deletions incident_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,7 @@ func TestIncident_ResponderRequest(t *testing.T) {
From: from,
Message: "help",
RequesterID: "PL1JMK5",
Targets: []ResponderRequestTarget{r},
Targets: []ResponderRequestTargets{{r}},
}

user := User{}
Expand All @@ -591,7 +591,7 @@ func TestIncident_ResponderRequest(t *testing.T) {
Incident: Incident{},
Requester: user,
Message: "Help",
Targets: ResponderRequestTargets{target},
Targets: []ResponderRequestTargets{{target}},
},
}
res, err := client.ResponderRequest(id, input)
Expand Down
8 changes: 7 additions & 1 deletion webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ type IncidentDetails struct {
Urgency string `json:"urgency"`
ResolveReason *string `json:"resolve_reason"`
AlertCounts AlertCounts `json:"alert_counts"`
Alerts []WebhookAlert `json:"alerts"`
Metadata interface{} `json:"metadata"`
Description string `json:"description"`
}
Expand All @@ -40,11 +41,16 @@ type WebhookPayloadMessages struct {
type WebhookPayload struct {
ID string `json:"id"`
Event string `json:"event"`
CreatedOn time.Time `json:"created_on`
CreatedOn time.Time `json:"created_on"`
Incident IncidentDetails `json:"incident"`
LogEntries []LogEntry `json:"log_entries"`
}

// WebhookAlert describes the alert of the incident
type WebhookAlert struct {
AlertKey string `json:"alert_key"`
}

// DecodeWebhook decodes a webhook from a response object.
func DecodeWebhook(r io.Reader) (*WebhookPayloadMessages, error) {
var payload WebhookPayloadMessages
Expand Down

0 comments on commit 697313a

Please sign in to comment.