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

Implement the Incident endpoint for ResponderRequest #196

Merged

Conversation

CerealBoy
Copy link
Contributor

Was hoping to use this functionality, but it lacks in the API here, so adding it in. Based on the docs this looks to be correct?

I wasn't entirely sure about the test case either, whether there is a way to provide better response content from the API (or have it generated).

@stmcallister
Copy link
Contributor

Cool! Thank you for submitting this pull request! I'll leave my comments inline!

Copy link
Contributor

@stmcallister stmcallister left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, really good! Just some styling changes. Let me know if you have any questions about the feedback. Thanks again for submitting!

incident.go Outdated
@@ -380,4 +380,46 @@ type ListAlertResponse struct {
Alerts []Alert `json:"alerts,omitempty"`
}

/* TODO: Manage Alerts, Get Alert, Create Status Updates, Create Responder Request, */
// CreateIncidentResponderRequestResponse
type CreateIncidentResponderRequestResponse struct {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we'll go with a shorter name. Will you remove all the CreateIncidents and start the names at ResponderRequest? So, this struct would be ResponderRequestResponse.

incident.go Outdated

data["message"] = o.Message
data["request_id"] = o.RequesterID
data["responder_request_targets"] = o.Targets
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than piece out each field in the payload object, will you create a ResponderRequestPayload struct with json tags and add that to the ResponderRequestOptions?

incident_test.go Outdated
id := "1"
mux.HandleFunc("/incidents/"+id+"/responder_requests", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "POST")
w.Write([]byte(`{"requester_id": "PL1JMK5", "message": "Help", "responder_request_targets": [{"responder_request_target":{"id":"PJ25ZYX","type":"user_reference"}}]}`))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is supposed to match the JSON of the response you're expecting. Can you change it to reflect the response?

…del the response, fix tests to actually model the data properly, use the data structures as a part of the request processing where possible
@CerealBoy
Copy link
Contributor Author

Hi @stmcallister, thank you very much for the feedback, I've made the changes as you've requested. The only difference I have is to use the ResponderRequestOptions as the payload, rather than having another struct purely for it. Would you prefer this to be split out?

Looking at the original commit, I can't work out how I managed to think the response payload looked the way it did considering the docs are completely different, so I've made a bunch of changes to better model the expected response data from this request.

@stmcallister
Copy link
Contributor

Looks good! Thanks for the feature and for making those changes @CerealBoy !

@stmcallister stmcallister merged commit 4fb5571 into PagerDuty:master Feb 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants