-
Notifications
You must be signed in to change notification settings - Fork 43
Expand file tree
/
Copy pathIterableEmbeddedPlacement.ts
More file actions
52 lines (47 loc) · 1.7 KB
/
Copy pathIterableEmbeddedPlacement.ts
File metadata and controls
52 lines (47 loc) · 1.7 KB
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
48
49
50
51
52
import { IterableEmbeddedMessage } from './IterableEmbeddedMessage';
/**
* IterableEmbeddedPlacement represents an embedded placement.
*/
export class IterableEmbeddedPlacement {
/** The placement id of the embedded placement */
readonly placementId: number;
/** The messages associated with the embedded placement */
readonly messages?: IterableEmbeddedMessage[];
/**
* Creates an instance of `IterableEmbeddedPlacement`.
*
* @param placementId - The placement id of the embedded placement.
* @param messages - The messages associated with the embedded placement.
*/
constructor(placementId: number, messages?: IterableEmbeddedMessage[]) {
this.placementId = placementId;
this.messages = messages;
}
/**
* Creates an instance of `IterableEmbeddedPlacement` from a dictionary object.
*
* @param dict - The dictionary object containing the properties to initialize the `IterableEmbeddedPlacement` instance.
* @returns A new instance of `IterableEmbeddedPlacement` initialized with the provided dictionary properties.
*/
static fromDict(
dict: Partial<EmbeddedPlacementDict>
): IterableEmbeddedPlacement {
if (!dict.placementId) {
throw new Error('placementId is required');
}
const placementId = dict.placementId;
const messages = dict.messages
? dict.messages?.map((message) =>
IterableEmbeddedMessage.fromDict(message)
)
: undefined;
return new IterableEmbeddedPlacement(placementId, messages);
}
}
/**
* An interface defining the dictionary object containing the properties for the embedded placement.
*/
export interface EmbeddedPlacementDict {
placementId: number;
messages?: IterableEmbeddedMessage[];
}