-
Notifications
You must be signed in to change notification settings - Fork 57
/
Copy pathodata-batch-request-config.ts
47 lines (40 loc) · 1.27 KB
/
odata-batch-request-config.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
46
47
import { v4 as uuid } from 'uuid';
import { BatchSubRequestPathType } from '../request-builder/batch/batch-request-options';
import { ODataRequestConfig } from './odata-request-config';
export class ODataBatchRequestConfig extends ODataRequestConfig {
/**
* @deprecated Since v1.30.0.
*/
static readonly content_type_prefix = 'multipart/mixed; boundary=batch_';
subRequestPathType: BatchSubRequestPathType = 'relativeToService';
/**
* @deprecated Since v1.30.0. Use [[boundary]] instead.
*/
get batchId() {
return this.boundary;
}
/**
* Creates an instance of ODataBatchRequestConfig.
*
* @param defaultServicePath The default OData service path
* @param boundary Request boundary for separation of subrequests. Defaults to an autogenerated value.
*/
constructor(
readonly defaultServicePath: string,
readonly boundary = `batch_${uuid()}`
) {
super('post', defaultServicePath, {
'content-type': `multipart/mixed; boundary=${boundary}`,
accept: 'multipart/mixed'
});
}
withSubRequestPathType(subRequestPathType: BatchSubRequestPathType) {
this.subRequestPathType = subRequestPathType;
}
resourcePath(): string {
return '$batch';
}
queryParameters(): Record<string, any> {
return {};
}
}