import axios from "axios"; export default class PlayerApi { store = { permition: null, steam_data: null, ban: null } discord = null; auth(value) { switch (value) { case "steam": return document.cookie.indexOf("steam64_secured=") !== -1 && document.cookie.indexOf("steam64=") !== -1 case "discord": return document.cookie.indexOf("discord") !== -1 default: return this.auth('steam') && this.auth('discord'); } } async loadFull() { return axios.get(`/api/profile/current`) .then(response => { if (response.status === 200) this.store = response.data; }) .catch(() => { this.store = null; }); } async loadThis(value) { return axios.get(`/api/profile/current?requests=${value}`) .then(response => { if (response.status === 200) this.store[value] = response.data[value]; }) .catch(() => { this.store[value] = null; }); } async loadDiscord() { return axios.get(`https://tf2.pblr-nyk.pro/api/auth/discord`) .then(response => { if (response.status === 200) this.discord = response.data; }) .catch(() => { this.discord = null; }); } async load(stages) { console.log(`[PlayerAPI] request info`); stages.add("profile"); if (this.auth('steam')) await this.loadFull(); if (this.auth('discord')) await this.loadDiscord(); stages.remove("profile"); } }