-
Notifications
You must be signed in to change notification settings - Fork 43
Expand file tree
/
Copy pathIterableEmbeddedMessageMetadata.ts
More file actions
65 lines (62 loc) · 1.96 KB
/
Copy pathIterableEmbeddedMessageMetadata.ts
File metadata and controls
65 lines (62 loc) · 1.96 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
53
54
55
56
57
58
59
60
61
62
63
64
65
/**
* Metadata for an embedded message.
*/
export class IterableEmbeddedMessageMetadata {
/** The ID for the embedded message */
readonly messageId: string;
/** The placement ID for the embedded message */
readonly placementId: number;
/** The campaign ID for the embedded message */
readonly campaignId?: number;
/** Whether the embedded message is a proof */
readonly isProof: boolean;
/**
* Constructs an instance of IterableEmbeddedMessageMetadata.
*
* @param messageId - The ID for the embedded message.
* @param placementId - The placement ID for the embedded message.
* @param campaignId - The campaign ID for the embedded message.
* @param isProof - Whether the embedded message is a proof.
*/
constructor(
messageId: string,
placementId: number,
campaignId: number | undefined,
isProof: boolean = false
) {
this.messageId = messageId;
this.placementId = placementId;
this.campaignId = campaignId;
this.isProof = isProof;
}
/**
* Creates an instance of `IterableEmbeddedMessageMetadata` from a dictionary object.
*
* @param dict - The dictionary objectcontaining the metadata properties.
* This corresponds to the properties in {@link IterableEmbeddedMessageMetadata}
*
* @returns A new instance of `IterableEmbeddedMessageMetadata` with the provided properties.
*/
static fromDict(
dict: Partial<EmbeddedMessageMetadataDict>
): IterableEmbeddedMessageMetadata {
if (!dict.messageId || !dict.placementId) {
throw new Error('messageId and placementId are required');
}
return new IterableEmbeddedMessageMetadata(
dict.messageId,
dict.placementId,
dict.campaignId,
dict.isProof
);
}
}
/**
* An interface defining the dictionary object containing the metadata properties for an embedded message.
*/
export interface EmbeddedMessageMetadataDict {
messageId: string;
placementId: number;
campaignId?: number;
isProof?: boolean;
}