From ed4a8d0687ec9dc5532d18b9c7961f8be1f7d71b Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 17 Apr 2024 08:43:00 +0000 Subject: [PATCH] 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) https://github.com/line/line-openapi/pull/54 Co-authored-by: github-actions <github-actions@github.com> --- lib/messaging-api/.openapi-generator/FILES | 1 + lib/messaging-api/api/messagingApiClient.ts | 33 +++++++ lib/messaging-api/model/models.ts | 1 + .../model/showLoadingAnimationRequest.ts | 26 ++++++ .../tests/api/MessagingApiClientTest.spec.ts | 87 +++++++++++++++++++ line-openapi | 2 +- 6 files changed, 149 insertions(+), 1 deletion(-) create mode 100644 lib/messaging-api/model/showLoadingAnimationRequest.ts diff --git a/lib/messaging-api/.openapi-generator/FILES b/lib/messaging-api/.openapi-generator/FILES index bc263a000..cf7bd7916 100644 --- a/lib/messaging-api/.openapi-generator/FILES +++ b/lib/messaging-api/.openapi-generator/FILES @@ -135,6 +135,7 @@ model/roomUserProfileResponse.ts model/sender.ts model/sentMessage.ts model/setWebhookEndpointRequest.ts +model/showLoadingAnimationRequest.ts model/stickerMessage.ts model/subscribedMembershipPlan.ts model/subscribedMembershipUser.ts diff --git a/lib/messaging-api/api/messagingApiClient.ts b/lib/messaging-api/api/messagingApiClient.ts index fb0601f07..129395b84 100644 --- a/lib/messaging-api/api/messagingApiClient.ts +++ b/lib/messaging-api/api/messagingApiClient.ts @@ -52,6 +52,7 @@ import { RichMenuResponse } from "../model/richMenuResponse.js"; import { RoomMemberCountResponse } from "../model/roomMemberCountResponse.js"; import { RoomUserProfileResponse } from "../model/roomUserProfileResponse.js"; import { SetWebhookEndpointRequest } from "../model/setWebhookEndpointRequest.js"; +import { ShowLoadingAnimationRequest } from "../model/showLoadingAnimationRequest.js"; import { TestWebhookEndpointRequest } from "../model/testWebhookEndpointRequest.js"; import { TestWebhookEndpointResponse } from "../model/testWebhookEndpointResponse.js"; import { UpdateRichMenuAliasRequest } from "../model/updateRichMenuAliasRequest.js"; @@ -1720,6 +1721,38 @@ export class MessagingApiClient { ); return { httpResponse: res, body: await res.json() }; } + /** + * Display a loading animation in one-on-one chats between users and LINE Official Accounts. + * @param showLoadingAnimationRequest + * + * @see <a href="https://developers.line.biz/en/reference/messaging-api/#display-a-loading-indicator"> Documentation</a> + */ + public async showLoadingAnimation( + showLoadingAnimationRequest: ShowLoadingAnimationRequest, + ): Promise<object> { + return ( + await this.showLoadingAnimationWithHttpInfo(showLoadingAnimationRequest) + ).body; + } + + /** + * Display a loading animation in one-on-one chats between users and LINE Official Accounts.. + * This method includes HttpInfo object to return additional information. + * @param showLoadingAnimationRequest + * + * @see <a href="https://developers.line.biz/en/reference/messaging-api/#display-a-loading-indicator"> Documentation</a> + */ + public async showLoadingAnimationWithHttpInfo( + showLoadingAnimationRequest: ShowLoadingAnimationRequest, + ): Promise<Types.ApiResponseType<object>> { + const params = showLoadingAnimationRequest; + + const res = await this.httpClient.post( + "/v2/bot/chat/loading/start", + params, + ); + return { httpResponse: res, body: await res.json() }; + } /** * Test webhook endpoint * @param testWebhookEndpointRequest diff --git a/lib/messaging-api/model/models.ts b/lib/messaging-api/model/models.ts index b52727b08..076133f4a 100644 --- a/lib/messaging-api/model/models.ts +++ b/lib/messaging-api/model/models.ts @@ -129,6 +129,7 @@ export * from "./roomUserProfileResponse.js"; export * from "./sender.js"; export * from "./sentMessage.js"; export * from "./setWebhookEndpointRequest.js"; +export * from "./showLoadingAnimationRequest.js"; export * from "./stickerMessage.js"; export * from "./subscribedMembershipPlan.js"; export * from "./subscribedMembershipUser.js"; diff --git a/lib/messaging-api/model/showLoadingAnimationRequest.ts b/lib/messaging-api/model/showLoadingAnimationRequest.ts new file mode 100644 index 000000000..825cc9ccf --- /dev/null +++ b/lib/messaging-api/model/showLoadingAnimationRequest.ts @@ -0,0 +1,26 @@ +/** + * LINE Messaging API + * This document describes LINE Messaging API. + * + * The version of the OpenAPI document: 0.0.1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +export type ShowLoadingAnimationRequest = { + /** + * User ID of the target user for whom the loading animation is to be displayed. + * + * @see <a href="https://developers.line.biz/en/reference/messaging-api/#display-a-loading-indicator-request-body">chatId Documentation</a> + */ + chatId: string /**/; + /** + * The number of seconds to display the loading indicator. It must be a multiple of 5. The maximum value is 60 seconds. + * + * @see <a href="https://developers.line.biz/en/reference/messaging-api/#display-a-loading-indicator-request-body">loadingSeconds Documentation</a> + */ + loadingSeconds?: number /**/; +}; diff --git a/lib/messaging-api/tests/api/MessagingApiClientTest.spec.ts b/lib/messaging-api/tests/api/MessagingApiClientTest.spec.ts index 256d81eca..6954fb0cb 100644 --- a/lib/messaging-api/tests/api/MessagingApiClientTest.spec.ts +++ b/lib/messaging-api/tests/api/MessagingApiClientTest.spec.ts @@ -41,6 +41,7 @@ import { RichMenuResponse } from "../../model/richMenuResponse.js"; import { RoomMemberCountResponse } from "../../model/roomMemberCountResponse.js"; import { RoomUserProfileResponse } from "../../model/roomUserProfileResponse.js"; import { SetWebhookEndpointRequest } from "../../model/setWebhookEndpointRequest.js"; +import { ShowLoadingAnimationRequest } from "../../model/showLoadingAnimationRequest.js"; import { TestWebhookEndpointRequest } from "../../model/testWebhookEndpointRequest.js"; import { TestWebhookEndpointResponse } from "../../model/testWebhookEndpointResponse.js"; import { UpdateRichMenuAliasRequest } from "../../model/updateRichMenuAliasRequest.js"; @@ -5057,6 +5058,92 @@ describe("MessagingApiClient", () => { server.close(); }); + it("showLoadingAnimationWithHttpInfo", async () => { + let requestCount = 0; + + const server = createServer((req, res) => { + requestCount++; + + equal(req.method, "POST"); + const reqUrl = new URL(req.url, "http://localhost/"); + equal(reqUrl.pathname, "/v2/bot/chat/loading/start"); + + equal(req.headers["authorization"], `Bearer ${channel_access_token}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); + + res.writeHead(200, { "Content-Type": "application/json" }); + res.end(JSON.stringify({})); + }); + await new Promise(resolve => { + server.listen(0); + server.on("listening", resolve); + }); + + const serverAddress = server.address(); + if (typeof serverAddress === "string" || serverAddress === null) { + throw new Error("Unexpected server address: " + serverAddress); + } + + const client = new MessagingApiClient({ + channelAccessToken: channel_access_token, + baseURL: `http://localhost:${String(serverAddress.port)}/`, + }); + + const res = await client.showLoadingAnimationWithHttpInfo( + // showLoadingAnimationRequest: ShowLoadingAnimationRequest + {} as unknown as ShowLoadingAnimationRequest, // paramName=showLoadingAnimationRequest + ); + + equal(requestCount, 1); + server.close(); + }); + + it("showLoadingAnimation", async () => { + let requestCount = 0; + + const server = createServer((req, res) => { + requestCount++; + + equal(req.method, "POST"); + const reqUrl = new URL(req.url, "http://localhost/"); + equal(reqUrl.pathname, "/v2/bot/chat/loading/start"); + + equal(req.headers["authorization"], `Bearer ${channel_access_token}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); + + res.writeHead(200, { "Content-Type": "application/json" }); + res.end(JSON.stringify({})); + }); + await new Promise(resolve => { + server.listen(0); + server.on("listening", resolve); + }); + + const serverAddress = server.address(); + if (typeof serverAddress === "string" || serverAddress === null) { + throw new Error("Unexpected server address: " + serverAddress); + } + + const client = new MessagingApiClient({ + channelAccessToken: channel_access_token, + baseURL: `http://localhost:${String(serverAddress.port)}/`, + }); + + const res = await client.showLoadingAnimation( + // showLoadingAnimationRequest: ShowLoadingAnimationRequest + {} as unknown as ShowLoadingAnimationRequest, // paramName=showLoadingAnimationRequest + ); + + equal(requestCount, 1); + server.close(); + }); + it("testWebhookEndpointWithHttpInfo", async () => { let requestCount = 0; diff --git a/line-openapi b/line-openapi index 1ca46400a..f9859923b 160000 --- a/line-openapi +++ b/line-openapi @@ -1 +1 @@ -Subproject commit 1ca46400ade898510d5bb38018952143757891bb +Subproject commit f9859923b5dc9f8179a018243a756b0fe4669cd3