-
Notifications
You must be signed in to change notification settings - Fork 2
/
QuickReply.ts
63 lines (53 loc) · 1.32 KB
/
QuickReply.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/**
* @module QuickReply
*/
import { Abstract } from './Abstract'
export enum ContentType {
TEXT = 'text',
LOCATION = 'location',
USER_PHONE_NUMBER = 'user_phone_number',
USER_EMAIL = 'user_email'
}
export interface QuickReplyItemOption {
title?: String
payload?: String
imageUrl?: String
}
/**
* @see {@link https://developers.facebook.com/docs/messenger-platform/reference/send-api/quick-replies/#quick_reply}
*/
export class QuickReplyItem extends Abstract {
constructor (contentType: ContentType | 'text' | 'location' | 'user_phone_number' | 'user_email', option: QuickReplyItemOption = {}) {
const constructure = {
title: option.title,
content_type: contentType,
payload: option.payload,
image_url: option.imageUrl
}
super(constructure)
}
static get ContentType () {
return ContentType
}
get ContentType () {
return ContentType
}
}
/**
* @see {@link https://developers.facebook.com/docs/messenger-platform/reference/send-api/quick-replies/}
*/
export class QuickReply extends Abstract {
constructor (text: String, quickReplies: QuickReplyItem[]) {
const constructure = {
text,
quick_replies: quickReplies
}
super(constructure)
}
static get Item () {
return QuickReplyItem
}
get Item () {
return QuickReplyItem
}
}