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