feat: implement entity patch
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
@@ -25,6 +25,8 @@ import type {
|
||||
EntityListStreamRequest,
|
||||
EntityListBulkResponse,
|
||||
EntityListBulkRequest,
|
||||
EntityPatchResponse,
|
||||
EntityPatchRequest,
|
||||
} from '../types/entity';
|
||||
import { useIntegrationStore } from '@KTXC/stores/integrationStore';
|
||||
import { EntityObject } from '../models';
|
||||
@@ -150,6 +152,27 @@ export const entityService = {
|
||||
return createEntityObject(response);
|
||||
},
|
||||
|
||||
/**
|
||||
* Patch existing entities with new properties
|
||||
*
|
||||
* @param request - patch request parameters
|
||||
*
|
||||
* @returns Promise with patch results keyed by target entity identifier
|
||||
*/
|
||||
async patch(request: EntityPatchRequest): Promise<EntityPatchResponse> {
|
||||
const properties = {
|
||||
'@type': request.properties['@type'] ?? 'mail:message',
|
||||
...(Object.prototype.hasOwnProperty.call(request.properties, 'flags')
|
||||
? { flags: request.properties.flags }
|
||||
: {}),
|
||||
}
|
||||
|
||||
return await transceivePost<EntityPatchRequest, EntityPatchResponse>('entity.patch', {
|
||||
...request,
|
||||
properties,
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Delete entities by their identifiers
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user