github v0.11.0 Github.Client View Source

Struct which represents GitHub client

Link to this section Summary

Link to this section Functions

Link to this function fetch_all!(github_response) View Source

The rest of the paginated pages

Example

iex> client = %Github.Client{access_token: "access_token"}
iex> response1 = client |> Github.Apps.Installations.list_repos!(per_page: 30)
%Github.Client.Response{
  next_url: "https://api.github.com/installation/repositories?per_page=30&page=2",
  last_url: "https://api.github.com/installation/repositories?per_page=30&page=3",
  status: 200,
  ...
}

iex> responses = client.fetch_all!(response1)
[
  %Github.Client.Response{
    next_url: "https://api.github.com/installation/repositories?per_page=30&page=3",
    last_url: "https://api.github.com/installation/repositories?per_page=30&page=3",
    status: 200,
    ...
  },
  %Github.Client.Response{
    next_url: nil,
    last_url: "https://api.github.com/installation/repositories?per_page=30&page=3",
    status: 200,
    ...
  }
]

To reduce number of HTTP requests it is recommended to specify the largest per_page value 100 in the first request.

Link to this function fetch_more!(github_response) View Source

The next paginated page

Example

iex> client = %Github.Client{access_token: "access_token"}
iex> response1 = client |> Github.Apps.Installations.list_repos!(per_page: 1)
%Github.Client.Response{
  next_url: "https://api.github.com/installation/repositories?per_page=1&page=2",
  last_url: "https://api.github.com/installation/repositories?per_page=1&page=77",
  status: 200,
  ...
}

iex> response2 = client.fetch_more!(response1)
%Github.Client.Response{
  next_url: "https://api.github.com/installation/repositories?per_page=1&page=3",
  last_url: "https://api.github.com/installation/repositories?per_page=1&page=77",
  status: 200,
  ...
}
Link to this function generate_jwt_token(options) View Source

Generate GitHub JWT token with App ID and private key

Example

iex> Github.Client.generate_jwt_token(id: 12345, private_key_filepath: "app.pem", expire_in_minutes: 10)
"eyJhbGciOiJSU..."
Link to this function post!(url, body, headers) View Source