Skip to content

Commit 03e37c4

Browse files
dlacktyxingoxu
andauthored
Implement getBotInfo API (#261)
* Add getBotInfo API support * Update doc for getBotInfo Co-authored-by: xingo xu <xingoxu@users.noreply.github.com>
1 parent d390415 commit 03e37c4

File tree

4 files changed

+38
-0
lines changed

4 files changed

+38
-0
lines changed

docs/api-reference/client.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,9 @@ class Client {
172172
changeAudienceGroupAuthorityLevel(
173173
authorityLevel: Types.AudienceGroupAuthorityLevel
174174
): Promise<{}>
175+
176+
// Bot
177+
getBotInfo(): Promise<BotInfoResponse>
175178
}
176179
```
177180

@@ -667,3 +670,9 @@ It corresponds to the [Get number of followers](https://developers.line.biz/en/r
667670
#### `getFriendDemographics(): Promise<Types.FriendDemographics>`
668671

669672
It corresponds to the [Get friend demographics](https://developers.line.biz/en/reference/messaging-api/#get-demographic) API.
673+
674+
### Bot
675+
676+
#### `getBotInfo(): Promise<BotInfoResponse>`
677+
678+
It corresponds to the [Get bot info](https://developers.line.biz/en/reference/messaging-api/#get-bot-info) API.

lib/client.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,13 @@ export default class Client {
630630
);
631631
return ensureJSON(res);
632632
}
633+
634+
public async getBotInfo(): Promise<Types.BotInfoResponse> {
635+
const res = await this.http.get<Types.BotInfoResponse>(
636+
`${MESSAGING_API_PREFIX}/info`,
637+
);
638+
return ensureJSON(res);
639+
}
633640
}
634641

635642
export class OAuth {

lib/types.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2482,3 +2482,18 @@ export type GroupSummaryResponse = {
24822482
export type MembersCountResponse = {
24832483
count: number;
24842484
};
2485+
2486+
/**
2487+
* Response body of get bot info.
2488+
*
2489+
* @see [Get bot info](https://developers.line.biz/en/reference/messaging-api/#get-bot-info)
2490+
*/
2491+
export type BotInfoResponse = {
2492+
userId: string;
2493+
basicId: string;
2494+
premiumId?: string;
2495+
displayName: string;
2496+
pictureUrl?: string;
2497+
chatMode: "chat" | "bot";
2498+
markAsReadMode: "auto" | "manual";
2499+
};

test/client.spec.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -960,6 +960,13 @@ describe("client", () => {
960960
equal(err.message, "invalid data type for binary data");
961961
}
962962
});
963+
964+
it("getBotInfo", async () => {
965+
const scope = mockGet(MESSAGING_API_PREFIX, `/info`);
966+
967+
await client.getBotInfo();
968+
equal(scope.isDone(), true);
969+
});
963970
});
964971

965972
const oauth = new OAuth();

0 commit comments

Comments
 (0)