Skip to content

Commit 1ce1e39

Browse files
author
Evan Greer
committed
feat: adds IterableEmbeddedMessageButton class
1 parent c30f78a commit 1ce1e39

2 files changed

Lines changed: 58 additions & 1 deletion

File tree

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,32 @@
1-
export class IterableEmbeddedMessageButton {}
1+
import { IterableEmbeddedMessageElementsButtonAction } from './IterableEmbeddedMessageElementsButtonAction';
2+
3+
export class IterableEmbeddedMessageButton {
4+
readonly id: string;
5+
readonly title?: string;
6+
readonly action?: IterableEmbeddedMessageElementsButtonAction;
7+
8+
constructor(
9+
id: string,
10+
title?: string,
11+
action?: IterableEmbeddedMessageElementsButtonAction
12+
) {
13+
this.id = id;
14+
this.title = title;
15+
this.action = action;
16+
}
17+
18+
static fromDict(
19+
dict: Partial<EmbeddedMessageButtonDict>
20+
): IterableEmbeddedMessageButton {
21+
if (!dict.id) {
22+
throw new Error('id is required');
23+
}
24+
return new IterableEmbeddedMessageButton(dict.id, dict.title, dict.action);
25+
}
26+
}
27+
28+
export interface EmbeddedMessageButtonDict {
29+
id: string;
30+
title?: string;
31+
action?: IterableEmbeddedMessageElementsButtonAction;
32+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
export class IterableEmbeddedMessageElementsButtonAction {
2+
readonly type: string;
3+
readonly data?: string;
4+
5+
constructor(type: string, data?: string) {
6+
this.type = type;
7+
this.data = data;
8+
}
9+
10+
static fromDict(
11+
dict: Partial<EmbeddedMessageButtonActionDict>
12+
): IterableEmbeddedMessageElementsButtonAction {
13+
if (!dict.type) {
14+
throw new Error('type is required');
15+
}
16+
return new IterableEmbeddedMessageElementsButtonAction(
17+
dict.type,
18+
dict.data
19+
);
20+
}
21+
}
22+
23+
interface EmbeddedMessageButtonActionDict {
24+
type: string;
25+
data?: string;
26+
}

0 commit comments

Comments
 (0)