Skip to content

Instantly share code, notes, and snippets.

Created December 20, 2012 20:15
Show Gist options
  • Save anonymous/4348184 to your computer and use it in GitHub Desktop.
Save anonymous/4348184 to your computer and use it in GitHub Desktop.
Here, I want to get a PR via API and then get the issue contents
pull_response = RestCall.get("/repos/bob/rails8/pulls")
issue_response = RestCall.get("/repos/bob/rails8/issues/#{response.first['issue']}")
# either of these might 404
pull_response = RestCall.get("/repos/bob/rails8/pulls")
issue_response = RestCall.get(pull_response.first["issue_url"]) # => oops, what if response is empty?
if pull_response.present?
issue_response = RestCall.get(pull_response.first["issue_url"]) # => oops, what if response issue_url isn't there?
end
if pull_response.present? && pull_response.first["issue_url"].present?
issue_response = RestCall.get(pull_response.first["issue_url"]) # OK!
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment