mirror of
https://github.com/rzmk/learnhouse.git
synced 2025-12-19 04:19:25 +00:00
65 lines
No EOL
2.2 KiB
TypeScript
65 lines
No EOL
2.2 KiB
TypeScript
import { getAPIUrl } from '@services/config/config';
|
|
import { RequestBodyWithAuthHeader, errorHandling } from '@services/utils/ts/requests';
|
|
|
|
export async function getPaymentConfigs(orgId: number, access_token: string) {
|
|
const result = await fetch(
|
|
`${getAPIUrl()}payments/${orgId}/config`,
|
|
RequestBodyWithAuthHeader('GET', null, null, access_token)
|
|
);
|
|
const res = await errorHandling(result);
|
|
return res;
|
|
}
|
|
|
|
export async function checkPaidAccess(courseId: number, orgId: number, access_token: string) {
|
|
const result = await fetch(
|
|
`${getAPIUrl()}payments/${orgId}/courses/${courseId}/access`,
|
|
RequestBodyWithAuthHeader('GET', null, null, access_token)
|
|
);
|
|
const res = await errorHandling(result);
|
|
return res;
|
|
}
|
|
|
|
export async function createPaymentConfig(orgId: number, data: any, access_token: string) {
|
|
const result = await fetch(
|
|
`${getAPIUrl()}payments/${orgId}/config`,
|
|
RequestBodyWithAuthHeader('POST', data, null, access_token)
|
|
);
|
|
const res = await errorHandling(result);
|
|
return res;
|
|
}
|
|
|
|
export async function updatePaymentConfig(orgId: number, id: string, data: any, access_token: string) {
|
|
const result = await fetch(
|
|
`${getAPIUrl()}payments/${orgId}/config?id=${id}`,
|
|
RequestBodyWithAuthHeader('PUT', data, null, access_token)
|
|
);
|
|
const res = await errorHandling(result);
|
|
return res;
|
|
}
|
|
|
|
export async function deletePaymentConfig(orgId: number, id: string, access_token: string) {
|
|
const result = await fetch(
|
|
`${getAPIUrl()}payments/${orgId}/config?id=${id}`,
|
|
RequestBodyWithAuthHeader('DELETE', null, null, access_token)
|
|
);
|
|
const res = await errorHandling(result);
|
|
return res;
|
|
}
|
|
|
|
export async function getOrgCustomers(orgId: number, access_token: string) {
|
|
const result = await fetch(
|
|
`${getAPIUrl()}payments/${orgId}/customers`,
|
|
RequestBodyWithAuthHeader('GET', null, null, access_token)
|
|
);
|
|
const res = await errorHandling(result);
|
|
return res;
|
|
}
|
|
|
|
export async function getOwnedCourses(orgId: number, access_token: string) {
|
|
const result = await fetch(
|
|
`${getAPIUrl()}payments/${orgId}/courses/owned`,
|
|
RequestBodyWithAuthHeader('GET', null, null, access_token)
|
|
);
|
|
const res = await errorHandling(result);
|
|
return res;
|
|
} |