Skip to content

Commit 5729617

Browse files
author
Hyunje Jun
committed
Separate common message property to type
1 parent e0359ea commit 5729617

File tree

1 file changed

+22
-72
lines changed

1 file changed

+22
-72
lines changed

lib/types.ts

Lines changed: 22 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -244,10 +244,23 @@ export type Message =
244244
| TemplateMessage
245245
| FlexMessage;
246246

247+
/**
248+
* @see [Common properties for messages](https://developers.line.me/en/reference/messaging-api/#common-properties-for-messages)
249+
*/
250+
export type MessageCommon = {
251+
/**
252+
* For the quick reply feature.
253+
* For more information, see [Using quick replies](https://developers.line.me/en/docs/messaging-api/using-quick-reply/).
254+
*
255+
* If the user receives multiple [message objects](https://developers.line.me/en/reference/messaging-api/#message-objects), the quickReply property of the last message object is displayed.
256+
*/
257+
quickReply?: QuickReply;
258+
};
259+
247260
/**
248261
* @see [Text message](https://developers.line.me/en/reference/messaging-api/#text-message)
249262
*/
250-
export type TextMessage = {
263+
export type TextMessage = MessageCommon & {
251264
type: "text";
252265
/**
253266
* Message text. You can include the following emoji:
@@ -258,19 +271,12 @@ export type TextMessage = {
258271
* Max: 2000 characters
259272
*/
260273
text: string;
261-
/**
262-
* These properties are used for the quick reply feature.
263-
* For more information, see [Using quick replies](https://developers.line.me/en/docs/messaging-api/using-quick-reply/).
264-
*
265-
* If the user receives multiple [message objects](https://developers.line.me/en/reference/messaging-api/#message-objects), the quickReply property of the last message object is displayed.
266-
*/
267-
quickReply?: QuickReply;
268274
};
269275

270276
/**
271277
* @see [Image message](https://developers.line.me/en/reference/messaging-api/#image-message)
272278
*/
273-
export type ImageMessage = {
279+
export type ImageMessage = MessageCommon & {
274280
type: "image";
275281
/**
276282
* Image URL (Max: 1000 characters)
@@ -290,19 +296,12 @@ export type ImageMessage = {
290296
* - Max: 1 MB
291297
*/
292298
previewImageUrl: string;
293-
/**
294-
* These properties are used for the quick reply feature.
295-
* For more information, see [Using quick replies](https://developers.line.me/en/docs/messaging-api/using-quick-reply/).
296-
*
297-
* If the user receives multiple [message objects](https://developers.line.me/en/reference/messaging-api/#message-objects), the quickReply property of the last message object is displayed.
298-
*/
299-
quickReply?: QuickReply;
300299
};
301300

302301
/**
303302
* @see [Video message](https://developers.line.me/en/reference/messaging-api/#video-message)
304303
*/
305-
export type VideoMessage = {
304+
export type VideoMessage = MessageCommon & {
306305
type: "video";
307306
/**
308307
* URL of video file (Max: 1000 characters)
@@ -324,19 +323,12 @@ export type VideoMessage = {
324323
* - Max: 1 MB
325324
*/
326325
previewImageUrl: string;
327-
/**
328-
* These properties are used for the quick reply feature.
329-
* For more information, see [Using quick replies](https://developers.line.me/en/docs/messaging-api/using-quick-reply/).
330-
*
331-
* If the user receives multiple [message objects](https://developers.line.me/en/reference/messaging-api/#message-objects), the quickReply property of the last message object is displayed.
332-
*/
333-
quickReply?: QuickReply;
334326
};
335327

336328
/**
337329
* @see [Audio message](https://developers.line.me/en/reference/messaging-api/#audio-message)
338330
*/
339-
export type AudioMessage = {
331+
export type AudioMessage = MessageCommon & {
340332
type: "audio";
341333
/**
342334
* URL of audio file (Max: 1000 characters)
@@ -351,19 +343,12 @@ export type AudioMessage = {
351343
* Length of audio file (milliseconds)
352344
*/
353345
duration: number;
354-
/**
355-
* These properties are used for the quick reply feature.
356-
* For more information, see [Using quick replies](https://developers.line.me/en/docs/messaging-api/using-quick-reply/).
357-
*
358-
* If the user receives multiple [message objects](https://developers.line.me/en/reference/messaging-api/#message-objects), the quickReply property of the last message object is displayed.
359-
*/
360-
quickReply?: QuickReply;
361346
};
362347

363348
/**
364349
* @see [Location message](https://developers.line.me/en/reference/messaging-api/#location-message)
365350
*/
366-
export type LocationMessage = {
351+
export type LocationMessage = MessageCommon & {
367352
type: "location";
368353
/**
369354
* Title (Max: 100 characters)
@@ -375,19 +360,12 @@ export type LocationMessage = {
375360
address: string;
376361
latitude: number;
377362
longitude: number;
378-
/**
379-
* These properties are used for the quick reply feature.
380-
* For more information, see [Using quick replies](https://developers.line.me/en/docs/messaging-api/using-quick-reply/).
381-
*
382-
* If the user receives multiple [message objects](https://developers.line.me/en/reference/messaging-api/#message-objects), the quickReply property of the last message object is displayed.
383-
*/
384-
quickReply?: QuickReply;
385363
};
386364

387365
/**
388366
* @see [Sticker message](https://developers.line.me/en/reference/messaging-api/#sticker-message)
389367
*/
390-
export type StickerMessage = {
368+
export type StickerMessage = MessageCommon & {
391369
type: "sticker";
392370
/**
393371
* Package ID for a set of stickers.
@@ -399,19 +377,12 @@ export type StickerMessage = {
399377
* For a list of sticker IDs for stickers that can be sent with the Messaging API, see the [Sticker list](https://developers.line.me/media/messaging-api/sticker_list.pdf).
400378
*/
401379
stickerId: string;
402-
/**
403-
* These properties are used for the quick reply feature.
404-
* For more information, see [Using quick replies](https://developers.line.me/en/docs/messaging-api/using-quick-reply/).
405-
*
406-
* If the user receives multiple [message objects](https://developers.line.me/en/reference/messaging-api/#message-objects), the quickReply property of the last message object is displayed.
407-
*/
408-
quickReply?: QuickReply;
409380
};
410381

411382
/**
412383
* @see [Imagemap message](https://developers.line.me/en/reference/messaging-api/#imagemap-message)
413384
*/
414-
export type ImageMapMessage = {
385+
export type ImageMapMessage = MessageCommon & {
415386
type: "imagemap";
416387
/**
417388
* [Base URL](https://developers.line.me/en/reference/messaging-api/#base-url) of image (Max: 1000 characters, **HTTPS**)
@@ -426,13 +397,6 @@ export type ImageMapMessage = {
426397
* Action when tapped (Max: 50)
427398
*/
428399
actions: ImageMapAction[];
429-
/**
430-
* These properties are used for the quick reply feature.
431-
* For more information, see [Using quick replies](https://developers.line.me/en/docs/messaging-api/using-quick-reply/).
432-
*
433-
* If the user receives multiple [message objects](https://developers.line.me/en/reference/messaging-api/#message-objects), the quickReply property of the last message object is displayed.
434-
*/
435-
quickReply?: QuickReply;
436400
};
437401

438402
/**
@@ -447,7 +411,7 @@ export type ImageMapMessage = {
447411
*
448412
* @see [Template messages](https://developers.line.me/en/reference/messaging-api/#template-messages)
449413
*/
450-
export type TemplateMessage = {
414+
export type TemplateMessage = MessageCommon & {
451415
type: "template";
452416
/**
453417
* Alternative text (Max: 400 characters)
@@ -457,13 +421,6 @@ export type TemplateMessage = {
457421
* A [Buttons](https://developers.line.me/en/reference/messaging-api/#buttons), [Confirm](https://developers.line.me/en/reference/messaging-api/#confirm), [Carousel](https://developers.line.me/en/reference/messaging-api/#carousel), or [Image Carousel](https://developers.line.me/en/reference/messaging-api/#image-carousel) object.
458422
*/
459423
template: TemplateContent;
460-
/**
461-
* These properties are used for the quick reply feature.
462-
* For more information, see [Using quick replies](https://developers.line.me/en/docs/messaging-api/using-quick-reply/).
463-
*
464-
* If the user receives multiple [message objects](https://developers.line.me/en/reference/messaging-api/#message-objects), the quickReply property of the last message object is displayed.
465-
*/
466-
quickReply?: QuickReply;
467424
};
468425

469426
/**
@@ -473,17 +430,10 @@ export type TemplateMessage = {
473430
*
474431
* @see [Flex messages](https://developers.line.me/en/reference/messaging-api/#flex-message)
475432
*/
476-
export type FlexMessage = {
433+
export type FlexMessage = MessageCommon & {
477434
type: "flex";
478435
altText: string;
479436
contents: FlexContainer;
480-
/**
481-
* These properties are used for the quick reply feature.
482-
* For more information, see [Using quick replies](https://developers.line.me/en/docs/messaging-api/using-quick-reply/).
483-
*
484-
* If the user receives multiple [message objects](https://developers.line.me/en/reference/messaging-api/#message-objects), the quickReply property of the last message object is displayed.
485-
*/
486-
quickReply?: QuickReply;
487437
};
488438

489439
/**

0 commit comments

Comments
 (0)