# Generated by `mix github.gen` from docs/github-api/api.github.com.json. # Do not edit by hand; re-run the task instead. defmodule Noizu.Github.Api.Licenses do @moduledoc """ GitHub `licenses` API. """ import Noizu.Github @doc """ Get a license @see https://docs.github.com/rest/licenses/licenses#get-a-license """ def get(license, options \\ nil) do url = github_base() <> "/licenses/#{license}" body = %{} api_call(:get, url, body, Noizu.Github.License, options) end @doc """ Get all commonly used licenses @see https://docs.github.com/rest/licenses/licenses#get-all-commonly-used-licenses """ def get_all_commonly_used(options \\ nil) do url = ( query = [ get_field(:featured, options, nil), get_field(:per_page, options, nil), get_field(:page, options, nil) ] |> Enum.filter(& &1) qs = if query == [], do: "", else: "?" <> Enum.join(query, "&") github_base() <> "/licenses" <> qs ) body = %{} api_call(:get, url, body, Noizu.Github.Collection.LicenseSimple, options) end @doc """ Get the license for a repository @see https://docs.github.com/rest/licenses/licenses#get-the-license-for-a-repository """ def get_for_repo(options \\ nil) do owner = repo_owner(options) repo = repo_name(options) url = ( query = [ get_field(:ref, options, nil) ] |> Enum.filter(& &1) qs = if query == [], do: "", else: "?" <> Enum.join(query, "&") github_base() <> "/repos/#{owner}/#{repo}/license" <> qs ) body = %{} api_call(:get, url, body, Noizu.Github.LicenseContent, options) end end