mirror of
https://github.com/pocket-id/pocket-id.git
synced 2025-12-11 15:53:00 +03:00
22 lines
711 B
TypeScript
22 lines
711 B
TypeScript
import type { ApiKey, ApiKeyCreate, ApiKeyResponse } from '$lib/types/api-key.type';
|
|
import type { Paginated, SearchPaginationSortRequest } from '$lib/types/pagination.type';
|
|
import APIService from './api-service';
|
|
|
|
export default class ApiKeyService extends APIService {
|
|
async list(options?: SearchPaginationSortRequest) {
|
|
const res = await this.api.get('/api-keys', {
|
|
params: options
|
|
});
|
|
return res.data as Paginated<ApiKey>;
|
|
}
|
|
|
|
async create(data: ApiKeyCreate): Promise<ApiKeyResponse> {
|
|
const res = await this.api.post('/api-keys', data);
|
|
return res.data as ApiKeyResponse;
|
|
}
|
|
|
|
async revoke(id: string): Promise<void> {
|
|
await this.api.delete(`/api-keys/${id}`);
|
|
}
|
|
}
|