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('/lists'); } async create(data: Partial) { return await this.fetcher('/lists', { method: 'POST', body: data }); } async uploadKeys(data: string) { console.log('uploadEncryptedPrivateKey : data is') console.log(data) return await this.fetcher('/lists/PrivKeyCipher', { method: 'POST', body: data }) } async update(data: WPListEncrypted) { const string = JSON.stringify(data); return await this.fetcher('/lists/' + data.id, { method: 'PUT', body: string }) } }