Skip to main content

lib/api/classroom/classroom.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.Classroom do
  @moduledoc """
  GitHub `classroom` API.
  """
  import Noizu.Github

  @doc """
  Get a classroom

  @see https://docs.github.com/rest/classroom/classroom#get-a-classroom
  """
  def get_a_classroom(classroom_id, options \\ nil) do
    url = github_base() <> "/classrooms/#{classroom_id}"
    body = %{}
    api_call(:get, url, body, Noizu.Github.Classroom, options)
  end

  @doc """
  Get an assignment

  @see https://docs.github.com/rest/classroom/classroom#get-an-assignment
  """
  def get_an_assignment(assignment_id, options \\ nil) do
    url = github_base() <> "/assignments/#{assignment_id}"
    body = %{}
    api_call(:get, url, body, Noizu.Github.ClassroomAssignment, options)
  end

  @doc """
  Get assignment grades

  @see https://docs.github.com/rest/classroom/classroom#get-assignment-grades
  """
  def get_assignment_grades(assignment_id, options \\ nil) do
    url = github_base() <> "/assignments/#{assignment_id}/grades"
    body = %{}
    api_call(:get, url, body, Noizu.Github.Collection.ClassroomAssignmentGrade, options)
  end

  @doc """
  List accepted assignments for an assignment

  @see https://docs.github.com/rest/classroom/classroom#list-accepted-assignments-for-an-assignment
  """
  def list_accepted_assignments_for_an_assignment(assignment_id, options \\ nil) do
    url =
      (
        query =
          [
            get_field(:page, options, nil),
            get_field(:per_page, options, nil)
          ]
          |> Enum.filter(& &1)

        qs = if query == [], do: "", else: "?" <> Enum.join(query, "&")
        github_base() <> "/assignments/#{assignment_id}/accepted_assignments" <> qs
      )

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

  @doc """
  List assignments for a classroom

  @see https://docs.github.com/rest/classroom/classroom#list-assignments-for-a-classroom
  """
  def list_assignments_for_a_classroom(classroom_id, options \\ nil) do
    url =
      (
        query =
          [
            get_field(:page, options, nil),
            get_field(:per_page, options, nil)
          ]
          |> Enum.filter(& &1)

        qs = if query == [], do: "", else: "?" <> Enum.join(query, "&")
        github_base() <> "/classrooms/#{classroom_id}/assignments" <> qs
      )

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

  @doc """
  List classrooms

  @see https://docs.github.com/rest/classroom/classroom#list-classrooms
  """
  def list_classrooms(options \\ nil) do
    url =
      (
        query =
          [
            get_field(:page, options, nil),
            get_field(:per_page, options, nil)
          ]
          |> Enum.filter(& &1)

        qs = if query == [], do: "", else: "?" <> Enum.join(query, "&")
        github_base() <> "/classrooms" <> qs
      )

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