import axios from 'axios'; import UserStore from './UserStore'; export default class Apiclient { static async getStats() { return ( await axios.get('https://kauft.es/api/stats', { headers: { Authorization: `Bearer ${UserStore.state.token}` } }) ).data; } static async getUrls() { return ( await axios.get('https://kauft.es/api?showVisits=true', { headers: { Authorization: `Bearer ${UserStore.state.token}` } }) ).data; } static async getUrlDetails(shortcode) { return ( await axios.get(`https://kauft.es/api/${shortcode}`, { headers: { Authorization: `Bearer ${UserStore.state.token}` } }) ).data; } static async getUrlVisits(shortcode) { return ( await axios.get(`https://kauft.es/api/${shortcode}/visits`, { headers: { Authorization: `Bearer ${UserStore.state.token}` } }) ).data; } static async deleteUrl(shortcode) { return ( await axios.delete(`https://kauft.es/api/${shortcode}`, { headers: { Authorization: `Bearer ${UserStore.state.token}` } }) ).status; } static async login(username, password) { return ( await axios.post(`https://kauft.es/api/auth/login`, {}, { auth: { username, password } }) ).data; } }