Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 65 additions & 0 deletions src/embedded/classes/IterableEmbeddedMetadata.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/**

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error loading TSDoc config file:
Error encountered for /home/runner/work/react-native-sdk/tsdoc.json:
Unable to resolve "extends" reference to "typedoc/tsdoc.json": Cannot find module 'typedoc/tsdoc.json' from '/home/runner/work/react-native-sdk'
[eslint:tsdoc/syntax]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error loading TSDoc config file:
Error encountered for /home/runner/work/react-native-sdk/tsdoc.json:
Unable to resolve "extends" reference to "typedoc/tsdoc.json": Cannot find module 'typedoc/tsdoc.json' from '/home/runner/work/react-native-sdk'
[eslint:tsdoc/syntax]

* 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
Comment on lines +22 to +26

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function with many parameters (count = 4): constructor [qlty:function-parameters]

Comment on lines +22 to +26

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function with many parameters (count = 4): constructor [qlty:function-parameters]

) {
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;
}