Skip to content

Commit 41cd81d

Browse files
SombreroElGringoHyunje Jun
authored andcommitted
Add AltURI, linkRichMenuToMultipleUsers & unlinkRichMenusFromMultipleUsers (#135)
* Add AltURI type * Add linkRichMenuToMultipleUsers and unlinkRichMenusFromMultipleUsers
1 parent f039d08 commit 41cd81d

File tree

4 files changed

+84
-0
lines changed

4 files changed

+84
-0
lines changed

docs/api-reference/client.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ class Client {
3737
getRichMenuIdOfUser(userId: string): Promise<string>
3838
linkRichMenuToUser(userId: string, richMenuId: string): Promise<any>
3939
unlinkRichMenuFromUser(userId: string, richMenuId: string): Promise<any>
40+
linkRichMenuToMultipleUsers(richMenuId: string, userIds: string[]): Promise<any>
41+
unlinkRichMenusFromMultipleUsers(userIds: string[]): Promise<any>
4042
getRichMenuImage(richMenuId: string): Promise<Readable>
4143
setRichMenuImage(richMenuId: string, data: Buffer | Readable, contentType?: string): Promise<any>
4244
getRichMenuList(): Promise<Array<RichMenuResponse>>
@@ -309,6 +311,26 @@ The arguments are a user ID and a rich menu ID.
309311
client.unlinkRichMenuFromUser('user_id', 'rich_menu_id')
310312
```
311313

314+
#### `linkRichMenuToMultipleUsers(richMenuId: string, userIds: string[]): Promise<any>`
315+
316+
It corresponds to the [Link rich menu to multiple users](https://developers.line.biz/en/reference/messaging-api/#link-rich-menu-to-users) API.
317+
318+
The arguments are a richMenuId and a array of userIds.
319+
320+
``` js
321+
client.linkRichMenuToMultipleUsers('rich_menu_id', ['user_id'])
322+
```
323+
324+
#### `unlinkRichMenusFromMultipleUsers(userIds: string[]): Promise<any>`
325+
326+
It corresponds to the [Unlink rich menus from multiple users](https://developers.line.biz/en/reference/messaging-api#unlink-rich-menu-from-users) API.
327+
328+
The argument is a array of userIds.
329+
330+
``` js
331+
client.unlinkRichMenusFromMultipleUsers(['user_id'])
332+
```
333+
312334
#### `getRichMenuImage(richMenuId: string): Promise<Readable>`
313335

314336
It corresponds to the [Download rich menu image](https://developers.line.me/en/docs/messaging-api/reference/#download-rich-menu-image) API.

lib/client.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,22 @@ export default class Client {
169169
return this.http.delete(`/user/${userId}/richmenu`);
170170
}
171171

172+
public linkRichMenuToMultipleUsers(
173+
richMenuId: string,
174+
userIds: string[],
175+
): Promise<any> {
176+
return this.http.post("/richmenu/bulk/link", {
177+
richMenuId,
178+
userIds,
179+
});
180+
}
181+
182+
public unlinkRichMenusFromMultipleUsers(userIds: string[]): Promise<any> {
183+
return this.http.post("/richmenu/bulk/unlink", {
184+
userIds,
185+
});
186+
}
187+
172188
public getRichMenuImage(richMenuId: string): Promise<Readable> {
173189
return this.http.getStream(`/richmenu/${richMenuId}/content`);
174190
}

lib/types.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1552,6 +1552,21 @@ export type URIAction = {
15521552
* Must start with `http`, `https`, or `tel`.
15531553
*/
15541554
uri: string;
1555+
altUri?: AltURI;
1556+
};
1557+
1558+
/**
1559+
* URI opened on LINE for macOS and Windows when the action is performed (Max: 1000 characters)
1560+
* If the altUri.desktop property is set, the uri property is ignored on LINE for macOS and Windows.
1561+
* The available schemes are http, https, line, and tel.
1562+
* For more information about the LINE URL scheme, see Using the LINE URL scheme.
1563+
* This property is supported on the following version of LINE.
1564+
*
1565+
* LINE 5.12.0 or later for macOS and Windows
1566+
* Note: The altUri.desktop property is supported only when you set URI actions in Flex Messages.
1567+
*/
1568+
export type AltURI = {
1569+
desktop: string;
15551570
};
15561571

15571572
/**

test/client.spec.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,37 @@ describe("client", () => {
257257
});
258258
});
259259

260+
it("linkRichMenuToMultipleUsers", () => {
261+
return client
262+
.linkRichMenuToMultipleUsers("test_rich_menu_id", ["test_user_id"])
263+
.then((res: any) => {
264+
const req = getRecentReq();
265+
equal(req.headers.authorization, "Bearer test_channel_access_token");
266+
equal(req.path, "/richmenu/bulk/link");
267+
equal(req.method, "POST");
268+
deepEqual(res, {});
269+
deepEqual(req.body, {
270+
richMenuId: "test_rich_menu_id",
271+
userIds: ["test_user_id"],
272+
});
273+
});
274+
});
275+
276+
it("unlinkRichMenusFromMultipleUsers", () => {
277+
return client
278+
.unlinkRichMenusFromMultipleUsers(["test_user_id"])
279+
.then((res: any) => {
280+
const req = getRecentReq();
281+
equal(req.headers.authorization, "Bearer test_channel_access_token");
282+
equal(req.path, "/richmenu/bulk/unlink");
283+
equal(req.method, "POST");
284+
deepEqual(res, {});
285+
deepEqual(req.body, {
286+
userIds: ["test_user_id"],
287+
});
288+
});
289+
});
290+
260291
it("setRichMenuImage", () => {
261292
const filepath = join(__dirname, "/helpers/line-icon.png");
262293
const buffer = readFileSync(filepath);

0 commit comments

Comments
 (0)