refactor: use resource identifiers
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
@@ -72,9 +72,16 @@ export const collectionService = {
|
||||
*
|
||||
* @returns Promise with collection object
|
||||
*/
|
||||
async fetch(request: CollectionFetchRequest): Promise<CollectionObject> {
|
||||
async fetch(request: CollectionFetchRequest): Promise<Record<string, CollectionObject>> {
|
||||
const response = await transceivePost<CollectionFetchRequest, CollectionFetchResponse>('collection.fetch', request);
|
||||
return createCollectionObject(response);
|
||||
|
||||
// Convert response to CollectionObject instances
|
||||
const list: Record<string, CollectionObject> = {};
|
||||
Object.entries(response).forEach(([identifier, entity]) => {
|
||||
list[entity.identifier] = createCollectionObject(entity);
|
||||
});
|
||||
|
||||
return list;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -128,8 +135,8 @@ export const collectionService = {
|
||||
async delete(request: CollectionDeleteRequest): Promise<boolean | CollectionObject> {
|
||||
const response = await transceivePost<CollectionDeleteRequest, CollectionDeleteResponse>('collection.delete', request);
|
||||
|
||||
if (response.outcome === 'moved' && response.data) {
|
||||
return createCollectionObject(response.data);
|
||||
if (response.disposition === 'moved' && response.mutation) {
|
||||
return createCollectionObject(response.mutation);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user