Skip to main content

lib/api/reactions/reactions.ex

# 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.Reactions do
  @moduledoc """
  GitHub `reactions` API.
  """
  import Noizu.Github

  @doc """
  Create reaction for a commit comment

  @see https://docs.github.com/rest/reactions/reactions#create-reaction-for-a-commit-comment
  """
  def create_for_commit_comment(comment_id, body, options \\ nil) do
    owner = repo_owner(options)
    repo = repo_name(options)
    url = github_base() <> "/repos/#{owner}/#{repo}/comments/#{comment_id}/reactions"
    body = body
    api_call(:post, url, body, Noizu.Github.Reaction, options)
  end

  @doc """
  Create reaction for an issue

  @see https://docs.github.com/rest/reactions/reactions#create-reaction-for-an-issue
  """
  def create_for_issue(issue_number, body, options \\ nil) do
    owner = repo_owner(options)
    repo = repo_name(options)
    url = github_base() <> "/repos/#{owner}/#{repo}/issues/#{issue_number}/reactions"
    body = body
    api_call(:post, url, body, Noizu.Github.Reaction, options)
  end

  @doc """
  Create reaction for an issue comment

  @see https://docs.github.com/rest/reactions/reactions#create-reaction-for-an-issue-comment
  """
  def create_for_issue_comment(comment_id, body, options \\ nil) do
    owner = repo_owner(options)
    repo = repo_name(options)
    url = github_base() <> "/repos/#{owner}/#{repo}/issues/comments/#{comment_id}/reactions"
    body = body
    api_call(:post, url, body, Noizu.Github.Reaction, options)
  end

  @doc """
  Create reaction for a pull request review comment

  @see https://docs.github.com/rest/reactions/reactions#create-reaction-for-a-pull-request-review-comment
  """
  def create_for_pull_request_review_comment(comment_id, body, options \\ nil) do
    owner = repo_owner(options)
    repo = repo_name(options)
    url = github_base() <> "/repos/#{owner}/#{repo}/pulls/comments/#{comment_id}/reactions"
    body = body
    api_call(:post, url, body, Noizu.Github.Reaction, options)
  end

  @doc """
  Create reaction for a release

  @see https://docs.github.com/rest/reactions/reactions#create-reaction-for-a-release
  """
  def create_for_release(release_id, body, options \\ nil) do
    owner = repo_owner(options)
    repo = repo_name(options)
    url = github_base() <> "/repos/#{owner}/#{repo}/releases/#{release_id}/reactions"
    body = body
    api_call(:post, url, body, Noizu.Github.Reaction, options)
  end

  @doc """
  Delete a commit comment reaction

  @see https://docs.github.com/rest/reactions/reactions#delete-a-commit-comment-reaction
  """
  def delete_for_commit_comment(comment_id, reaction_id, options \\ nil) do
    owner = repo_owner(options)
    repo = repo_name(options)

    url =
      github_base() <> "/repos/#{owner}/#{repo}/comments/#{comment_id}/reactions/#{reaction_id}"

    body = %{}
    api_call(:delete, url, body, Noizu.Github.Raw, options)
  end

  @doc """
  Delete an issue reaction

  @see https://docs.github.com/rest/reactions/reactions#delete-an-issue-reaction
  """
  def delete_for_issue(issue_number, reaction_id, options \\ nil) do
    owner = repo_owner(options)
    repo = repo_name(options)

    url =
      github_base() <> "/repos/#{owner}/#{repo}/issues/#{issue_number}/reactions/#{reaction_id}"

    body = %{}
    api_call(:delete, url, body, Noizu.Github.Raw, options)
  end

  @doc """
  Delete an issue comment reaction

  @see https://docs.github.com/rest/reactions/reactions#delete-an-issue-comment-reaction
  """
  def delete_for_issue_comment(comment_id, reaction_id, options \\ nil) do
    owner = repo_owner(options)
    repo = repo_name(options)

    url =
      github_base() <>
        "/repos/#{owner}/#{repo}/issues/comments/#{comment_id}/reactions/#{reaction_id}"

    body = %{}
    api_call(:delete, url, body, Noizu.Github.Raw, options)
  end

  @doc """
  Delete a pull request comment reaction

  @see https://docs.github.com/rest/reactions/reactions#delete-a-pull-request-comment-reaction
  """
  def delete_for_pull_request_comment(comment_id, reaction_id, options \\ nil) do
    owner = repo_owner(options)
    repo = repo_name(options)

    url =
      github_base() <>
        "/repos/#{owner}/#{repo}/pulls/comments/#{comment_id}/reactions/#{reaction_id}"

    body = %{}
    api_call(:delete, url, body, Noizu.Github.Raw, options)
  end

  @doc """
  Delete a release reaction

  @see https://docs.github.com/rest/reactions/reactions#delete-a-release-reaction
  """
  def delete_for_release(release_id, reaction_id, options \\ nil) do
    owner = repo_owner(options)
    repo = repo_name(options)

    url =
      github_base() <> "/repos/#{owner}/#{repo}/releases/#{release_id}/reactions/#{reaction_id}"

    body = %{}
    api_call(:delete, url, body, Noizu.Github.Raw, options)
  end

  @doc """
  List reactions for a commit comment

  @see https://docs.github.com/rest/reactions/reactions#list-reactions-for-a-commit-comment
  """
  def list_for_commit_comment(comment_id, options \\ nil) do
    owner = repo_owner(options)
    repo = repo_name(options)

    url =
      (
        query =
          [
            get_field(:content, 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() <> "/repos/#{owner}/#{repo}/comments/#{comment_id}/reactions" <> qs
      )

    body = %{}
    api_call(:get, url, body, Noizu.Github.Collection.Reaction, options)
  end

  @doc """
  List reactions for an issue

  @see https://docs.github.com/rest/reactions/reactions#list-reactions-for-an-issue
  """
  def list_for_issue(issue_number, options \\ nil) do
    owner = repo_owner(options)
    repo = repo_name(options)

    url =
      (
        query =
          [
            get_field(:content, 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() <> "/repos/#{owner}/#{repo}/issues/#{issue_number}/reactions" <> qs
      )

    body = %{}
    api_call(:get, url, body, Noizu.Github.Collection.Reaction, options)
  end

  @doc """
  List reactions for an issue comment

  @see https://docs.github.com/rest/reactions/reactions#list-reactions-for-an-issue-comment
  """
  def list_for_issue_comment(comment_id, options \\ nil) do
    owner = repo_owner(options)
    repo = repo_name(options)

    url =
      (
        query =
          [
            get_field(:content, 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() <> "/repos/#{owner}/#{repo}/issues/comments/#{comment_id}/reactions" <> qs
      )

    body = %{}
    api_call(:get, url, body, Noizu.Github.Collection.Reaction, options)
  end

  @doc """
  List reactions for a pull request review comment

  @see https://docs.github.com/rest/reactions/reactions#list-reactions-for-a-pull-request-review-comment
  """
  def list_for_pull_request_review_comment(comment_id, options \\ nil) do
    owner = repo_owner(options)
    repo = repo_name(options)

    url =
      (
        query =
          [
            get_field(:content, 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() <> "/repos/#{owner}/#{repo}/pulls/comments/#{comment_id}/reactions" <> qs
      )

    body = %{}
    api_call(:get, url, body, Noizu.Github.Collection.Reaction, options)
  end

  @doc """
  List reactions for a release

  @see https://docs.github.com/rest/reactions/reactions#list-reactions-for-a-release
  """
  def list_for_release(release_id, options \\ nil) do
    owner = repo_owner(options)
    repo = repo_name(options)

    url =
      (
        query =
          [
            get_field(:content, 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() <> "/repos/#{owner}/#{repo}/releases/#{release_id}/reactions" <> qs
      )

    body = %{}
    api_call(:get, url, body, Noizu.Github.Collection.Reaction, options)
  end
end