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 the ResponderRequest input/output structures #328

Merged
merged 1 commit into from
Sep 1, 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
18 changes: 9 additions & 9 deletions incident.go
Original file line number Diff line number Diff line change
Expand Up @@ -557,19 +557,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
16 changes: 12 additions & 4 deletions incident_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ func TestIncident_ResponderRequest(t *testing.T) {
"type": "user_reference"
},
"message": "Help",
"responder_request_targets": {
"responder_request_targets": [{
"responder_request_target": {
"id": "PJ25ZYX",
"type": "user_reference",
Expand All @@ -555,7 +555,7 @@ func TestIncident_ResponderRequest(t *testing.T) {
}
}
}
}
}]
}
}`))
})
Expand All @@ -566,11 +566,15 @@ func TestIncident_ResponderRequest(t *testing.T) {
r.ID = "PJ25ZYX"
r.Type = "user_reference"

targets := []ResponderRequestTargets{
ResponderRequestTargets{Target: r},
}

input := ResponderRequestOptions{
From: from,
Message: "help",
RequesterID: "PL1JMK5",
Targets: []ResponderRequestTarget{r},
Targets: targets,
}

user := User{}
Expand All @@ -583,12 +587,16 @@ func TestIncident_ResponderRequest(t *testing.T) {
target.Responders.State = "pending"
target.Responders.User.ID = "PJ25ZYX"

targets = []ResponderRequestTargets{
ResponderRequestTargets{Target: target},
}

want := &ResponderRequestResponse{
ResponderRequest: ResponderRequest{
Incident: Incident{},
Requester: user,
Message: "Help",
Targets: ResponderRequestTargets{target},
Targets: targets,
},
}
res, err := client.ResponderRequest(id, input)
Expand Down