-
Notifications
You must be signed in to change notification settings - Fork 43
[MOB-7936] create IterableEmbeddedPlacement class #644
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| import { IterableEmbeddedMessageMetadata } from './IterableEmbeddedMessageMetadata'; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| import { IterableEmbeddedMessageElements } from './IterableEmbeddedMessageElements'; | ||
|
|
||
| /** | ||
| * IterableEmbeddedMessage represents an embedded message. | ||
| */ | ||
| export class IterableEmbeddedMessage { | ||
| /** The metadata of the embedded message */ | ||
| metadata: IterableEmbeddedMessageMetadata; | ||
| /** The elements of the embedded message */ | ||
| elements?: IterableEmbeddedMessageElements; | ||
| /** The custom payload of the embedded message */ | ||
| payload?: Record<string, unknown>; | ||
|
|
||
| /** | ||
| * Creates an instance of `IterableEmbeddedMessage`. | ||
| * | ||
| * @param metadata - The metadata of the embedded message. | ||
| * @param elements - The elements of the embedded message. | ||
| * @param payload - The custom payload of the embedded message. | ||
| */ | ||
| constructor( | ||
| metadata: IterableEmbeddedMessageMetadata, | ||
| elements?: IterableEmbeddedMessageElements, | ||
| payload?: Record<string, unknown> | ||
| ) { | ||
| this.metadata = metadata; | ||
| this.elements = elements; | ||
| this.payload = payload; | ||
| } | ||
|
|
||
| /** | ||
| * Creates an instance of `IterableEmbeddedMessage` from a dictionary object. | ||
| * | ||
| * @param dict - The dictionary object containing the properties to initialize the `IterableEmbeddedMessage` instance. | ||
| * @returns A new instance of `IterableEmbeddedMessage` initialized with the provided dictionary properties. | ||
| */ | ||
| static fromDict(dict: Partial<EmbeddedMessageDict>): IterableEmbeddedMessage { | ||
| if (!dict.metadata) { | ||
| throw new Error('metadata is required'); | ||
| } | ||
| const metadata = IterableEmbeddedMessageMetadata.fromDict(dict.metadata); | ||
| const elements = dict.elements | ||
| ? IterableEmbeddedMessageElements.fromDict(dict.elements) | ||
| : undefined; | ||
| const payload = dict.payload; | ||
| return new IterableEmbeddedMessage(metadata, elements, payload); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * An interface defining the dictionary object containing the properties for the embedded message. | ||
| */ | ||
| interface EmbeddedMessageDict { | ||
| metadata: IterableEmbeddedMessageMetadata; | ||
| elements: IterableEmbeddedMessageElements; | ||
| payload: Record<string, unknown>; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,52 @@ | ||
| import { IterableEmbeddedMessage } from './IterableEmbeddedMessage'; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
|
||
| /** | ||
| * Iterable embedded placement | ||
| * Contains placement id and the associated embedded messages | ||
| * 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[]; | ||
|
|
||
| constructor(placementId: number) { | ||
| /** | ||
| * 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[]; | ||
| } | ||
There was a problem hiding this comment.
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]