mirror of
https://github.com/rzmk/learnhouse.git
synced 2025-12-19 04:19:25 +00:00
78 lines
2 KiB
TypeScript
78 lines
2 KiB
TypeScript
import { getAPIUrl } from '@services/config/config'
|
|
import {
|
|
RequestBodyWithAuthHeader,
|
|
getResponseMetadata,
|
|
} from '@services/utils/ts/requests'
|
|
|
|
export async function createAssignment(body: any, access_token: string) {
|
|
const result: any = await fetch(
|
|
`${getAPIUrl()}assignments`,
|
|
RequestBodyWithAuthHeader('POST', body, null, access_token)
|
|
)
|
|
const res = await getResponseMetadata(result)
|
|
return res
|
|
}
|
|
|
|
export async function getAssignmentFromActivityUUID(
|
|
activityUUID: string,
|
|
access_token: string
|
|
) {
|
|
const result: any = await fetch(
|
|
`${getAPIUrl()}assignments/activity/${activityUUID}`,
|
|
RequestBodyWithAuthHeader('GET', null, null, access_token)
|
|
)
|
|
const res = await getResponseMetadata(result)
|
|
return res
|
|
}
|
|
|
|
// Delete an assignment
|
|
export async function deleteAssignment(
|
|
assignmentUUID: string,
|
|
access_token: string
|
|
) {
|
|
const result: any = await fetch(
|
|
`${getAPIUrl()}assignments/${assignmentUUID}`,
|
|
RequestBodyWithAuthHeader('DELETE', null, null, access_token)
|
|
)
|
|
const res = await getResponseMetadata(result)
|
|
return res
|
|
}
|
|
|
|
export async function deleteAssignmentUsingActivityUUID(
|
|
activityUUID: string,
|
|
access_token: string
|
|
) {
|
|
const result: any = await fetch(
|
|
`${getAPIUrl()}assignments/activity/${activityUUID}`,
|
|
RequestBodyWithAuthHeader('DELETE', null, null, access_token)
|
|
)
|
|
const res = await getResponseMetadata(result)
|
|
return res
|
|
}
|
|
|
|
// tasks
|
|
|
|
export async function createAssignmentTask(
|
|
body: any,
|
|
assignmentUUID: string,
|
|
access_token: string
|
|
) {
|
|
const result: any = await fetch(
|
|
`${getAPIUrl()}assignments/${assignmentUUID}/tasks`,
|
|
RequestBodyWithAuthHeader('POST', body, null, access_token)
|
|
)
|
|
const res = await getResponseMetadata(result)
|
|
return res
|
|
}
|
|
|
|
export async function getAssignmentTask(
|
|
assignmentTaskUUID: string,
|
|
access_token: string
|
|
) {
|
|
const result: any = await fetch(
|
|
`${getAPIUrl()}assignments/task/${assignmentTaskUUID}`,
|
|
RequestBodyWithAuthHeader('GET', null, null, access_token)
|
|
)
|
|
const res = await getResponseMetadata(result)
|
|
return res
|
|
}
|