@@ -8,7 +8,6 @@ package github
8
8
import (
9
9
"context"
10
10
"fmt"
11
- "net/http"
12
11
)
13
12
14
13
// ClassroomService handles communication with the GitHub Classroom related
@@ -67,7 +66,7 @@ func (a ClassroomAssignment) String() string {
67
66
func (s * ClassroomService ) GetAssignment (ctx context.Context , assignmentID int64 ) (* ClassroomAssignment , * Response , error ) {
68
67
u := fmt .Sprintf ("assignments/%v" , assignmentID )
69
68
70
- req , err := s .client .NewRequest (http . MethodGet , u , nil )
69
+ req , err := s .client .NewRequest ("GET" , u , nil )
71
70
if err != nil {
72
71
return nil , nil , err
73
72
}
@@ -80,3 +79,79 @@ func (s *ClassroomService) GetAssignment(ctx context.Context, assignmentID int64
80
79
81
80
return assignment , resp , nil
82
81
}
82
+
83
+ // GetClassroom gets a GitHub Classroom for the current user. Classroom will only be
84
+ // returned if the current user is an administrator of the GitHub Classroom.
85
+ //
86
+ // GitHub API docs: https://docs.github.com/rest/classroom/classroom#get-a-classroom
87
+ //
88
+ //meta:operation GET /classrooms/{classroom_id}
89
+ func (s * ClassroomService ) GetClassroom (ctx context.Context , classroomID int64 ) (* Classroom , * Response , error ) {
90
+ u := fmt .Sprintf ("classrooms/%v" , classroomID )
91
+
92
+ req , err := s .client .NewRequest ("GET" , u , nil )
93
+ if err != nil {
94
+ return nil , nil , err
95
+ }
96
+
97
+ classroom := new (Classroom )
98
+ resp , err := s .client .Do (ctx , req , classroom )
99
+ if err != nil {
100
+ return nil , resp , err
101
+ }
102
+
103
+ return classroom , resp , nil
104
+ }
105
+
106
+ // ListClassrooms lists GitHub Classrooms for the current user. Classrooms will only be
107
+ // returned if the current user is an administrator of one or more GitHub Classrooms.
108
+ //
109
+ // GitHub API docs: https://docs.github.com/rest/classroom/classroom#list-classrooms
110
+ //
111
+ //meta:operation GET /classrooms
112
+ func (s * ClassroomService ) ListClassrooms (ctx context.Context , opts * ListOptions ) ([]* Classroom , * Response , error ) {
113
+ u , err := addOptions ("classrooms" , opts )
114
+ if err != nil {
115
+ return nil , nil , err
116
+ }
117
+
118
+ req , err := s .client .NewRequest ("GET" , u , nil )
119
+ if err != nil {
120
+ return nil , nil , err
121
+ }
122
+
123
+ var classrooms []* Classroom
124
+ resp , err := s .client .Do (ctx , req , & classrooms )
125
+ if err != nil {
126
+ return nil , resp , err
127
+ }
128
+
129
+ return classrooms , resp , nil
130
+ }
131
+
132
+ // ListClassroomAssignments lists GitHub Classroom assignments for a classroom. Assignments will only be
133
+ // returned if the current user is an administrator of the GitHub Classroom.
134
+ //
135
+ // GitHub API docs: https://docs.github.com/rest/classroom/classroom#list-assignments-for-a-classroom
136
+ //
137
+ //meta:operation GET /classrooms/{classroom_id}/assignments
138
+ func (s * ClassroomService ) ListClassroomAssignments (ctx context.Context , classroomID int64 , opts * ListOptions ) ([]* ClassroomAssignment , * Response , error ) {
139
+ u := fmt .Sprintf ("classrooms/%v/assignments" , classroomID )
140
+ u , err := addOptions (u , opts )
141
+ if err != nil {
142
+ return nil , nil , err
143
+ }
144
+
145
+ req , err := s .client .NewRequest ("GET" , u , nil )
146
+ if err != nil {
147
+ return nil , nil , err
148
+ }
149
+
150
+ var assignments []* ClassroomAssignment
151
+ resp , err := s .client .Do (ctx , req , & assignments )
152
+ if err != nil {
153
+ return nil , resp , err
154
+ }
155
+
156
+ return assignments , resp , nil
157
+ }
0 commit comments