CourseService
1. Import the service from our library:
import {CourseService} from "@selfcommunity/api-services";
2. Create a function and put the service inside it!
The async function `searchCourses` will return the events matching the search query.
async searchCourses() {
return await CourseService.searchCourses();
}
In case of required `params`, just add them inside the brackets.
async getSpecificCourseInfo(eventId) {
return await CourseService.getSpecificCourseInfo(eventId);
}
If you need to customize the request, you can add optional config params (`AxiosRequestConfig` type).
1. Declare it(or declare them, it is possible to add multiple params)
const headers = headers: {Authorization: `Bearer ${yourToken}`}
2. Add it inside the brackets and pass it to the function, as shown in the previous example!
Constructors
Constructor
new CourseService():
CourseService
Returns
CourseService
Methods
changeCourseCover()
static
changeCourseCover(id
,data
,config?
):Promise
<SCCourseType
>
Parameters
Parameter | Type |
---|---|
id | string | number |
data | FormData |
config? | AxiosRequestConfig |
Returns
Promise
<SCCourseType
>
changeCourseUserRole()
static
changeCourseUserRole(id
,data
,config?
):Promise
<any
>
Parameters
Parameter | Type |
---|---|
id | string | number |
data | CourseUserRoleParams |
config? | AxiosRequestConfig |
Returns
Promise
<any
>
createCourse()
static
createCourse(data
,config?
):Promise
<SCCourseType
>
Parameters
Parameter | Type |
---|---|
data | CourseCreateParams | FormData |
config? | AxiosRequestConfig |
Returns
Promise
<SCCourseType
>
createCourseComment()
static
createCourseComment(id
,section_id
,lesson_id
,data
,config?
):Promise
<SCCourseCommentType
>
Parameters
Parameter | Type |
---|---|
id | string | number |
section_id | string | number |
lesson_id | string | number |
data | SCCourseCommentType |
config? | AxiosRequestConfig |
Returns
Promise
<SCCourseCommentType
>
createCourseLesson()
static
createCourseLesson(data
,config?
):Promise
<SCCourseLessonType
>
Parameters
Parameter | Type |
---|---|
data | SCCourseLessonType |
config? | AxiosRequestConfig |
Returns
Promise
<SCCourseLessonType
>
createCourseSection()
static
createCourseSection(id
,data
,config?
):Promise
<SCCourseSectionType
>
Parameters
Parameter | Type |
---|---|
id | string | number |
data | CourseSectionParams |
config? | AxiosRequestConfig |
Returns
Promise
<SCCourseSectionType
>
deleteCourse()
static
deleteCourse(id
,config?
):Promise
<any
>
Parameters
Parameter | Type |
---|---|
id | string | number |
config? | AxiosRequestConfig |
Returns
Promise
<any
>
deleteCourseComment()
static
deleteCourseComment(id
,section_id
,lesson_id
,comment_id
,config?
):Promise
<any
>
Parameters
Parameter | Type |
---|---|
id | string | number |
section_id | string | number |
lesson_id | string | number |
comment_id | string | number |
config? | AxiosRequestConfig |
Returns
Promise
<any
>
deleteCourseLesson()
static
deleteCourseLesson(id
,section_id
,lesson_id
,config?
):Promise
<any
>
Parameters
Parameter | Type |
---|---|
id | string | number |
section_id | string | number |
lesson_id | string | number |
config? | AxiosRequestConfig |
Returns
Promise
<any
>
deleteCourseSection()
static
deleteCourseSection(id
,section_id
,config?
):Promise
<any
>
Parameters
Parameter | Type |
---|---|
id | string | number |
section_id | string | number |
config? | AxiosRequestConfig |
Returns
Promise
<any
>
getCourseComments()
static
getCourseComments(id
,params?
,config?
):Promise
<SCPaginatedResponse
<SCCourseCommentType
>>
Parameters
Parameter | Type |
---|---|
id | string | number |
params? | BaseGetParams |
config? | AxiosRequestConfig |
Returns
Promise
<SCPaginatedResponse
<SCCourseCommentType
>>
getCourseDashboardUsers()
static
getCourseDashboardUsers(id
,params?
,config?
):Promise
<SCPaginatedResponse
<SCUserType
>>
Parameters
Parameter | Type |
---|---|
id | string | number |
params? | CourseDashboardUsersParams |
config? | AxiosRequestConfig |
Returns
Promise
<SCPaginatedResponse
<SCUserType
>>
getCourseInvitedUsers()
static
getCourseInvitedUsers(id
,params?
,config?
):Promise
<SCPaginatedResponse
<SCUserType
>>
Parameters
Parameter | Type |
---|---|
id | string | number |
params? | BaseGetParams |
config? | AxiosRequestConfig |
Returns
Promise
<SCPaginatedResponse
<SCUserType
>>
getCourseJoinedUsers()
static
getCourseJoinedUsers(id
,params?
,config?
):Promise
<SCPaginatedResponse
<SCUserType
>>
Parameters
Parameter | Type |
---|---|
id | string | number |
params? | CourseUsersParams |
config? | AxiosRequestConfig |
Returns
Promise
<SCPaginatedResponse
<SCUserType
>>
getCourseLesson()
static
getCourseLesson(id
,section_id
,lesson_id
,config?
):Promise
<SCCourseLessonType
>
Parameters
Parameter | Type |
---|---|
id | string | number |
section_id | string | number |
lesson_id | string | number |
config? | AxiosRequestConfig |
Returns
Promise
<SCCourseLessonType
>
getCourseLessonComment()
static
getCourseLessonComment(id
,section_id
,lesson_id
,comment_id
,config?
):Promise
<SCCourseCommentType
>
Parameters
Parameter | Type |
---|---|
id | string | number |
section_id | string | number |
lesson_id | string | number |
comment_id | string | number |
config? | AxiosRequestConfig |
Returns
Promise
<SCCourseCommentType
>
getCourseLessonComments()
static
getCourseLessonComments(id
,section_id
,lesson_id
,params?
,config?
):Promise
<SCCourseCommentType
[]>
Parameters
Parameter | Type |
---|---|
id | string | number |
section_id | string | number |
lesson_id | string | number |
params? | CourseLessonCommentsParams |
config? | AxiosRequestConfig |
Returns
Promise
<SCCourseCommentType
[]>
getCourseLessons()
static
getCourseLessons(id
,section_id
,config?
):Promise
<SCCourseLessonType
[]>
Parameters
Parameter | Type |
---|---|
id | string | number |
section_id | string | number |
config? | AxiosRequestConfig |
Returns
Promise
<SCCourseLessonType
[]>
getCourseSection()
static
getCourseSection(id
,section_id
,config?
):Promise
<SCCourseSectionType
>
Parameters
Parameter | Type |
---|---|
id | string | number |
section_id | string | number |
config? | AxiosRequestConfig |
Returns
Promise
<SCCourseSectionType
>
getCourseSections()
static
getCourseSections(id
,config?
):Promise
<SCCourseSectionType
[]>
Parameters
Parameter | Type |
---|---|
id | string | number |
config? | AxiosRequestConfig |
Returns
Promise
<SCCourseSectionType
[]>
getCourseStatus()
static
getCourseStatus(id
,config?
):Promise
<SCPaginatedResponse
<any
>>
Parameters
Parameter | Type |
---|---|
id | string | number |
config? | AxiosRequestConfig |
Returns
Promise
<SCPaginatedResponse
<any
>>
getCourseSuggestedUsers()
static
getCourseSuggestedUsers(id
,search
,config?
):Promise
<SCPaginatedResponse
<SCUserType
>>
Parameters
Parameter | Type |
---|---|
id | string | number |
search | string |
config? | AxiosRequestConfig |
Returns
Promise
<SCPaginatedResponse
<SCUserType
>>
getCourseWaitingApproval()
static
getCourseWaitingApproval(id
,params?
,config?
):Promise
<SCPaginatedResponse
<SCUserType
>>
Parameters
Parameter | Type |
---|---|
id | string | number |
params? | BaseSearchParams |
config? | AxiosRequestConfig |
Returns
Promise
<SCPaginatedResponse
<SCUserType
>>
getJoinedCourses()
static
getJoinedCourses(params?
,config?
):Promise
<SCPaginatedResponse
<SCCourseType
>>
Parameters
Parameter | Type |
---|---|
params? | CourseUserParams |
config? | AxiosRequestConfig |
Returns
Promise
<SCPaginatedResponse
<SCCourseType
>>
getSpecificCourseInfo()
static
getSpecificCourseInfo(id
,params?
,config?
):Promise
<SCCourseType
>
Parameters
Parameter | Type |
---|---|
id | string | number |
params? | CourseInfoParams |
config? | AxiosRequestConfig |
Returns
Promise
<SCCourseType
>
getUserJoinedCourses()
static
getUserJoinedCourses(id
,params?
,config?
):Promise
<SCPaginatedResponse
<SCCourseType
>>
Parameters
Parameter | Type |
---|---|
id | string | number |
params? | CourseUsersParams |
config? | AxiosRequestConfig |
Returns
Promise
<SCPaginatedResponse
<SCCourseType
>>
inviteOrAcceptUsersToCourse()
static
inviteOrAcceptUsersToCourse(id
,data
,config?
):Promise
<any
>
Parameters
Parameter | Type |
---|---|
id | string | number |
data | { users : number []; } |
data.users | number [] |
config? | AxiosRequestConfig |
Returns
Promise
<any
>
joinOrAcceptInviteToCourse()
static
joinOrAcceptInviteToCourse(id
,config?
):Promise
<SCCourseType
>
Parameters
Parameter | Type |
---|---|
id | string | number |
config? | AxiosRequestConfig |
Returns
Promise
<SCCourseType
>
leaveOrRemoveCourseRequest()
static
leaveOrRemoveCourseRequest(id
,params?
,config?
):Promise
<any
>
Parameters
Parameter | Type |
---|---|
id | string | number |
params? | { user : number ; } |
params.user? | number |
config? | AxiosRequestConfig |
Returns
Promise
<any
>
markLessonComplete()
static
markLessonComplete(id
,section_id
,lesson_id
,config?
):Promise
<any
>
Parameters
Parameter | Type |
---|---|
id | string | number |
section_id | string | number |
lesson_id | string | number |
config? | AxiosRequestConfig |
Returns
Promise
<any
>
markLessonIncomplete()
static
markLessonIncomplete(id
,section_id
,lesson_id
,config?
):Promise
<any
>
Parameters
Parameter | Type |
---|---|
id | string | number |
section_id | string | number |
lesson_id | string | number |
config? | AxiosRequestConfig |
Returns
Promise
<any
>
patchCourse()
static
patchCourse(id
,data
,config?
):Promise
<SCCourseType
>
Parameters
Parameter | Type |
---|---|
id | string | number |
data | Partial <SCCourseType > | FormData |
config? | AxiosRequestConfig |
Returns
Promise
<SCCourseType
>
patchCourseComment()
static
patchCourseComment(id
,section_id
,lesson_id
,comment_id
,data
,config?
):Promise
<SCCourseCommentType
>
Parameters
Parameter | Type |
---|---|
id | string | number |
section_id | string | number |
lesson_id | string | number |
comment_id | string | number |
data | SCCourseLessonType |
config? | AxiosRequestConfig |
Returns
Promise
<SCCourseCommentType
>
patchCourseLesson()
static
patchCourseLesson(id
,section_id
,lesson_id
,data
,config?
):Promise
<SCCourseLessonType
>
Parameters
Parameter | Type |
---|---|
id | string | number |
section_id | string | number |
lesson_id | string | number |
data | Partial <SCCourseLessonType > |
config? | AxiosRequestConfig |
Returns
Promise
<SCCourseLessonType
>
patchCourseSection()
static
patchCourseSection(id
,section_id
,data
,config?
):Promise
<SCCourseSectionType
>
Parameters
Parameter | Type |
---|---|
id | string | number |
section_id | string | number |
data | SCCourseSectionType |
config? | AxiosRequestConfig |
Returns
Promise
<SCCourseSectionType
>
removeInvitationToCourse()
static
removeInvitationToCourse(id
,data
,config?
):Promise
<any
>
Parameters
Parameter | Type |
---|---|
id | string | number |
data | { users : number []; } |
data.users | number [] |
config? | AxiosRequestConfig |
Returns
Promise
<any
>
searchCourses()
static
searchCourses(params?
,config?
):Promise
<SCPaginatedResponse
<SCCourseType
>>
Parameters
Parameter | Type |
---|---|
params? | CourseSearchParams |
config? | AxiosRequestConfig |
Returns
Promise
<SCPaginatedResponse
<SCCourseType
>>
updateCourse()
static
updateCourse(id
,data
,config?
):Promise
<SCCourseType
>
Parameters
Parameter | Type |
---|---|
id | string | number |
data | SCCourseType | FormData |
config? | AxiosRequestConfig |
Returns
Promise
<SCCourseType
>
updateCourseComment()
static
updateCourseComment(id
,section_id
,lesson_id
,comment_id
,data
,config?
):Promise
<SCCourseCommentType
>
Parameters
Parameter | Type |
---|---|
id | string | number |
section_id | string | number |
lesson_id | string | number |
comment_id | string | number |
data | SCCourseCommentType |
config? | AxiosRequestConfig |
Returns
Promise
<SCCourseCommentType
>
updateCourseLesson()
static
updateCourseLesson(id
,section_id
,lesson_id
,data
,config?
):Promise
<SCCourseLessonType
>
Parameters
Parameter | Type |
---|---|
id | string | number |
section_id | string | number |
lesson_id | string | number |
data | SCCourseLessonType |
config? | AxiosRequestConfig |
Returns
Promise
<SCCourseLessonType
>
updateCourseSection()
static
updateCourseSection(id
,section_id
,data
,config?
):Promise
<SCCourseSectionType
>
Parameters
Parameter | Type |
---|---|
id | string | number |
section_id | string | number |
data | SCCourseSectionType |
config? | AxiosRequestConfig |
Returns
Promise
<SCCourseSectionType
>