import { AxiosInstance } from 'axios'; import { Methods, UserData } from '../types'; export class Session { api: AxiosInstance; constructor(api: AxiosInstance) { this.api = api; this.renew = this.renew.bind(this); this.del = this.del.bind(this); } async renew(): Promise { const { data } = await this.api.request<{ token: string; user: UserData }>({ url: '/sessions', method: Methods.PUT, }); const { user } = data; return user; } async del(): Promise { await this.api.request({ url: '/sessions', method: Methods.DELETE, }); } } export interface SessionRelations {} export type SessionWithRelations = Session & SessionRelations;