Merge pull request #17583 from edx/MLoTurco/learner-3925-feature-client-api
Add Client API Learner-3925 Learner-4388
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
import 'whatwg-fetch';
|
||||
import Cookies from 'js-cookie';
|
||||
|
||||
import { entitlementApi } from './endpoints';
|
||||
|
||||
const HEADERS = {
|
||||
Accept: 'application/json',
|
||||
'Content-Type': 'application/json',
|
||||
'X-CSRFToken': Cookies.get('csrftoken'),
|
||||
};
|
||||
|
||||
const requestEntitlements = ({ username }) => fetch(
|
||||
`${entitlementApi}/?user=${username}`, {
|
||||
credentials: 'same-origin',
|
||||
method: 'get',
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
const createEntitlement = ({ username, courseUuid, mode, action, comments }) => fetch(
|
||||
`${entitlementApi}`, {
|
||||
credentials: 'same-origin',
|
||||
method: 'post',
|
||||
headers: HEADERS,
|
||||
body: JSON.stringify({
|
||||
course_uuid: courseUuid,
|
||||
user: username,
|
||||
mode,
|
||||
support_details: [{
|
||||
action,
|
||||
comments,
|
||||
}],
|
||||
}),
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
const updateEntitlement = ({ entitlementUuid, unenrolledRun, action, comments }) => fetch(
|
||||
`${entitlementApi}/${entitlementUuid}`, {
|
||||
credentials: 'same-origin',
|
||||
method: 'patch',
|
||||
headers: HEADERS,
|
||||
body: JSON.stringify({
|
||||
expired_at: null,
|
||||
enrollment_run: null,
|
||||
support_details: [{
|
||||
unenrolled_run: unenrolledRun,
|
||||
action,
|
||||
comments,
|
||||
}],
|
||||
}),
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
export {
|
||||
requestEntitlements,
|
||||
createEntitlement,
|
||||
updateEntitlement,
|
||||
};
|
||||
@@ -0,0 +1,5 @@
|
||||
const entitlementApi = '/api/entitlements/v1/entitlements';
|
||||
|
||||
export {
|
||||
entitlementApi,
|
||||
};
|
||||
@@ -32,6 +32,7 @@
|
||||
"jquery": "2.2.4",
|
||||
"jquery-migrate": "1.4.1",
|
||||
"jquery.scrollto": "2.1.2",
|
||||
"js-cookie": "2.2.0",
|
||||
"moment": "2.18.1",
|
||||
"moment-timezone": "0.5.14",
|
||||
"node-sass": "4.7.2",
|
||||
@@ -53,6 +54,7 @@
|
||||
"webpack": "2.7.0",
|
||||
"webpack-bundle-tracker": "0.2.1",
|
||||
"webpack-merge": "4.1.1",
|
||||
"whatwg-fetch": "2.0.3",
|
||||
"which-country": "1.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
Reference in New Issue
Block a user