forked from code-corps/code-corps-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpull_request.ex
More file actions
26 lines (23 loc) · 746 Bytes
/
pull_request.ex
File metadata and controls
26 lines (23 loc) · 746 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
defmodule CodeCorps.GitHub.API.PullRequest do
@moduledoc ~S"""
Functions for working with pull requests on GitHub.
"""
alias CodeCorps.{
GitHub,
GithubAppInstallation,
GithubRepo
}
@doc """
Fetches a pull request from the GitHub API, given the API URL for the pull
request and the `CodeCorps.GithubRepo` record that points to its GitHub
repository.
"""
def from_url(url, %GithubRepo{github_app_installation: %GithubAppInstallation{} = installation}) do
"https://api.github.com/" <> endpoint = url
with opts when is_list(opts) <- GitHub.API.opts_for(installation) do
GitHub.request(:get, endpoint, %{}, %{}, opts)
else
{:error, github_error} -> {:error, github_error}
end
end
end