Skip to content

Commit 0e2e825

Browse files
author
Hyunje Jun
authored
Merge pull request #21 from line/template-type-additions
Template type additions
2 parents bdfb4e5 + 8bbf19e commit 0e2e825

File tree

1 file changed

+38
-11
lines changed

1 file changed

+38
-11
lines changed

types/global.d.ts

Lines changed: 38 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,13 @@ declare namespace Line {
4141
export type UnfollowEvent = { type: "unfollow" } & EventBase;
4242
export type JoinEvent = { type: "join" } & ReplyableEvent;
4343
export type LeaveEvent = { type: "leave" } & EventBase;
44-
export type PostbackEvent = { type: "postback", postback: { data: string } } & ReplyableEvent;
44+
export type PostbackEvent = {
45+
type: "postback",
46+
postback: {
47+
data: string,
48+
params?: string,
49+
},
50+
} & ReplyableEvent;
4551
export type BeaconEvent = ReplyableEvent & {
4652
type: "beacon",
4753
beacon: {
@@ -129,41 +135,62 @@ declare namespace Line {
129135

130136
export type ImageMapArea = { x: number, y: number, width: number, height: number };
131137

132-
export type TemplateContent = TemplateButtons | TemplateConfirm | TemplateCarousel;
138+
export type TemplateContent = TemplateButtons | TemplateConfirm | TemplateCarousel | TemplateImageCarousel;
133139
export type TemplateButtons = {
134140
type: "buttons",
135141
thumbnailImageUrl?: string,
136142
title?: string,
137143
text: string,
138-
actions: TemplateAction[],
144+
actions: TemplateAction<{ label: string }>[],
139145
};
140146
export type TemplateConfirm = {
141147
type: "confirm",
142148
text: string,
143-
actions: TemplateAction[],
149+
actions: TemplateAction<{ label: string }>[],
144150
};
145151
export type TemplateCarousel = { type: "carousel", columns: TemplateColumn[] };
146152

147153
export type TemplateColumn = {
148154
thumbnailImageUrl?: string,
149155
title?: string,
150156
text: string,
151-
actions: TemplateAction[],
157+
actions: TemplateAction<{ label: string }>[],
158+
};
159+
160+
export type TemplateImageCarousel = {
161+
type: "image_carousel",
162+
columns: TemplateImageColumn,
163+
};
164+
165+
export type TemplateImageColumn = {
166+
imageUrl: string,
167+
action: TemplateAction<{ label?: string }>,
152168
};
153169

154-
export type TemplateAction = TemplatePostbackAction | TemplateMessageAction | TemplateURIAction;
155-
export type TemplateActionBase = { label: string };
170+
export type TemplateAction<Label> =
171+
| TemplatePostbackAction & Label
172+
| TemplateMessageAction & Label
173+
| TemplateURIAction & Label
174+
| TemplateDatetimePickerAction & Label;
156175
export type TemplatePostbackAction = {
157176
type: "postback",
158177
data: string,
159178
text?: string,
160-
} & TemplateActionBase;
179+
};
161180
export type TemplateMessageAction = {
162181
type: "message",
163182
text: string,
164-
} & TemplateActionBase;
183+
};
165184
export type TemplateURIAction = {
166-
type: "template",
185+
type: "uri",
167186
uri: string,
168-
} & TemplateActionBase;
187+
};
188+
export type TemplateDatetimePickerAction = {
189+
type: "datetimepicker",
190+
data: string,
191+
mode: "date" | "time" | "datetime",
192+
initial?: string,
193+
max?: string,
194+
min?: string,
195+
};
169196
}

0 commit comments

Comments
 (0)