-
Notifications
You must be signed in to change notification settings - Fork 36
[MOB-11549] creates IterableEmbeddedMessageMetadata class #654
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-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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -0,0 +1,65 @@ | |||
/** |
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( | ||
messageId: string, | ||
placementId: number, | ||
campaignId: number | undefined, | ||
isProof: boolean = false |
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.
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm yeah maybe that can be a future improvement.
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 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -0,0 +1,65 @@ | |||
/** |
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( | ||
messageId: string, | ||
placementId: number, | ||
campaignId: number | undefined, | ||
isProof: boolean = false |
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.
…edded-metadata-class
@@ -0,0 +1,58 @@ | |||
import { IterableEmbeddedMessageMetadata } from '../embedded/classes/IterableEmbeddedMessageMetadata'; |
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,65 @@ | |||
/** |
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( | ||
messageId: string, | ||
placementId: number, | ||
campaignId: number | undefined, | ||
isProof: boolean = false |
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