fix: return type + any aangepast voor linter
This commit is contained in:
		
							parent
							
								
									f87c943530
								
							
						
					
					
						commit
						4bee95762b
					
				
					 4 changed files with 34 additions and 25 deletions
				
			
		|  | @ -17,31 +17,31 @@ export class AssignmentController extends BaseController { | ||||||
|         super(`class/${classid}/assignments`); |         super(`class/${classid}/assignments`); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     async getAll(full = true) { |     async getAll(full = true): Promise<AssignmentsResponse> { | ||||||
|         return this.get<AssignmentsResponse>(`/`, { full }); |         return this.get<AssignmentsResponse>(`/`, { full }); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     async getByNumber(num: number) { |     async getByNumber(num: number): Promise<AssignmentResponse> { | ||||||
|         return this.get<AssignmentResponse>(`/${num}`); |         return this.get<AssignmentResponse>(`/${num}`); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     async createAssignment(data: any) { |     async createAssignment(data: AssignmentDTO): Promise<AssignmentResponse> { | ||||||
|         return this.post<AssignmentResponse>(`/`, data); |         return this.post<AssignmentResponse>(`/`, data); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     async deleteAssignment(num: number) { |     async deleteAssignment(num: number): Promise<AssignmentResponse> { | ||||||
|         return this.delete<AssignmentResponse>(`/${num}`); |         return this.delete<AssignmentResponse>(`/${num}`); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     async getSubmissions(assignmentNumber: number, full = true) { |     async getSubmissions(assignmentNumber: number, full = true): Promise<SubmissionsResponse> { | ||||||
|         return this.get<SubmissionsResponse>(`/${assignmentNumber}/submissions`, { full }); |         return this.get<SubmissionsResponse>(`/${assignmentNumber}/submissions`, { full }); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     async getQuestions(assignmentNumber: number, full = true) { |     async getQuestions(assignmentNumber: number, full = true): Promise<QuestionsResponse> { | ||||||
|         return this.get<QuestionsResponse>(`/${assignmentNumber}/questions`, { full }); |         return this.get<QuestionsResponse>(`/${assignmentNumber}/questions`, { full }); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     async getGroups(assignmentNumber: number, full = true) { |     async getGroups(assignmentNumber: number, full = true): Promise<GroupsResponse> { | ||||||
|         return this.get<GroupsResponse>(`/${assignmentNumber}/groups`, { full }); |         return this.get<GroupsResponse>(`/${assignmentNumber}/groups`, { full }); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -2,6 +2,7 @@ import { BaseController } from "./base-controller"; | ||||||
| import type { ClassDTO } from "@dwengo-1/common/interfaces/class"; | import type { ClassDTO } from "@dwengo-1/common/interfaces/class"; | ||||||
| import type { StudentsResponse } from "./students"; | import type { StudentsResponse } from "./students"; | ||||||
| import type { AssignmentsResponse } from "./assignments"; | import type { AssignmentsResponse } from "./assignments"; | ||||||
|  | import type { TeacherInvitationDTO } from "@dwengo-1/common/interfaces/teacher-invitation"; | ||||||
| 
 | 
 | ||||||
| export interface ClassesResponse { | export interface ClassesResponse { | ||||||
|     classes: ClassDTO[] | string[]; |     classes: ClassDTO[] | string[]; | ||||||
|  | @ -11,37 +12,45 @@ export interface ClassResponse { | ||||||
|     class: ClassDTO; |     class: ClassDTO; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | export interface TeacherInvitationsResponse { | ||||||
|  |     invites: TeacherInvitationDTO[]; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | export interface TeacherInvitationResponse { | ||||||
|  |     invite: TeacherInvitationDTO; | ||||||
|  | } | ||||||
|  | 
 | ||||||
| export class ClassController extends BaseController { | export class ClassController extends BaseController { | ||||||
|     constructor() { |     constructor() { | ||||||
|         super("class"); |         super("class"); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     async getAll(full = true) { |     async getAll(full = true): Promise<ClassesResponse> { | ||||||
|         return this.get<ClassesResponse>(`/`, { full }); |         return this.get<ClassesResponse>(`/`, { full }); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     async getById(id: string) { |     async getById(id: string): Promise<ClassResponse> { | ||||||
|         return this.get<ClassResponse>(`/${id}`); |         return this.get<ClassResponse>(`/${id}`); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     async createClass(data: any) { |     async createClass(data: ClassDTO): Promise<ClassResponse> { | ||||||
|         return this.post<ClassResponse>(`/`, data); |         return this.post<ClassResponse>(`/`, data); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     async deleteClass(id: string) { |     async deleteClass(id: string): Promise<ClassResponse> { | ||||||
|         return this.delete<ClassResponse>(`/${id}`); |         return this.delete<ClassResponse>(`/${id}`); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     async getStudents(id: string, full = true) { |     async getStudents(id: string, full = true): Promise<StudentsResponse> { | ||||||
|         return this.get<StudentsResponse>(`/${id}/students`, { full }); |         return this.get<StudentsResponse>(`/${id}/students`, { full }); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     // TODO
 |     // TODO
 | ||||||
|     async getTeacherInvitations(id: string, full = true) { |     async getTeacherInvitations(id: string, full = true): Promise<TeacherInvitationsResponse> { | ||||||
|         return this.get<any>(`/${id}/teacher-invitations`, { full }); |         return this.get<TeacherInvitationsResponse>(`/${id}/teacher-invitations`, { full }); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     async getAssignments(id: string, full = true) { |     async getAssignments(id: string, full = true): Promise<AssignmentsResponse> { | ||||||
|         return this.get<AssignmentsResponse>(`/${id}/assignments`, { full }); |         return this.get<AssignmentsResponse>(`/${id}/assignments`, { full }); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -16,27 +16,27 @@ export class GroupController extends BaseController { | ||||||
|         super(`class/${classid}/assignments/${assignmentNumber}/groups`); |         super(`class/${classid}/assignments/${assignmentNumber}/groups`); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     async getAll(full = true) { |     async getAll(full = true): Promise<GroupsResponse> { | ||||||
|         return this.get<GroupsResponse>(`/`, { full }); |         return this.get<GroupsResponse>(`/`, { full }); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     async getByNumber(num: number) { |     async getByNumber(num: number): Promise<GroupResponse> { | ||||||
|         return this.get<GroupResponse>(`/${num}`); |         return this.get<GroupResponse>(`/${num}`); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     async createGroup(data: any) { |     async createGroup(data: GroupDTO): Promise<GroupResponse> { | ||||||
|         return this.post<GroupResponse>(`/`, data); |         return this.post<GroupResponse>(`/`, data); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     async deleteGroup(num: number) { |     async deleteGroup(num: number): Promise<GroupResponse> { | ||||||
|         return this.delete<GroupResponse>(`/${num}`); |         return this.delete<GroupResponse>(`/${num}`); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     async getSubmissions(groupNumber: number, full = true) { |     async getSubmissions(groupNumber: number, full = true): Promise<SubmissionsResponse> { | ||||||
|         return this.get<SubmissionsResponse>(`/${groupNumber}/submissions`, { full }); |         return this.get<SubmissionsResponse>(`/${groupNumber}/submissions`, { full }); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     async getQuestions(groupNumber: number, full = true) { |     async getQuestions(groupNumber: number, full = true): Promise<QuestionsResponse> { | ||||||
|         return this.get<QuestionsResponse>(`/${groupNumber}/questions`, { full }); |         return this.get<QuestionsResponse>(`/${groupNumber}/questions`, { full }); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -14,19 +14,19 @@ export class SubmissionController extends BaseController { | ||||||
|         super(`class/${classid}/assignments/${assignmentNumber}/groups/${groupNumber}`); |         super(`class/${classid}/assignments/${assignmentNumber}/groups/${groupNumber}`); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     async getAll(full = true) { |     async getAll(full = true): Promise<SubmissionsResponse> { | ||||||
|         return this.get<SubmissionsResponse>(`/`, { full }); |         return this.get<SubmissionsResponse>(`/`, { full }); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     async getByNumber(submissionNumber: number) { |     async getByNumber(submissionNumber: number): Promise<SubmissionResponse> { | ||||||
|         return this.get<SubmissionResponse>(`/${submissionNumber}`); |         return this.get<SubmissionResponse>(`/${submissionNumber}`); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     async createSubmission(data: any) { |     async createSubmission(data: any): Promise<SubmissionResponse> { | ||||||
|         return this.post<SubmissionResponse>(`/`, data); |         return this.post<SubmissionResponse>(`/`, data); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     async deleteSubmission(submissionNumber: number) { |     async deleteSubmission(submissionNumber: number): Promise<SubmissionResponse> { | ||||||
|         return this.delete<SubmissionResponse>(`/${submissionNumber}`); |         return this.delete<SubmissionResponse>(`/${submissionNumber}`); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
		Reference in a new issue
	
	 Gabriellvl
						Gabriellvl