-
Notifications
You must be signed in to change notification settings - Fork 36
[MOB-11649] updated embedded message class #670
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
base: evan/feature/embedded
Are you sure you want to change the base?
Conversation
…le-embedded-message-button-class
…d-message-button-class [MOB-11550] creates iterableEmbeddedMessageButton class
…le-embedded-message-button-class
…d-message-button-class [MOB-XXXX] adds labels for dict
…le-embedded-message-elements-class
…d-message-elements-class [MOB-11551] creates IterableEmbeddedMessageElements class
…e-embedded-message-class
…-message-class [MOB-7936] creates IterableEmbeddedMessage class
❌ 6 blocking issues (7 total)
This is from Qlty Cloud, the successor to Code Climate Quality. Learn more. |
@@ -1,5 +1,4 @@ | |||
import { IterableEmbeddedMessageElementsButton } from '../embedded/classes/IterableEmbeddedMessageElementsButton'; |
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.
const buttons = dict.buttons?.map((button) => | ||
IterableEmbeddedMessageElementsButton.fromDict(button) | ||
const buttons = dict.buttons?.map( | ||
(button) => new IterableEmbeddedMessageElementsButton(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.
@@ -1,5 +1,3 @@ | |||
import { IterableEmbeddedMessageElementsButtonAction } from './IterableEmbeddedMessageElementsButtonAction'; | |||
|
|||
/** |
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.
const text = dict.text?.map((text) => | ||
IterableEmbeddedMessageText.fromDict(text) | ||
const text = dict.text?.map( | ||
(text) => new IterableEmbeddedMessageText(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.
@@ -52,7 +52,8 @@ describe('IterableEmbeddedMessage', () => { | |||
}; | |||
|
|||
expect(() => { | |||
IterableEmbeddedMessageMetadata.fromDict(dict); | |||
// @ts-expect-error - messageId is purposely missing | |||
new IterableEmbeddedMessageMetadata(dict); |
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,86 @@ | |||
import { IterableEmbeddedMessageButton } from '../embedded/classes/IterableEmbeddedMessageButton'; |
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,131 @@ | |||
import { IterableEmbeddedMessageButton } from './IterableEmbeddedMessageButton'; |
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(dict: EmbeddedMessageDict) { | ||
if (!dict.metadata) { | ||
throw new Error('metadata is required'); | ||
} | ||
this.metadata = { | ||
messageId: dict.metadata.messageId, | ||
placementId: dict.metadata.placementId, | ||
campaignId: dict.metadata.campaignId, | ||
isProof: dict.metadata.isProof, | ||
}; | ||
|
||
if (dict.elements) { | ||
this.elements = { | ||
title: dict.elements?.title, | ||
body: dict.elements?.body, | ||
mediaUrl: dict.elements?.mediaUrl, | ||
mediaUrlCaption: dict.elements?.mediaUrlCaption, | ||
}; | ||
|
||
if (dict.elements?.defaultAction) { | ||
this.elements.defaultAction = { | ||
type: dict.elements.defaultAction.type, | ||
data: dict.elements.defaultAction.data, | ||
}; | ||
} | ||
|
||
if (dict.elements?.buttons) { | ||
this.elements.buttons = dict.elements.buttons.map( | ||
(button) => new IterableEmbeddedMessageButton(button) | ||
); | ||
} | ||
|
||
if (dict.elements?.text) { | ||
this.elements.text = dict.elements.text.map( | ||
(text) => new IterableEmbeddedMessageText(text) | ||
); | ||
} | ||
} | ||
|
||
this.payload = dict.payload; |
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,54 @@ | |||
/** |
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,162 @@ | |||
import { IterableEmbeddedMessage } from '../embedded/classes/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.
@@ -0,0 +1,86 @@ | |||
import { IterableEmbeddedMessageButton } from '../embedded/classes/IterableEmbeddedMessageButton'; |
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,39 @@ | |||
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,131 @@ | |||
import { IterableEmbeddedMessageButton } from './IterableEmbeddedMessageButton'; |
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(dict: EmbeddedMessageDict) { | ||
if (!dict.metadata) { | ||
throw new Error('metadata is required'); | ||
} | ||
this.metadata = { | ||
messageId: dict.metadata.messageId, | ||
placementId: dict.metadata.placementId, | ||
campaignId: dict.metadata.campaignId, | ||
isProof: dict.metadata.isProof, | ||
}; | ||
|
||
if (dict.elements) { | ||
this.elements = { | ||
title: dict.elements?.title, | ||
body: dict.elements?.body, | ||
mediaUrl: dict.elements?.mediaUrl, | ||
mediaUrlCaption: dict.elements?.mediaUrlCaption, | ||
}; | ||
|
||
if (dict.elements?.defaultAction) { | ||
this.elements.defaultAction = { | ||
type: dict.elements.defaultAction.type, | ||
data: dict.elements.defaultAction.data, | ||
}; | ||
} | ||
|
||
if (dict.elements?.buttons) { | ||
this.elements.buttons = dict.elements.buttons.map( | ||
(button) => new IterableEmbeddedMessageButton(button) | ||
); | ||
} | ||
|
||
if (dict.elements?.text) { | ||
this.elements.text = dict.elements.text.map( | ||
(text) => new IterableEmbeddedMessageText(text) | ||
); | ||
} | ||
} | ||
|
||
this.payload = dict.payload; |
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,54 @@ | |||
/** |
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,40 @@ | |||
/** |
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