|
| 1 | +import { IterableEmbeddedMessageElementsButtonAction } from './IterableEmbeddedMessageElementsButtonAction'; |
| 2 | + |
| 3 | +/** |
| 4 | + * IterableEmbeddedMessageElementsButton represents a button in an embedded message. |
| 5 | + */ |
| 6 | +export class IterableEmbeddedMessageElementsButton { |
| 7 | + /** The ID for the embedded message button */ |
| 8 | + readonly id: string; |
| 9 | + /** The title for the embedded message button */ |
| 10 | + readonly title?: string; |
| 11 | + /** The action for the embedded message button */ |
| 12 | + readonly action?: IterableEmbeddedMessageElementsButtonAction; |
| 13 | + |
| 14 | + /** |
| 15 | + * Creates an instance of IterableEmbeddedMessageButton. |
| 16 | + * |
| 17 | + * @param id - The ID for the embedded message button. |
| 18 | + * @param title - The title for the embedded message button. |
| 19 | + * @param action - The action for the embedded message button. |
| 20 | + */ |
| 21 | + constructor( |
| 22 | + id: string, |
| 23 | + title?: string, |
| 24 | + action?: IterableEmbeddedMessageElementsButtonAction |
| 25 | + ) { |
| 26 | + this.id = id; |
| 27 | + this.title = title; |
| 28 | + this.action = action; |
| 29 | + } |
| 30 | + |
| 31 | + /** |
| 32 | + * Creates an instance of `IterableEmbeddedMessageButton` from a dictionary object. |
| 33 | + * |
| 34 | + * @param dict - The dictionary object containing the properties to initialize the `IterableEmbeddedMessageButton` instance. |
| 35 | + * @returns A new instance of `IterableEmbeddedMessageButton` initialized with the provided dictionary properties. |
| 36 | + */ |
| 37 | + static fromDict( |
| 38 | + dict: Partial<EmbeddedMessageElementsButtonDict> |
| 39 | + ): IterableEmbeddedMessageElementsButton { |
| 40 | + if (!dict.id) { |
| 41 | + throw new Error('id is required'); |
| 42 | + } |
| 43 | + const action = dict.action |
| 44 | + ? IterableEmbeddedMessageElementsButtonAction.fromDict(dict.action) |
| 45 | + : undefined; |
| 46 | + return new IterableEmbeddedMessageElementsButton( |
| 47 | + dict.id, |
| 48 | + dict.title, |
| 49 | + action |
| 50 | + ); |
| 51 | + } |
| 52 | +} |
| 53 | + |
| 54 | +/** |
| 55 | + * An interface defining the dictionary object containing the properties for the embedded message button. |
| 56 | + */ |
| 57 | +export interface EmbeddedMessageElementsButtonDict { |
| 58 | + id: string; |
| 59 | + title?: string; |
| 60 | + action?: IterableEmbeddedMessageElementsButtonAction; |
| 61 | +} |
0 commit comments