import Api from '@/services/Api'

export default {
    listApps (params) {
        return Api().get('/v1/app')
    },
    getAppImage(id) {
        return process.env.VUE_APP_API_URL+"gui/apps/"+id+"/icon";
    },
    getApp(id) {
        return Api().get('/v1/app/'+id)
    },
    getAppByKey(key) {
        return Api().get("/v1/app/find?apiKey="+key);
    },
    getStartPageApps() {
        return Api().get("/v1/app/find?webpage=1");
    },
    getAccess(id) {
        return Api().get('/v1/app/'+id+'/access?create=1')
    },
    allowAccess(id, redirect_uri, scope, state) {
        return Api().post('/v1/app/'+id+'/access/allow', {redirect_uri: redirect_uri, scope:scope, state:state});
    },
    updateApp(app) {
        return Api().put("/v1/app/"+app.id, app);
    },
    getUser(id) {
        return Api().get('/v1/app/'+id+'/user')
    },
    newApp(name, description, url) {
        return Api().post('/v1/app', {name: name, description: description, url: url});
    },
    getAccessList() {
        return Api().get('/v1/access')
    },
    removeAccess(accessId) {
        return Api().delete('/v1/access/'+accessId)
    }
}
