Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
58 changes: 58 additions & 0 deletions src/embedded/classes/IterableEmbeddedMessage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import { IterableEmbeddedMessageMetadata } from './IterableEmbeddedMessageMetadata';

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]

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]

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>;
}
47 changes: 44 additions & 3 deletions src/embedded/classes/IterableEmbeddedPlacement.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,52 @@
import { IterableEmbeddedMessage } from './IterableEmbeddedMessage';

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]

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]


/**
* 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[];
}