From c1b504039c88c4d90ab3e916af29ef039e03c225 Mon Sep 17 00:00:00 2001 From: Ally Weir Date: Wed, 16 Aug 2023 21:10:15 +0100 Subject: [PATCH] Make `ResponderRequestTarget.Responders` a slice (#493) This commit also tweaks the json key name as the previous key did not match the key used in production. --- incident.go | 2 +- incident_test.go | 27 ++++++++++++++++++++------- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/incident.go b/incident.go index 1c7286a9..48ac4cbd 100644 --- a/incident.go +++ b/incident.go @@ -659,7 +659,7 @@ type ResponderRequestResponse struct { // ResponderRequestTarget specifies an individual target for the responder request. type ResponderRequestTarget struct { APIObject - Responders IncidentResponders `json:"incident_responders,omitempty"` + Responders []IncidentResponders `json:"incidents_responders,omitempty"` } // ResponderRequestTargetWrapper is a wrapper for a ResponderRequestTarget. diff --git a/incident_test.go b/incident_test.go index 3d8759c0..5108b342 100644 --- a/incident_test.go +++ b/incident_test.go @@ -811,12 +811,16 @@ func TestIncident_ResponderRequest(t *testing.T) { "responder_request_target": { "id": "PJ25ZYX", "type": "user_reference", - "incident_responders": { - "state": "pending", - "user": { - "id": "PJ25ZYX" + "incidents_responders": [ + { + "state": "pending", + "user": { + "id": "PJ25ZYX", + "type": "user_reference", + "summary": "dave" + } } - } + ] } }] } @@ -846,8 +850,17 @@ func TestIncident_ResponderRequest(t *testing.T) { want_target := ResponderRequestTarget{} want_target.ID = "PJ25ZYX" want_target.Type = "user_reference" - want_target.Responders.State = "pending" - want_target.Responders.User.ID = "PJ25ZYX" + + want_target.Responders = []IncidentResponders{ + { + State: "pending", + User: APIObject{ + ID: "PJ25ZYX", + Type: "user_reference", + Summary: "dave", + }, + }, + } want_target_wrapper := ResponderRequestTargetWrapper{Target: want_target} want_targets := []ResponderRequestTargetWrapper{want_target_wrapper}