39 lines
864 B
TypeScript
39 lines
864 B
TypeScript
import type { $Fetch } from 'ofetch';
|
|
import type { List, WPListEncrypted } from '~/types/lists'
|
|
|
|
export default class ListRepository {
|
|
private fetcher: $Fetch;
|
|
|
|
constructor(fetcher: $Fetch) {
|
|
this.fetcher = fetcher;
|
|
}
|
|
|
|
async getAll() {
|
|
return await this.fetcher<List[]>('/lists');
|
|
}
|
|
|
|
async create(data: Partial<List>) {
|
|
return await this.fetcher<List>('/lists', {
|
|
method: 'POST',
|
|
body: data
|
|
});
|
|
}
|
|
|
|
async uploadKeys(data: string) {
|
|
console.log('uploadEncryptedPrivateKey : data is')
|
|
console.log(data)
|
|
|
|
return await this.fetcher<any>('/lists/PrivKeyCipher', {
|
|
method: 'POST',
|
|
body: data
|
|
})
|
|
}
|
|
|
|
async update(data: WPListEncrypted) {
|
|
const string = JSON.stringify(data);
|
|
return await this.fetcher<any>('/lists/' + data.id, {
|
|
method: 'PUT',
|
|
body: string
|
|
})
|
|
}
|
|
} |