Skip to content

Commit ed4a8d0

Browse files
github-actions[bot]github-actions
andauthored
Codes are generated by openapi (#821)
In the Messaging API, we've added a new endpoint that allows you to [display a loading animation](https://developers.line.biz/en/reference/messaging-api/#display-a-loading-indicator). After your LINE Official Account receives a message from a user, the response may takes some time due to message preparation or reservation processing. In such cases, you can visually tell the user that you want them to wait by displaying a loading animation. news: https://developers.line.biz/en/news/2024/04/17/loading-indicator/ ![loading-animation 7aad3d6c](https://github.com/line/line-openapi/assets/24933664/4435a2c1-db0c-409a-92f1-7c5fb64903c3) line/line-openapi#54 Co-authored-by: github-actions <[email protected]>
1 parent 17c048b commit ed4a8d0

File tree

6 files changed

+149
-1
lines changed

6 files changed

+149
-1
lines changed

lib/messaging-api/.openapi-generator/FILES

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ model/roomUserProfileResponse.ts
135135
model/sender.ts
136136
model/sentMessage.ts
137137
model/setWebhookEndpointRequest.ts
138+
model/showLoadingAnimationRequest.ts
138139
model/stickerMessage.ts
139140
model/subscribedMembershipPlan.ts
140141
model/subscribedMembershipUser.ts

lib/messaging-api/api/messagingApiClient.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ import { RichMenuResponse } from "../model/richMenuResponse.js";
5252
import { RoomMemberCountResponse } from "../model/roomMemberCountResponse.js";
5353
import { RoomUserProfileResponse } from "../model/roomUserProfileResponse.js";
5454
import { SetWebhookEndpointRequest } from "../model/setWebhookEndpointRequest.js";
55+
import { ShowLoadingAnimationRequest } from "../model/showLoadingAnimationRequest.js";
5556
import { TestWebhookEndpointRequest } from "../model/testWebhookEndpointRequest.js";
5657
import { TestWebhookEndpointResponse } from "../model/testWebhookEndpointResponse.js";
5758
import { UpdateRichMenuAliasRequest } from "../model/updateRichMenuAliasRequest.js";
@@ -1720,6 +1721,38 @@ export class MessagingApiClient {
17201721
);
17211722
return { httpResponse: res, body: await res.json() };
17221723
}
1724+
/**
1725+
* Display a loading animation in one-on-one chats between users and LINE Official Accounts.
1726+
* @param showLoadingAnimationRequest
1727+
*
1728+
* @see <a href="https://developers.line.biz/en/reference/messaging-api/#display-a-loading-indicator"> Documentation</a>
1729+
*/
1730+
public async showLoadingAnimation(
1731+
showLoadingAnimationRequest: ShowLoadingAnimationRequest,
1732+
): Promise<object> {
1733+
return (
1734+
await this.showLoadingAnimationWithHttpInfo(showLoadingAnimationRequest)
1735+
).body;
1736+
}
1737+
1738+
/**
1739+
* Display a loading animation in one-on-one chats between users and LINE Official Accounts..
1740+
* This method includes HttpInfo object to return additional information.
1741+
* @param showLoadingAnimationRequest
1742+
*
1743+
* @see <a href="https://developers.line.biz/en/reference/messaging-api/#display-a-loading-indicator"> Documentation</a>
1744+
*/
1745+
public async showLoadingAnimationWithHttpInfo(
1746+
showLoadingAnimationRequest: ShowLoadingAnimationRequest,
1747+
): Promise<Types.ApiResponseType<object>> {
1748+
const params = showLoadingAnimationRequest;
1749+
1750+
const res = await this.httpClient.post(
1751+
"/v2/bot/chat/loading/start",
1752+
params,
1753+
);
1754+
return { httpResponse: res, body: await res.json() };
1755+
}
17231756
/**
17241757
* Test webhook endpoint
17251758
* @param testWebhookEndpointRequest

lib/messaging-api/model/models.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ export * from "./roomUserProfileResponse.js";
129129
export * from "./sender.js";
130130
export * from "./sentMessage.js";
131131
export * from "./setWebhookEndpointRequest.js";
132+
export * from "./showLoadingAnimationRequest.js";
132133
export * from "./stickerMessage.js";
133134
export * from "./subscribedMembershipPlan.js";
134135
export * from "./subscribedMembershipUser.js";
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/**
2+
* LINE Messaging API
3+
* This document describes LINE Messaging API.
4+
*
5+
* The version of the OpenAPI document: 0.0.1
6+
*
7+
*
8+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
9+
* https://openapi-generator.tech
10+
* Do not edit the class manually.
11+
*/
12+
13+
export type ShowLoadingAnimationRequest = {
14+
/**
15+
* User ID of the target user for whom the loading animation is to be displayed.
16+
*
17+
* @see <a href="https://developers.line.biz/en/reference/messaging-api/#display-a-loading-indicator-request-body">chatId Documentation</a>
18+
*/
19+
chatId: string /**/;
20+
/**
21+
* The number of seconds to display the loading indicator. It must be a multiple of 5. The maximum value is 60 seconds.
22+
*
23+
* @see <a href="https://developers.line.biz/en/reference/messaging-api/#display-a-loading-indicator-request-body">loadingSeconds Documentation</a>
24+
*/
25+
loadingSeconds?: number /**/;
26+
};

lib/messaging-api/tests/api/MessagingApiClientTest.spec.ts

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ import { RichMenuResponse } from "../../model/richMenuResponse.js";
4141
import { RoomMemberCountResponse } from "../../model/roomMemberCountResponse.js";
4242
import { RoomUserProfileResponse } from "../../model/roomUserProfileResponse.js";
4343
import { SetWebhookEndpointRequest } from "../../model/setWebhookEndpointRequest.js";
44+
import { ShowLoadingAnimationRequest } from "../../model/showLoadingAnimationRequest.js";
4445
import { TestWebhookEndpointRequest } from "../../model/testWebhookEndpointRequest.js";
4546
import { TestWebhookEndpointResponse } from "../../model/testWebhookEndpointResponse.js";
4647
import { UpdateRichMenuAliasRequest } from "../../model/updateRichMenuAliasRequest.js";
@@ -5057,6 +5058,92 @@ describe("MessagingApiClient", () => {
50575058
server.close();
50585059
});
50595060

5061+
it("showLoadingAnimationWithHttpInfo", async () => {
5062+
let requestCount = 0;
5063+
5064+
const server = createServer((req, res) => {
5065+
requestCount++;
5066+
5067+
equal(req.method, "POST");
5068+
const reqUrl = new URL(req.url, "http://localhost/");
5069+
equal(reqUrl.pathname, "/v2/bot/chat/loading/start");
5070+
5071+
equal(req.headers["authorization"], `Bearer ${channel_access_token}`);
5072+
equal(
5073+
req.headers["user-agent"],
5074+
"@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__",
5075+
);
5076+
5077+
res.writeHead(200, { "Content-Type": "application/json" });
5078+
res.end(JSON.stringify({}));
5079+
});
5080+
await new Promise(resolve => {
5081+
server.listen(0);
5082+
server.on("listening", resolve);
5083+
});
5084+
5085+
const serverAddress = server.address();
5086+
if (typeof serverAddress === "string" || serverAddress === null) {
5087+
throw new Error("Unexpected server address: " + serverAddress);
5088+
}
5089+
5090+
const client = new MessagingApiClient({
5091+
channelAccessToken: channel_access_token,
5092+
baseURL: `http://localhost:${String(serverAddress.port)}/`,
5093+
});
5094+
5095+
const res = await client.showLoadingAnimationWithHttpInfo(
5096+
// showLoadingAnimationRequest: ShowLoadingAnimationRequest
5097+
{} as unknown as ShowLoadingAnimationRequest, // paramName=showLoadingAnimationRequest
5098+
);
5099+
5100+
equal(requestCount, 1);
5101+
server.close();
5102+
});
5103+
5104+
it("showLoadingAnimation", async () => {
5105+
let requestCount = 0;
5106+
5107+
const server = createServer((req, res) => {
5108+
requestCount++;
5109+
5110+
equal(req.method, "POST");
5111+
const reqUrl = new URL(req.url, "http://localhost/");
5112+
equal(reqUrl.pathname, "/v2/bot/chat/loading/start");
5113+
5114+
equal(req.headers["authorization"], `Bearer ${channel_access_token}`);
5115+
equal(
5116+
req.headers["user-agent"],
5117+
"@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__",
5118+
);
5119+
5120+
res.writeHead(200, { "Content-Type": "application/json" });
5121+
res.end(JSON.stringify({}));
5122+
});
5123+
await new Promise(resolve => {
5124+
server.listen(0);
5125+
server.on("listening", resolve);
5126+
});
5127+
5128+
const serverAddress = server.address();
5129+
if (typeof serverAddress === "string" || serverAddress === null) {
5130+
throw new Error("Unexpected server address: " + serverAddress);
5131+
}
5132+
5133+
const client = new MessagingApiClient({
5134+
channelAccessToken: channel_access_token,
5135+
baseURL: `http://localhost:${String(serverAddress.port)}/`,
5136+
});
5137+
5138+
const res = await client.showLoadingAnimation(
5139+
// showLoadingAnimationRequest: ShowLoadingAnimationRequest
5140+
{} as unknown as ShowLoadingAnimationRequest, // paramName=showLoadingAnimationRequest
5141+
);
5142+
5143+
equal(requestCount, 1);
5144+
server.close();
5145+
});
5146+
50605147
it("testWebhookEndpointWithHttpInfo", async () => {
50615148
let requestCount = 0;
50625149

line-openapi

0 commit comments

Comments
 (0)