Octokit v0.0.1 Octokit.Client

A client to retrieve information from the GitHub API.

This client does minimal caching, only retaining the very last response from any call to the API. It also doesn’t do anything to ensure that you stay under your respective rate limit, though it does make the rate limit information available.

Summary

Functions

Gets the credentials used to create the client

Gets information on a single issue

Gets the last response object received from an API call

Gets information on all of the issues in a repo

Creates a new GitHub API client using the supplied credentials

Gets the rate limit information from the last response

Gets the rate limit informaiton from the API

Gets the URL for the named relative link from the last response

Gets information on a single repository

Gets information on a single user

Types

creds :: %{}
issue_number :: pos_integer | String.t
rate_limit :: %{limit: Integer.t, remaining: Integer.t, reset: Integer.t}
rel_name :: :first | :prev | :next | :last
repo ::
  pos_integer |
  String.t |
  Octokit.Repository.t
t :: pid

Functions

credentials(client)

Specs

credentials(t) :: creds

Gets the credentials used to create the client.

issue(client, repo, number, opts \\ [])

Specs

issue(t, repo, issue_number, request_opts) ::
  {:ok, Octokit.Issue.t} |
  {:error, any}

Gets information on a single issue.

last_response(client)

Specs

last_response(t) :: %HTTPoison.Response{body: term, headers: term, status_code: term}

Gets the last response object received from an API call.

list_issues(client, repo, opts \\ [])

Specs

list_issues(t, repo, request_opts) ::
  {:ok, [Octokit.Issue.t]} |
  {:error, any}

Gets information on all of the issues in a repo.

new(credentials \\ %{})

Specs

new(creds) :: t

Creates a new GitHub API client using the supplied credentials.

Examples

Creating an unauthenticated client:

iex> client = Octokit.Client.new
iex> is_pid(client)
true

Creating a client with an application’s client ID and secret:

iex> client = Octokit.Client.new(id: "client_id", secret: "client_secret")
iex> is_pid(client)
true

Creating a client with a user’s Personal Access token:

iex> client = Octokit.Client.new(token: "access_token")
iex> is_pid(client)
true
rate_limit(client)

Specs

rate_limit(t) :: rate_limit

Gets the rate limit information from the last response.

If there is no last response available, it makes a call to the rate limit API.

rate_limit!(client)

Specs

rate_limit!(t) :: rate_limit

Gets the rate limit informaiton from the API.

rels(client, name)

Specs

rels(t, rel_name) :: String.t

Gets the URL for the named relative link from the last response.

rel_name can be any of the following:

  • :first - URL to the first page of information
  • :prev - URL to the previous page of information
  • :next - URL to the next page of information
  • :last - URL to the last page of information

If :first and :prev are not defined, then the last response was the first page of information. If :next and :last are not defined, then the last response was the last page of information. Obviously, if none of them are defined, the last response contained all information requested.

repository(client, repo, opts \\ [])

Specs

repository(t, repo, request_opts) ::
  {:ok, Octokit.Repository.t} |
  {:error, any}

Gets information on a single repository.

user(client, user, opts \\ [])

Specs

user(t, user, request_opts) ::
  {:ok, Octokit.User.t} |
  {:error, any}

Gets information on a single user.