@@ -9,19 +9,37 @@ corresponding to [messaging APIs](https://developers.line.me/en/docs/messaging-a
9
9
class Client {
10
10
public config: ClientConfig
11
11
12
- constructor (config : ClientConfig )
12
+ constructor (config : ClientConfig ) {}
13
13
14
- pushMessage(to : string , messages : Message | Message []): Promise <{}>
15
- replyMessage(replyToken : string , messages : Message | Message []): Promise <{}>
16
- multicast(to : string [], messages : Message | Message []): Promise <{}>
14
+ // Message
15
+ pushMessage(to : string , messages : Message | Message []): Promise <any >
16
+ replyMessage(replyToken : string , messages : Message | Message []): Promise <any >
17
+ multicast(to : string [], messages : Message | Message []): Promise <any >
18
+ getMessageContent(messageId : string ): Promise <Readable >
19
+
20
+ // Profile
17
21
getProfile(userId : string ): Promise <Profile >
22
+
23
+ // Group
18
24
getGroupMemberProfile(groupId : string , userId : string ): Promise <Profile >
19
- getRoomMemberProfile(roomId : string , userId : string ): Promise <Profile >
20
25
getGroupMemberIds(groupId : string ): Promise <string []>
26
+ leaveGroup(groupId : string ): Promise <any >
27
+
28
+ // Room
29
+ getRoomMemberProfile(roomId : string , userId : string ): Promise <Profile >
21
30
getRoomMemberIds(roomId : string ): Promise <string []>
22
- getMessageContent(messageId : string ): Promise <ReadableStream >
23
- leaveGroup(groupId : string ): Promise <{}>
24
- leaveRoom(roomId : string ): Promise <{}>
31
+ leaveRoom(roomId : string ): Promise <any >
32
+
33
+ // Rich menu
34
+ getRichMenu(richMenuId : string ): Promise <RichMenuResponse >
35
+ createRichMenu(richMenu : RichMenu ): Promise <string >
36
+ deleteRichMenu(richMenuId : string ): Promise <any >
37
+ getRichMenuIdOfUser(userId : string ): Promise <string >
38
+ linkRichMenuToUser(userId : string , richMenuId : string ): Promise <any >
39
+ unlinkRichMenuFromUser(userId : string , richMenuId : string ): Promise <any >
40
+ getRichMenuImage(richMenuId : string ): Promise <Readable >
41
+ setRichMenuImage(richMenuId : string , data : Buffer | Readable , contentType ? : string ): Promise <any >
42
+ getRichMenuList(): Promise <Array <RichMenuResponse >>
25
43
}
26
44
```
27
45
@@ -51,7 +69,9 @@ goes wrong, such as HTTP errors or parsing errors. You can catch them with the
51
69
` .catch() ` method of the promises. The detailed error handling is explained
52
70
in [ the Client guide] ( ../guide/client.md ) .
53
71
54
- ### ` pushMessage(to: string, messages: Message | Message[]): Promise<{}> `
72
+ ### Message
73
+
74
+ #### ` pushMessage(to: string, messages: Message | Message[]): Promise<any> `
55
75
56
76
It corresponds to the [ Push message] ( https://developers.line.me/en/docs/messaging-api/reference/#send-push-message ) API.
57
77
@@ -64,7 +84,7 @@ client.pushMessage('user_or_group_or_room_id', {
64
84
})
65
85
```
66
86
67
- ### ` replyMessage(replyToken: string, messages: Message | Message[]): Promise<{} > `
87
+ #### ` replyMessage(replyToken: string, messages: Message | Message[]): Promise<any > `
68
88
69
89
It corresponds to the [ Reply message] ( https://developers.line.me/en/docs/messaging-api/reference/#send-reply-message ) API.
70
90
@@ -79,7 +99,7 @@ client.replyMessage(event.replyToken, {
79
99
})
80
100
```
81
101
82
- ### ` multicast(to: string[], messages: Message | Message[]): Promise<{} > `
102
+ #### ` multicast(to: string[], messages: Message | Message[]): Promise<any > `
83
103
84
104
It corresponds to the [ Multicast] ( https://developers.line.me/en/docs/messaging-api/reference/#send-multicast-messages ) API.
85
105
@@ -93,7 +113,32 @@ client.multicast(['user_id_1', 'user_id_2', 'room_id_1'], {
93
113
})
94
114
```
95
115
96
- ### ` getProfile(userId: string): Promise<Profile> `
116
+ #### ` getMessageContent(messageId: string): Promise<Readable> `
117
+
118
+ It corresponds to the [ Content] ( https://developers.line.me/en/docs/messaging-api/reference/#get-content ) API.
119
+
120
+ The argument is an ID of media messages, such as image, video, and audio. The ID
121
+ can be retrieved from a message object of a message event.
122
+
123
+ Please beware that what it returns is promise of [ readable stream] ( https://nodejs.org/dist/latest/docs/api/stream.html#stream_readable_streams ) .
124
+ You can pipe the stream into a file, an HTTP response, etc.
125
+
126
+ ``` js
127
+ client .getMessageContent (' message_id' )
128
+ .then ((stream ) => {
129
+ stream .on (' data' , (chunk ) => {
130
+ ...
131
+ })
132
+ stream .on (' error' , (err ) => {
133
+ ...
134
+ })
135
+ stream .pipe (... )
136
+ })
137
+ ```
138
+
139
+ ### Profile
140
+
141
+ #### ` getProfile(userId: string): Promise<Profile> `
97
142
98
143
It corresponds to the [ Profile] ( https://developers.line.me/en/docs/messaging-api/reference/#get-profile ) API.
99
144
@@ -105,7 +150,9 @@ client.getProfile('user_id').then((profile) => {
105
150
});
106
151
```
107
152
108
- ### ` getGroupMemberProfile(groupId: string, userId: string): Promise<Profile> `
153
+ ### Group
154
+
155
+ #### ` getGroupMemberProfile(groupId: string, userId: string): Promise<Profile> `
109
156
110
157
It corresponds to the [ Group Member Profile] ( https://developers.line.me/en/docs/messaging-api/reference/#get-group-member-profile ) API.
111
158
@@ -118,7 +165,33 @@ client.getGroupMemberProfile('group_id', 'user_id').then((profile) => {
118
165
})
119
166
```
120
167
121
- ### ` getRoomMemberProfile(roomId: string, userId: string): Promise<Profile> `
168
+ #### ` getGroupMemberIds(groupId: string): Promise<string[]> `
169
+
170
+ It corresponds to the [ Group Member IDs] ( https://developers.line.me/en/docs/messaging-api/reference/#get-group-member-user-ids ) API.
171
+
172
+ * FYI: This feature is only available for LINE@ Approved accounts or official accounts.*
173
+
174
+ The argument is a group ID and the method returns a promise of an array of user IDs.
175
+
176
+ ``` js
177
+ client .getGroupMemberIds (' group_id' ).then ((ids ) => {
178
+ ids .forEach ((id ) => console .log (id));
179
+ })
180
+ ```
181
+
182
+ #### ` leaveGroup(groupId: string): Promise<any> `
183
+
184
+ It corresponds to the [ Leave group] ( https://developers.line.me/en/docs/messaging-api/reference/#leave-group ) API.
185
+
186
+ The argument is a group ID.
187
+
188
+ ``` js
189
+ client .leaveGroup (' group_id' )
190
+ ```
191
+
192
+ ### Room
193
+
194
+ #### ` getRoomMemberProfile(roomId: string, userId: string): Promise<Profile> `
122
195
123
196
It corresponds to the [ Room Member Profile] ( https://developers.line.me/en/docs/messaging-api/reference/#get-room-member-profile ) API.
124
197
@@ -131,46 +204,111 @@ client.getRoomMemberProfile('room_id', 'user_id').then((profile) => {
131
204
})
132
205
```
133
206
134
- ### ` getGroupMemberIds(groupId : string): Promise<string[]>`
207
+ #### ` getRoomMemberIds(roomId : string): Promise<string[]>`
135
208
136
- It corresponds to the [ Group Member IDs] ( https://developers.line.me/en/docs/messaging-api/reference/#get-group -member-user-ids ) API.
209
+ It corresponds to the [ Room Member IDs] ( https://developers.line.me/en/docs/messaging-api/reference/#get-room -member-user-ids ) API.
137
210
138
211
* FYI: This feature is only available for LINE@ Approved accounts or official accounts.*
139
212
140
- The argument is a group ID and the method returns a promise of an array of user IDs.
213
+ The argument is a room ID and the method returns a promise of an array of user IDs.
141
214
142
215
``` js
143
- client .getGroupMemberIds ( ' group_id ' ).then ((ids ) => {
216
+ client .getRoomMemberIds ( ' room_id ' ).then ((ids ) => {
144
217
ids .forEach ((id ) => console .log (id));
145
218
})
146
219
```
147
220
148
- ### ` getRoomMemberIds (roomId: string): Promise<string[] >`
221
+ #### ` leaveRoom (roomId: string): Promise<any >`
149
222
150
- It corresponds to the [ Room Member IDs ] ( https://developers.line.me/en/docs/messaging-api/reference/#get -room-member-user-ids ) API.
223
+ It corresponds to the [ Leave room ] ( https://developers.line.me/en/docs/messaging-api/reference/#leave -room ) API.
151
224
152
- * FYI: This feature is only available for LINE@ Approved accounts or official accounts. *
225
+ The argument is a room ID.
153
226
154
- The argument is a room ID and the method returns a promise of an array of user IDs.
227
+ ``` js
228
+ client .leaveGroup (' room_id' )
229
+ ```
230
+
231
+ ### Rich menu
232
+
233
+ #### ` getRichMenu(richMenuId: string): Promise<RichMenuResponse> `
234
+
235
+ It corresponds to the [ Get rich menu] ( https://developers.line.me/en/docs/messaging-api/reference/#get-rich-menu ) API.
236
+
237
+ The argument is a rich menu ID. The return type is [ a rich menu response object] ( https://developers.line.me/en/docs/messaging-api/reference/#rich-menu-response-object ) .
155
238
156
239
``` js
157
- client .getRoomMemberIds (' room_id' ).then ((ids ) => {
158
- ids .forEach ((id ) => console .log (id));
240
+ client .getRichMenu (' rich_menu_id' ).then ((richMenu ) => {
241
+ console .log (richMenu .size );
242
+ console .log (richMenu .areas [0 ].bounds );
159
243
})
160
244
```
161
245
162
- ### ` getMessageContent(messageId: string ): Promise<ReadableStream >`
246
+ #### ` createRichMenu(richMenu: RichMenu ): Promise<string >`
163
247
164
- It corresponds to the [ Content ] ( https://developers.line.me/en/docs/messaging-api/reference/#get-content ) API.
248
+ It corresponds to the [ Create rich menu ] ( https://developers.line.me/en/docs/messaging-api/reference/#create-rich-menu ) API.
165
249
166
- The argument is an ID of media messages, such as image, video, and audio. The ID
167
- can be retrieved from a message object of a message event.
250
+ The argument is [ a rich menu object] ( https://developers.line.me/en/docs/messaging-api/reference/#rich-menu-object ) .
251
+ For the detail of the object format, please refer to the official documentation.
252
+ It returns the result rich menu ID.
253
+
254
+ ``` js
255
+ client .createRichMenu ({ size: { width: 2500 , height: 1686 }, ... })
256
+ .then ((richMenuId ) => console .log (richMenuId))
257
+ ```
258
+
259
+ #### ` deleteRichMenu(richMenuId: string): Promise<any> `
260
+
261
+ It corresponds to the [ Delete rich menu] ( https://developers.line.me/en/docs/messaging-api/reference/#delete-rich-menu ) API.
262
+
263
+ The argument is a rich menu ID.
264
+
265
+ ``` js
266
+ client .deleteRichMenu (' rich_menu_id' )
267
+ ```
268
+
269
+ #### ` getRichMenuIdOfUser(userId: string): Promise<string> `
270
+
271
+ It corresponds to the [ Get rich menu ID of user] ( https://developers.line.me/en/docs/messaging-api/reference/#get-rich-menu-id-of-user ) API.
272
+
273
+ The argument is a user ID. It returns a rich menu ID to be used with other APIs.
274
+
275
+ ``` js
276
+ client .getRichMenuIdOfUser (' user_id' ).then ((richMenuId ) => {
277
+ console .log (richMenuId);
278
+ })
279
+ ```
280
+
281
+ #### ` linkRichMenuToUser(userId: string, richMenuId: string): Promise<any> `
282
+
283
+ It corresponds to the [ Link rich menu to user] ( https://developers.line.me/en/docs/messaging-api/reference/#link-rich-menu-to-user ) API.
284
+
285
+ The arguments are a user ID and a rich menu ID.
286
+
287
+ ``` js
288
+ client .linkRichMenuToUser (' user_id' , ' rich_menu_id' )
289
+ ```
290
+
291
+ #### ` unlinkRichMenuFromUser(userId: string, richMenuId: string): Promise<any> `
292
+
293
+ It corresponds to the [ Unlink rich menu from user] ( https://developers.line.me/en/docs/messaging-api/reference/#unlink-rich-menu-from-user ) API.
294
+
295
+ The arguments are a user ID and a rich menu ID.
296
+
297
+ ``` js
298
+ client .unlinkRichMenuFromUser (' user_id' , ' rich_menu_id' )
299
+ ```
300
+
301
+ #### ` getRichMenuImage(richMenuId: string): Promise<Readable> `
302
+
303
+ It corresponds to the [ Download rich menu image] ( https://developers.line.me/en/docs/messaging-api/reference/#download-rich-menu-image ) API.
304
+
305
+ The argument is a rich menu ID.
168
306
169
307
Please beware that what it returns is promise of [ readable stream] ( https://nodejs.org/dist/latest/docs/api/stream.html#stream_readable_streams ) .
170
308
You can pipe the stream into a file, an HTTP response, etc.
171
309
172
310
``` js
173
- client .getMessageContent ( ' message_id ' )
311
+ client .getRichMenuImage ( ' rich_menu_id ' )
174
312
.then ((stream ) => {
175
313
stream .on (' data' , (chunk ) => {
176
314
...
@@ -182,22 +320,22 @@ client.getMessageContent('message_id')
182
320
})
183
321
```
184
322
185
- ### ` leaveGroup(groupId : string): Promise<{} >`
323
+ #### ` setRichMenuImage(richMenuId : string, data: Buffer | Readable, contentType?: string ): Promise<any >`
186
324
187
- It corresponds to the [ Leave group ] ( https://developers.line.me/en/docs/messaging-api/reference/#leave-group ) API.
325
+ It corresponds to the [ Upload rich menu image ] ( https://developers.line.me/en/docs/messaging-api/reference/#upload-rich-menu-image ) API.
188
326
189
- The argument is a group ID.
327
+ The 1st argument is a rich menu ID. For 2nd argument, a buffer or a readable
328
+ stream of an image should be provided. For the restriction of the image, please
329
+ refer to the official documentation. The last argument is optional. If it's not
330
+ provided, the mime type will be guessted from ` data ` . Only ` image/jpeg ` or
331
+ ` image/png ` is allowed for the content type.
190
332
191
333
``` js
192
- client .leaveGroup ( ' group_id ' )
334
+ client .setRichMenuImage ( ' rich_menu_id ' , fs . createReadStream ( ' ./some_image.png ' ) )
193
335
```
194
336
195
- ### ` leaveRoom(roomId: string): Promise<{}> `
196
-
197
- It corresponds to the [ Leave room] ( https://developers.line.me/en/docs/messaging-api/reference/#leave-room ) API.
337
+ #### ` getRichMenuList(): Promise<Array<RichMenuResponse>> `
198
338
199
- The argument is a room ID .
339
+ It corresponds to the [ Get rich menu list ] ( https://developers.line.me/en/docs/messaging-api/reference/#get-rich-menu-list ) API .
200
340
201
- ``` js
202
- client .leaveGroup (' room_id' )
203
- ```
341
+ The return type is a list of [ rich menu response objects] ( https://developers.line.me/en/docs/messaging-api/reference/#rich-menu-response-object ) .
0 commit comments