-
Notifications
You must be signed in to change notification settings - Fork 36
[MOB-11551] creates IterableEmbeddedMessageElements class #656
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
[MOB-11551] creates IterableEmbeddedMessageElements class #656
Conversation
❌ 7 blocking issues (10 total)
This is from Qlty Cloud, the successor to Code Climate Quality. Learn more. |
/** | ||
* IterableEmbeddedMessageText represents a text element in an embedded message. | ||
*/ | ||
export class IterableEmbeddedMessageText { |
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.
I feel like a lot of these don't necessarily need to be classes, and that they could just be interfaces. But I'll have to double check how they all fit together.
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.
Please update the comments
…le-embedded-message-elements-class
@@ -0,0 +1,40 @@ | |||
import { IterableEmbeddedMessageDefaultAction } from '../embedded/classes/IterableEmbeddedMessageDefaultAction'; |
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.
@@ -0,0 +1,214 @@ | |||
import { IterableEmbeddedMessageElements } from '../embedded/classes/IterableEmbeddedMessageElements'; |
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.
@@ -0,0 +1,38 @@ | |||
import { IterableEmbeddedMessageText } from '../embedded/classes/IterableEmbeddedMessageText'; |
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.
@@ -0,0 +1,51 @@ | |||
/** |
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.
export class IterableEmbeddedMessageDefaultAction { | ||
/** | ||
* The type of iterable action | ||
* For custom actions, the type is `action://` prefix followed by a custom action name | ||
*/ | ||
readonly type: string; | ||
|
||
/** | ||
* The url for the action when the type is `openUrl` | ||
* For custom actions, data is empty | ||
*/ | ||
readonly data?: string; | ||
|
||
/** | ||
* Creates an instance of `IterableEmbeddedMessageDefaultAction`. | ||
* | ||
* @param type - The type of iterable action | ||
* @param data - The url for the action when the type is `openUrl` | ||
*/ | ||
constructor(type: string, data?: string) { | ||
this.type = type; | ||
this.data = data; | ||
} | ||
|
||
/** | ||
* Creates an instance of `IterableEmbeddedMessageDefaultAction` from a dictionary object. | ||
* | ||
* @param dict - The dictionary object containing the properties to initialize the `IterableEmbeddedMessageDefaultAction` instance. | ||
* @returns A new instance of `IterableEmbeddedMessageDefaultAction` initialized with the provided dictionary properties. | ||
*/ | ||
static fromDict( | ||
dict: Partial<EmbeddedMessageDefaultActionDict> | ||
): IterableEmbeddedMessageDefaultAction { | ||
if (!dict.type) { | ||
throw new Error('type is required'); | ||
} | ||
return new IterableEmbeddedMessageDefaultAction(dict.type, dict.data); | ||
} |
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.
@@ -0,0 +1,101 @@ | |||
import { IterableEmbeddedMessageDefaultAction } from './IterableEmbeddedMessageDefaultAction'; |
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.
constructor( | ||
title?: string, | ||
body?: string, | ||
mediaUrl?: string, | ||
mediaUrlCaption?: string, | ||
defaultAction?: IterableEmbeddedMessageDefaultAction, | ||
buttons?: IterableEmbeddedMessageElementsButton[], | ||
text?: IterableEmbeddedMessageText[] |
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.
IterableEmbeddedMessageElementsButton.fromDict(button) | ||
); | ||
|
||
const text = dict.text?.map((text) => |
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.
@@ -0,0 +1,48 @@ | |||
/** |
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.
🔹 JIRA Ticket(s) if any
✏️ Description