import Api from '@/services/Api'
import axios from 'axios'

export default {
    getPublicSettings (params) {
        return Api().get('/v1/server/settings')
    },
    getAllSettings () {
        return Api().get('/v1/server/settings?all=1')
    },
    getStatus () {
        return Api().get("/v1/status/check")
    },
    getAPIUrl () {
        return new Promise((resolve, reject) => {
            if(localStorage.getItem("apiURL")) {
                resolve();
            }
            axios.get('/apiurl')
                .then(function (response) {
                    // handle success
                    console.log(response.data.trim())
                    localStorage.setItem("apiURL", response.data.trim()+`api/`)
                    resolve();
                })
                .catch(function (error) {
                    if(error.response.status) {
                        localStorage.setItem("apiURL", process.env.VUE_APP_API_URL+`api/`)
                        resolve();
                    }
                });
        })

    }
}
