import { AxiosPromise, AxiosResponse } from 'axios' import { Component } from 'vue-property-decorator' import AxiosLoadable from '@/helpers/loadable/AxiosLoadable' import { unsafeAxiosMapper } from '@/helpers/unsafeAxiosMapper' import { Auth } from '@/types/App' import ConnectedService from './ConnectedService' @Component export default class AccountService extends ConnectedService { account = new AxiosLoadable() get connector() { return this.account } load() { this.account.load(this.catchEmit(this.getAccount(this.auth)), this.mapAccount) } mapAccount(res: AxiosResponse) { return unsafeAxiosMapper(res) } checkAuth(auth: Auth) { return this.getAccount(auth) } mapServiceName(res: AxiosResponse, newAuth: Auth) { return `${this.serviceName} ${this.mapAccount(res)}` } getAccount(auth: Auth): AxiosPromise { throw this.mustBeDefined; } }