-
Notifications
You must be signed in to change notification settings - Fork 57
/
Copy pathdelete-request-builder.ts
45 lines (43 loc) · 1.35 KB
/
delete-request-builder.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import {
Constructable,
DeleteRequestBuilderBase,
EntityIdentifiable,
FieldType
} from '../../odata-common';
import { EntityV4 } from '../entity';
import { oDataUriV4 } from '../uri-conversion';
/**
* Create OData query to delete an entity.
*
* @typeparam EntityT - Type of the entity to be deleted
*/
export class DeleteRequestBuilderV4<EntityT extends EntityV4>
extends DeleteRequestBuilderBase<EntityT>
implements EntityIdentifiable<EntityT> {
readonly _entityConstructor: Constructable<EntityT>;
readonly _entity: EntityT;
/**
* Creates an instance of DeleteRequestBuilder. If the entity is passed, version identifier will also be added.
*
* @param entityConstructor - Constructor type of the entity to be deleted
* @param keysOrEntity - Entity or Key-value pairs of key properties for the given entity
*/
constructor(
entityConstructor: Constructable<EntityT>,
keysOrEntity: Record<string, FieldType> | EntityV4
) {
super(entityConstructor, oDataUriV4, keysOrEntity);
}
/**
* Add ETag version identifier in the delete request header.
*
* @param etag - The version identifier of the entity
* @returns The builder itself, to facilitate method chaining
*/
setVersionIdentifier(etag: string): this {
if (etag) {
this.requestConfig.addCustomHeaders({ 'if-match': etag });
}
return this;
}
}