Skip to content

TaskView is a self-hosted project and task management platform focused on clarity, ownership, and control. TaskView is built for teams that want a transparent, self-hosted alternative to SaaS task managers.

1.0 KB
Raw Blame
import TvApiBase from './base';
import type { AppResponse } from '@/api/base.types';
import type {
    ApiTokenArgCreate,
    ApiTokenCreateResponse,
    ApiTokenItem,
    ApiTokenPermission,
} from './api-tokens.types';

export default class TvApiTokens extends TvApiBase {
    protected moduleUrl = '/module/api-tokens';

    public async fetch() {
        return this.request(
            this.$axios.get<AppResponse<ApiTokenItem[]>>(`${this.moduleUrl}`)
        );
    }

    public async create(data: ApiTokenArgCreate) {
        return this.request(
            this.$axios.post<AppResponse<ApiTokenCreateResponse>>(`${this.moduleUrl}`, data)
        );
    }

    public async delete(id: number) {
        return this.request(
            this.$axios.delete<AppResponse<boolean>>(`${this.moduleUrl}`, { data: { id } })
        );
    }

    public async fetchPermissions() {
        return this.request(
            this.$axios.get<AppResponse<ApiTokenPermission[]>>(`${this.moduleUrl}/permissions`)
        );
    }
}