Skip to content

Commit

Permalink
Codes are generated by openapi (#821)
Browse files Browse the repository at this point in the history
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 <github-actions@github.com>
  • Loading branch information
github-actions[bot] and github-actions authored Apr 17, 2024
1 parent 17c048b commit ed4a8d0
Show file tree
Hide file tree
Showing 6 changed files with 149 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/messaging-api/.openapi-generator/FILES
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
33 changes: 33 additions & 0 deletions lib/messaging-api/api/messagingApiClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions lib/messaging-api/model/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
26 changes: 26 additions & 0 deletions lib/messaging-api/model/showLoadingAnimationRequest.ts
Original file line number Diff line number Diff line change
@@ -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 /**/;
};
87 changes: 87 additions & 0 deletions lib/messaging-api/tests/api/MessagingApiClientTest.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion line-openapi
Submodule line-openapi updated 1 files
+50 −0 messaging-api.yml

0 comments on commit ed4a8d0

Please sign in to comment.