# 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.Search do
@moduledoc """
GitHub `search` API.
"""
import Noizu.Github
@doc """
Search code
@see https://docs.github.com/rest/search/search#search-code
"""
def code(options \\ nil) do
url =
(
query =
[
get_field(:q, options, nil),
get_field(:sort, options, nil),
get_field(:order, 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() <> "/search/code" <> qs
)
body = %{}
api_call(:get, url, body, Noizu.Github.Raw, options)
end
@doc """
Search commits
@see https://docs.github.com/rest/search/search#search-commits
"""
def commits(options \\ nil) do
url =
(
query =
[
get_field(:q, options, nil),
get_field(:sort, options, nil),
get_field(:order, 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() <> "/search/commits" <> qs
)
body = %{}
api_call(:get, url, body, Noizu.Github.Raw, options)
end
@doc """
Search issues and pull requests
@see https://docs.github.com/rest/search/search#search-issues-and-pull-requests
"""
def issues_and_pull_requests(options \\ nil) do
url =
(
query =
[
get_field(:q, options, nil),
get_field(:sort, options, nil),
get_field(:order, options, nil),
get_field(:per_page, options, nil),
get_field(:page, options, nil),
get_field(:advanced_search, options, nil),
get_field(:search_type, options, nil)
]
|> Enum.filter(& &1)
qs = if query == [], do: "", else: "?" <> Enum.join(query, "&")
github_base() <> "/search/issues" <> qs
)
body = %{}
api_call(:get, url, body, Noizu.Github.Raw, options)
end
@doc """
Search labels
@see https://docs.github.com/rest/search/search#search-labels
"""
def labels(options \\ nil) do
url =
(
query =
[
get_field(:repository_id, options, nil),
get_field(:q, options, nil),
get_field(:sort, options, nil),
get_field(:order, 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() <> "/search/labels" <> qs
)
body = %{}
api_call(:get, url, body, Noizu.Github.Raw, options)
end
@doc """
Search repositories
@see https://docs.github.com/rest/search/search#search-repositories
"""
def repos(options \\ nil) do
url =
(
query =
[
get_field(:q, options, nil),
get_field(:sort, options, nil),
get_field(:order, 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() <> "/search/repositories" <> qs
)
body = %{}
api_call(:get, url, body, Noizu.Github.Raw, options)
end
@doc """
Search topics
@see https://docs.github.com/rest/search/search#search-topics
"""
def topics(options \\ nil) do
url =
(
query =
[
get_field(:q, 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() <> "/search/topics" <> qs
)
body = %{}
api_call(:get, url, body, Noizu.Github.Raw, options)
end
@doc """
Search users
@see https://docs.github.com/rest/search/search#search-users
"""
def users(options \\ nil) do
url =
(
query =
[
get_field(:q, options, nil),
get_field(:sort, options, nil),
get_field(:order, 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() <> "/search/users" <> qs
)
body = %{}
api_call(:get, url, body, Noizu.Github.Raw, options)
end
end