Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some mismatches between REST API and struct definitions #396

Merged
merged 1 commit into from
Nov 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions change_events.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,23 @@ const changeEventPath = "/v2/change/enqueue"
type ChangeEvent struct {
RoutingKey string `json:"routing_key"`
Payload ChangeEventPayload `json:"payload"`
Links []ChangeEventLink `json:"links"`
Links []ChangeEventLink `json:"links,omitempty"`
}

// ChangeEventPayload ChangeEvent ChangeEventPayload
// https://developer.pagerduty.com/docs/events-api-v2/send-change-events/#example-request-payload
type ChangeEventPayload struct {
Source string `json:"source"`
Summary string `json:"summary"`
Timestamp string `json:"timestamp"`
CustomDetails map[string]interface{} `json:"custom_details"`
Source string `json:"source,omitempty"`
Timestamp string `json:"timestamp,omitempty"`
CustomDetails map[string]interface{} `json:"custom_details,omitempty"`
}

// ChangeEventLink represents a single link in a ChangeEvent
// https://developer.pagerduty.com/docs/events-api-v2/send-change-events/#the-links-property
type ChangeEventLink struct {
Href string `json:"href"`
Text string `json:"text"`
Text string `json:"text,omitempty"`
}

// ChangeEventResponse is the json response body for an event
Expand Down
4 changes: 2 additions & 2 deletions change_events_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
)

const (
expectedChangeCreatePayload = `{"routing_key":"a0000000aa0000a0a000aa0a0a0aa000","payload":{"source":"Test runner",` +
`"summary":"Summary can't be blank","timestamp":"2020-10-19T03:06:16.318Z",` +
expectedChangeCreatePayload = `{"routing_key":"a0000000aa0000a0a000aa0a0a0aa000","payload":{"summary":"Summary can't be blank",` +
`"source":"Test runner","timestamp":"2020-10-19T03:06:16.318Z",` +
`"custom_details":{"DetailKey1":"DetailValue1","DetailKey2":"DetailValue2"}},` +
`"links":[{"href":"https://acme.pagerduty.dev/build/2","text":"View more details in Acme!"},` +
`{"href":"https://acme2.pagerduty.dev/build/2","text":"View more details in Acme2!"}]}`
Expand Down
1 change: 0 additions & 1 deletion escalation_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ type EscalationPolicy struct {
NumLoops uint `json:"num_loops,omitempty"`
Teams []APIReference `json:"teams"`
Description string `json:"description,omitempty"`
RepeatEnabled bool `json:"repeat_enabled,omitempty"`
}

// ListEscalationPoliciesResponse is the data structure returned from calling the ListEscalationPolicies API endpoint.
Expand Down