[MOB-11549] creates IterableEmbeddedMessageMetadata class#654
Conversation
❌ 2 blocking issues (3 total)
This is from Qlty Cloud, the successor to Code Climate Quality. Learn more. |
| @@ -0,0 +1,58 @@ | |||
| import { IterableEmbeddedMessageMetadata } from '../embedded/classes/IterableEmbeddedMessageMetadata'; | |||
There was a problem hiding this comment.
| @@ -0,0 +1,65 @@ | |||
| /** | |||
There was a problem hiding this comment.
| constructor( | ||
| messageId: string, | ||
| placementId: number, | ||
| campaignId: number | undefined, | ||
| isProof: boolean = false |
lposen
left a comment
There was a problem hiding this comment.
Looks good. Please just address the commenting item.
| * An interface defining the dictionary object containing the metadata properties for an embedded message. | ||
| */ | ||
| export interface EmbeddedMessageMetadataDict { | ||
| messageId: string; |
There was a problem hiding this comment.
Please comment what each of the props are
| * | ||
| * @returns A new instance of `IterableEmbeddedMessageMetadata` with the provided properties. | ||
| */ | ||
| static fromDict( |
There was a problem hiding this comment.
Side rant:
Personally, I really don't like the fromDict functions. It's just not a typical javascript pattern, so my spidey sense goes off when I see it (though I can't exactly figure out why). To me, this should all just be handled in a constructor.
That being said, we use fromDict in so many places that we should follow the established pattern and keep it.
There was a problem hiding this comment.
Hm yeah maybe that can be a future improvement.
There was a problem hiding this comment.
export class IterableEmbeddedMessageMetadata {
readonly messageId: string;
readonly placementId: number;
readonly campaignId?: number;
readonly isProof: boolean;
constructor({
messageId,
placementId,
campaignId,
isProof = false
}: EmbeddedMessageMetadataDict) {
if (!messageId || !placementId) {
throw new Error('messageId and placementId are required');
}
this.messageId = messageId;
this.placementId = placementId;
this.campaignId = campaignId;
this.isProof = isProof;
}
}
// Usage:
new IterableEmbeddedMessageMetadata({
messageId: 'msg123',
placementId: 456,
campaignId: 789,
isProof: false
});
| @@ -0,0 +1,58 @@ | |||
| import { IterableEmbeddedMessageMetadata } from '../embedded/classes/IterableEmbeddedMessageMetadata'; | |||
There was a problem hiding this comment.
| @@ -0,0 +1,65 @@ | |||
| /** | |||
There was a problem hiding this comment.
| constructor( | ||
| messageId: string, | ||
| placementId: number, | ||
| campaignId: number | undefined, | ||
| isProof: boolean = false |
…edded-metadata-class
| @@ -0,0 +1,58 @@ | |||
| import { IterableEmbeddedMessageMetadata } from '../embedded/classes/IterableEmbeddedMessageMetadata'; | |||
There was a problem hiding this comment.
| @@ -0,0 +1,65 @@ | |||
| /** | |||
There was a problem hiding this comment.
| constructor( | ||
| messageId: string, | ||
| placementId: number, | ||
| campaignId: number | undefined, | ||
| isProof: boolean = false |
🔹 JIRA Ticket(s) if any
✏️ Description