Skip to content

Commit dfc63dc

Browse files
authored
fix richmenu alias api type & add postback params (#294)
1 parent af26e10 commit dfc63dc

File tree

3 files changed

+61
-34
lines changed

3 files changed

+61
-34
lines changed

docs/api-reference/client.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,11 @@ class Client {
5050
getRichMenu(richMenuId: string): Promise<RichMenuResponse>
5151
createRichMenu(richMenu: RichMenu): Promise<string>
5252
deleteRichMenu(richMenuId: string): Promise<any>
53-
getRichMenuAliasList(): Promise<any>
54-
getRichMenuAlias(richMenuAliasId: string): Promise<any>
55-
createRichMenuAlias(richMenuId: string, richMenuAliasId: string): Promise<any>
56-
deleteRichMenuAlias(richMenuAliasId: string): Promise<any>
57-
updateRichMenuAlias(richMenuAliasId: string, richMenuId: string): Promise<any>
53+
getRichMenuAliasList(): Promise<Types.GetRichMenuAliasListResponse>
54+
getRichMenuAlias(richMenuAliasId: string): Promise<Types.GetRichMenuAliasResponse>>
55+
createRichMenuAlias(richMenuId: string, richMenuAliasId: string): Promise<{}>
56+
deleteRichMenuAlias(richMenuAliasId: string): Promise<{}>
57+
updateRichMenuAlias(richMenuAliasId: string, richMenuId: string): Promise<{}>
5858
getRichMenuIdOfUser(userId: string): Promise<string>
5959
linkRichMenuToUser(userId: string, richMenuId: string): Promise<any>
6060
unlinkRichMenuFromUser(userId: string, richMenuId: string): Promise<any>

lib/client.ts

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -285,15 +285,17 @@ export default class Client {
285285
return this.http.delete(`${MESSAGING_API_PREFIX}/richmenu/${richMenuId}`);
286286
}
287287

288-
public async getRichMenuAliasList(): Promise<any> {
289-
const res = await this.http.get<any>(
288+
public async getRichMenuAliasList(): Promise<Types.GetRichMenuAliasListResponse> {
289+
const res = await this.http.get<Types.GetRichMenuAliasListResponse>(
290290
`${MESSAGING_API_PREFIX}/richmenu/alias/list`,
291291
);
292292
return ensureJSON(res);
293293
}
294294

295-
public async getRichMenuAlias(richMenuAliasId: string): Promise<any> {
296-
const res = await this.http.get<any>(
295+
public async getRichMenuAlias(
296+
richMenuAliasId: string,
297+
): Promise<Types.GetRichMenuAliasResponse> {
298+
const res = await this.http.get<Types.GetRichMenuAliasResponse>(
297299
`${MESSAGING_API_PREFIX}/richmenu/alias/${richMenuAliasId}`,
298300
);
299301
return ensureJSON(res);
@@ -302,8 +304,8 @@ export default class Client {
302304
public async createRichMenuAlias(
303305
richMenuId: string,
304306
richMenuAliasId: string,
305-
): Promise<any> {
306-
const res = await this.http.post<any>(
307+
): Promise<{}> {
308+
const res = await this.http.post<{}>(
307309
`${MESSAGING_API_PREFIX}/richmenu/alias`,
308310
{
309311
richMenuId,
@@ -313,16 +315,17 @@ export default class Client {
313315
return ensureJSON(res);
314316
}
315317

316-
public async deleteRichMenuAlias(richMenuAliasId: string): Promise<any> {
317-
return this.http.delete(
318+
public async deleteRichMenuAlias(richMenuAliasId: string): Promise<{}> {
319+
const res = this.http.delete<{}>(
318320
`${MESSAGING_API_PREFIX}/richmenu/alias/${richMenuAliasId}`,
319321
);
322+
return ensureJSON(res);
320323
}
321324

322325
public async updateRichMenuAlias(
323326
richMenuAliasId: string,
324327
richMenuId: string,
325-
): Promise<any> {
328+
): Promise<{}> {
326329
const res = await this.http.put<{}>(
327330
`${MESSAGING_API_PREFIX}/richmenu/alias/${richMenuAliasId}`,
328331
{

lib/types.ts

Lines changed: 44 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -508,28 +508,43 @@ export type StickerEventMessage = {
508508

509509
export type Postback = {
510510
data: string;
511+
params?: DateTimePostback | RichMenuSwitchPostback;
512+
};
513+
514+
/**
515+
* Object with the date and time selected by a user through a
516+
* [datetime picker action](https://developers.line.biz/en/reference/messaging-api/#datetime-picker-action).
517+
* Only returned for postback actions via a
518+
* [datetime picker action](https://developers.line.biz/en/reference/messaging-api/#datetime-picker-action).
519+
* The `full-date`, `time-hour`, and `time-minute` formats follow the
520+
* [RFC3339 protocol](https://www.ietf.org/rfc/rfc3339.txt).
521+
*/
522+
type DateTimePostback = {
511523
/**
512-
* Object with the date and time selected by a user through a
513-
* [datetime picker action](https://developers.line.biz/en/reference/messaging-api/#datetime-picker-action).
514-
* Only returned for postback actions via a
515-
* [datetime picker action](https://developers.line.biz/en/reference/messaging-api/#datetime-picker-action).
516-
* The `full-date`, `time-hour`, and `time-minute` formats follow the
517-
* [RFC3339 protocol](https://www.ietf.org/rfc/rfc3339.txt).
524+
* Date selected by user. Only included in the `date` mode.
518525
*/
519-
params?: {
520-
/**
521-
* Date selected by user. Only included in the `date` mode.
522-
*/
523-
date?: string;
524-
/**
525-
* Time selected by the user. Only included in the `time` mode.
526-
*/
527-
time?: string;
528-
/**
529-
* Date and time selected by the user. Only included in the `datetime` mode.
530-
*/
531-
datetime?: string;
532-
};
526+
date?: string;
527+
/**
528+
* Time selected by the user. Only included in the `time` mode.
529+
*/
530+
time?: string;
531+
/**
532+
* Date and time selected by the user. Only included in the `datetime` mode.
533+
*/
534+
datetime?: string;
535+
};
536+
537+
/**
538+
* Object with rich menu alias ID selected by user via rich menu switch action.
539+
* https://developers.line.biz/en/reference/messaging-api/#postback-params-object-for-richmenu-switch-action
540+
*/
541+
type RichMenuSwitchPostback = {
542+
newRichMenuAliasId: string;
543+
status:
544+
| "SUCCESS"
545+
| "RICHMENU_ALIAS_ID_NOTFOUND"
546+
| "RICHMENU_NOTFOUND"
547+
| "FAILED";
533548
};
534549

535550
/**
@@ -2657,6 +2672,15 @@ export type MembersCountResponse = {
26572672
count: number;
26582673
};
26592674

2675+
export type GetRichMenuAliasResponse = {
2676+
richMenuAliasId: string;
2677+
richMenuId: string;
2678+
};
2679+
2680+
export type GetRichMenuAliasListResponse = {
2681+
aliases: GetRichMenuAliasResponse[];
2682+
};
2683+
26602684
/**
26612685
* Response body of get bot info.
26622686
*

0 commit comments

Comments
 (0)