mirror of
https://github.com/sergeyyarkov/educt-client.git
synced 2026-10-11 18:29:15 +03:00
29 lines
656 B
TypeScript
29 lines
656 B
TypeScript
import { AxiosInstance } from 'axios';
|
|
import { IApiRespose, ICourse } from 'interfaces';
|
|
import { FetchCoursesParams } from 'types';
|
|
|
|
export class CourseService {
|
|
public api: AxiosInstance;
|
|
|
|
constructor(api: AxiosInstance) {
|
|
this.api = api;
|
|
}
|
|
|
|
/**
|
|
* Fetch all courses
|
|
*
|
|
* @returns Array of courses
|
|
*/
|
|
public async fetchAll(
|
|
params?: FetchCoursesParams
|
|
): Promise<IApiRespose<Omit<ICourse, 'teacher' | 'students' | 'lessons'>[]>> {
|
|
const result = await this.api.get('/v1/courses', {
|
|
params: {
|
|
status: params?.status,
|
|
category_id: params?.category_id,
|
|
},
|
|
});
|
|
return result.data;
|
|
}
|
|
}
|