Skip to content
Commits on Source (11)
{
"name": "@coscine/api-connection",
"version": "1.21.0",
"version": "1.22.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
......
{
"name": "@coscine/api-connection",
"version": "1.22.0",
"version": "1.23.0",
"description": "This library provides methods to connect to CoScInE Apis with JavaScript.",
"keywords": [
"coscine",
......
export { ActivatedFeaturesApi } from './requests/activatedFeatures-api';
export { AdminApi } from './requests/admin-api';
export { BlobApi } from './requests/blob-api';
export { DisciplineApi } from './requests/discipline-api';
export { LanguageApi } from './requests/language-api';
......@@ -19,3 +20,4 @@ export { TOSApi } from './requests/tos-api';
export { TreeApi } from './requests/tree-api';
export { UserApi } from './requests/user-api';
export { VisibilityApi } from './requests/visibility-api';
export { TokenApi } from './requests/token-api';
......@@ -16,6 +16,9 @@ axios.interceptors.response.use(function (response: any) {
}
return response;
}, function (error: any) {
if ((typeof coscine !== "undefined") && (typeof coscine.loading !== "undefined") && (typeof coscine.loading.counter !== "undefined")) {
coscine.loading.counter--;
}
return Promise.reject(error);
});
export default {
......
const axios = require('axios');
import apiConnectionBasic from '../basic/api-connection-basic';
function getAdminApiUrl() {
return 'https://' + apiConnectionBasic.getHostName() + '/coscine/api/Coscine.Api.Admin/Admin/';
}
export class AdminApi {
public static GetProject(
projectString: String,
thenHandler: any = apiConnectionBasic.defaultThenHandler,
catchHandler: any = apiConnectionBasic.defaultOnCatch
) {
apiConnectionBasic.setHeader();
return axios
.get(getAdminApiUrl() + projectString)
.then(thenHandler)
.catch(catchHandler);
}
public static UpdateQuota(
body: any,
thenHandler: any = apiConnectionBasic.defaultThenHandler,
catchHandler: any = apiConnectionBasic.defaultOnCatch
) {
apiConnectionBasic.setHeader();
return axios
.post(getAdminApiUrl(), body)
.then(thenHandler)
.catch(catchHandler);
}
}
const axios = require('axios');
import apiConnectionBasic from '../basic/api-connection-basic';
function getTokenApiUrl() {
return 'https://' + apiConnectionBasic.getHostName() + '/coscine/api/Coscine.Api.Token/Token/';
}
export class TokenApi {
public static GetUserTokens(
thenHandler: any = apiConnectionBasic.defaultThenHandler,
catchHandler: any = apiConnectionBasic.defaultOnCatch
) {
apiConnectionBasic.setHeader();
return axios
.get(getTokenApiUrl())
.then(thenHandler)
.catch(catchHandler);
}
public static AddToken(
body: any,
thenHandler: any = apiConnectionBasic.defaultThenHandler,
catchHandler: any = apiConnectionBasic.defaultOnCatch
) {
apiConnectionBasic.setHeader();
return axios
.put(getTokenApiUrl(), body)
.then(thenHandler)
.catch(catchHandler);
}
public static RevokeToken(
tokenId: string,
thenHandler: any = apiConnectionBasic.defaultThenHandler,
catchHandler: any = apiConnectionBasic.defaultOnCatch
) {
apiConnectionBasic.setHeader();
return axios
.delete(getTokenApiUrl() + tokenId)
.then(thenHandler)
.catch(catchHandler);
}
public static GetUserToken(
tokenId: string,
thenHandler: any = apiConnectionBasic.defaultThenHandler,
catchHandler: any = apiConnectionBasic.defaultOnCatch,
) {
apiConnectionBasic.setHeader();
return axios
.get(getTokenApiUrl() + tokenId)
.then(thenHandler)
.catch(catchHandler);
}
}