UNPKG

@line/bot-sdk

Version:
1,091 lines (1,090 loc) 76.1 kB
"use strict"; /** * 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. */ Object.defineProperty(exports, "__esModule", { value: true }); exports.MessagingApiClient = void 0; const Types = require("../../types.js"); const http_fetch_js_1 = require("../../http-fetch.js"); class MessagingApiClient { constructor(config) { const baseURL = config.baseURL || "https://api.line.me"; this.httpClient = new http_fetch_js_1.default({ defaultHeaders: { Authorization: "Bearer " + config.channelAccessToken, }, baseURL: baseURL, }); } async parseHTTPResponse(response) { const { LINE_REQUEST_ID_HTTP_HEADER_NAME } = Types; let resBody = Object.assign({}, (await response.json())); if (response.headers.get(LINE_REQUEST_ID_HTTP_HEADER_NAME)) { resBody[LINE_REQUEST_ID_HTTP_HEADER_NAME] = response.headers.get(LINE_REQUEST_ID_HTTP_HEADER_NAME); } return resBody; } /** * Send a message using phone number * @param audienceMatchMessagesRequest * * @see <a href="https://developers.line.biz/en/reference/partner-docs/#phone-audience-match"> Documentation</a> */ async audienceMatch(audienceMatchMessagesRequest) { return (await this.audienceMatchWithHttpInfo(audienceMatchMessagesRequest)) .body; } /** * Send a message using phone number. * This method includes HttpInfo object to return additional information. * @param audienceMatchMessagesRequest * * @see <a href="https://developers.line.biz/en/reference/partner-docs/#phone-audience-match"> Documentation</a> */ async audienceMatchWithHttpInfo(audienceMatchMessagesRequest) { const params = audienceMatchMessagesRequest; const res = await this.httpClient.post("/bot/ad/multicast/phone", params); const text = await res.text(); const parsedBody = text ? JSON.parse(text) : null; return { httpResponse: res, body: parsedBody }; } /** * Sends a message to multiple users at any time. * @param broadcastRequest * @param xLineRetryKey Retry key. Specifies the UUID in hexadecimal format (e.g., `123e4567-e89b-12d3-a456-426614174000`) generated by any method. The retry key isn\'t generated by LINE. Each developer must generate their own retry key. * * @see <a href="https://developers.line.biz/en/reference/messaging-api/#send-broadcast-message"> Documentation</a> */ async broadcast(broadcastRequest, xLineRetryKey) { return (await this.broadcastWithHttpInfo(broadcastRequest, xLineRetryKey)) .body; } /** * Sends a message to multiple users at any time.. * This method includes HttpInfo object to return additional information. * @param broadcastRequest * @param xLineRetryKey Retry key. Specifies the UUID in hexadecimal format (e.g., `123e4567-e89b-12d3-a456-426614174000`) generated by any method. The retry key isn\'t generated by LINE. Each developer must generate their own retry key. * * @see <a href="https://developers.line.biz/en/reference/messaging-api/#send-broadcast-message"> Documentation</a> */ async broadcastWithHttpInfo(broadcastRequest, xLineRetryKey) { const params = broadcastRequest; const headerParams = Object.assign({}, (xLineRetryKey != null ? { "X-Line-Retry-Key": xLineRetryKey } : {})); const res = await this.httpClient.post("/v2/bot/message/broadcast", params, { headers: headerParams }); const text = await res.text(); const parsedBody = text ? JSON.parse(text) : null; return { httpResponse: res, body: parsedBody }; } /** * Cancel default rich menu * * @see <a href="https://developers.line.biz/en/reference/messaging-api/#cancel-default-rich-menu"> Documentation</a> */ async cancelDefaultRichMenu() { return (await this.cancelDefaultRichMenuWithHttpInfo()).body; } /** * Cancel default rich menu. * This method includes HttpInfo object to return additional information. * * @see <a href="https://developers.line.biz/en/reference/messaging-api/#cancel-default-rich-menu"> Documentation</a> */ async cancelDefaultRichMenuWithHttpInfo() { const res = await this.httpClient.delete("/v2/bot/user/all/richmenu"); const text = await res.text(); const parsedBody = text ? JSON.parse(text) : null; return { httpResponse: res, body: parsedBody }; } /** * Create rich menu * @param richMenuRequest * * @see <a href="https://developers.line.biz/en/reference/messaging-api/#create-rich-menu"> Documentation</a> */ async createRichMenu(richMenuRequest) { return (await this.createRichMenuWithHttpInfo(richMenuRequest)).body; } /** * Create rich menu. * This method includes HttpInfo object to return additional information. * @param richMenuRequest * * @see <a href="https://developers.line.biz/en/reference/messaging-api/#create-rich-menu"> Documentation</a> */ async createRichMenuWithHttpInfo(richMenuRequest) { const params = richMenuRequest; const res = await this.httpClient.post("/v2/bot/richmenu", params); const text = await res.text(); const parsedBody = text ? JSON.parse(text) : null; return { httpResponse: res, body: parsedBody }; } /** * Create rich menu alias * @param createRichMenuAliasRequest * * @see <a href="https://developers.line.biz/en/reference/messaging-api/#create-rich-menu-alias"> Documentation</a> */ async createRichMenuAlias(createRichMenuAliasRequest) { return (await this.createRichMenuAliasWithHttpInfo(createRichMenuAliasRequest)).body; } /** * Create rich menu alias. * This method includes HttpInfo object to return additional information. * @param createRichMenuAliasRequest * * @see <a href="https://developers.line.biz/en/reference/messaging-api/#create-rich-menu-alias"> Documentation</a> */ async createRichMenuAliasWithHttpInfo(createRichMenuAliasRequest) { const params = createRichMenuAliasRequest; const res = await this.httpClient.post("/v2/bot/richmenu/alias", params); const text = await res.text(); const parsedBody = text ? JSON.parse(text) : null; return { httpResponse: res, body: parsedBody }; } /** * Deletes a rich menu. * @param richMenuId ID of a rich menu * * @see <a href="https://developers.line.biz/en/reference/messaging-api/#delete-rich-menu"> Documentation</a> */ async deleteRichMenu(richMenuId) { return (await this.deleteRichMenuWithHttpInfo(richMenuId)).body; } /** * Deletes a rich menu.. * This method includes HttpInfo object to return additional information. * @param richMenuId ID of a rich menu * * @see <a href="https://developers.line.biz/en/reference/messaging-api/#delete-rich-menu"> Documentation</a> */ async deleteRichMenuWithHttpInfo(richMenuId) { const res = await this.httpClient.delete("/v2/bot/richmenu/{richMenuId}".replace("{richMenuId}", String(richMenuId))); const text = await res.text(); const parsedBody = text ? JSON.parse(text) : null; return { httpResponse: res, body: parsedBody }; } /** * Delete rich menu alias * @param richMenuAliasId Rich menu alias ID that you want to delete. * * @see <a href="https://developers.line.biz/en/reference/messaging-api/#delete-rich-menu-alias"> Documentation</a> */ async deleteRichMenuAlias(richMenuAliasId) { return (await this.deleteRichMenuAliasWithHttpInfo(richMenuAliasId)).body; } /** * Delete rich menu alias. * This method includes HttpInfo object to return additional information. * @param richMenuAliasId Rich menu alias ID that you want to delete. * * @see <a href="https://developers.line.biz/en/reference/messaging-api/#delete-rich-menu-alias"> Documentation</a> */ async deleteRichMenuAliasWithHttpInfo(richMenuAliasId) { const res = await this.httpClient.delete("/v2/bot/richmenu/alias/{richMenuAliasId}".replace("{richMenuAliasId}", String(richMenuAliasId))); const text = await res.text(); const parsedBody = text ? JSON.parse(text) : null; return { httpResponse: res, body: parsedBody }; } /** * Get result of message delivery using phone number * @param date Date the message was sent Format: `yyyyMMdd` (e.g. `20190831`) Time Zone: UTC+9 * * @see <a href="https://developers.line.biz/en/reference/partner-docs/#get-phone-audience-match"> Documentation</a> */ async getAdPhoneMessageStatistics(date) { return (await this.getAdPhoneMessageStatisticsWithHttpInfo(date)).body; } /** * Get result of message delivery using phone number. * This method includes HttpInfo object to return additional information. * @param date Date the message was sent Format: `yyyyMMdd` (e.g. `20190831`) Time Zone: UTC+9 * * @see <a href="https://developers.line.biz/en/reference/partner-docs/#get-phone-audience-match"> Documentation</a> */ async getAdPhoneMessageStatisticsWithHttpInfo(date) { const queryParams = { date: date, }; Object.keys(queryParams).forEach((key) => { if (queryParams[key] === undefined) { delete queryParams[key]; } }); const res = await this.httpClient.get("/v2/bot/message/delivery/ad_phone", queryParams); const text = await res.text(); const parsedBody = text ? JSON.parse(text) : null; return { httpResponse: res, body: parsedBody }; } /** * Get name list of units used this month * @param limit The maximum number of aggregation units you can get per request. * @param start Value of the continuation token found in the next property of the JSON object returned in the response. If you can\'t get all the aggregation units in one request, include this parameter to get the remaining array. * * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-name-list-of-units-used-this-month"> Documentation</a> */ async getAggregationUnitNameList(limit, start) { return (await this.getAggregationUnitNameListWithHttpInfo(limit, start)) .body; } /** * Get name list of units used this month. * This method includes HttpInfo object to return additional information. * @param limit The maximum number of aggregation units you can get per request. * @param start Value of the continuation token found in the next property of the JSON object returned in the response. If you can\'t get all the aggregation units in one request, include this parameter to get the remaining array. * * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-name-list-of-units-used-this-month"> Documentation</a> */ async getAggregationUnitNameListWithHttpInfo(limit, start) { const queryParams = { limit: limit, start: start, }; Object.keys(queryParams).forEach((key) => { if (queryParams[key] === undefined) { delete queryParams[key]; } }); const res = await this.httpClient.get("/v2/bot/message/aggregation/list", queryParams); const text = await res.text(); const parsedBody = text ? JSON.parse(text) : null; return { httpResponse: res, body: parsedBody }; } /** * Get number of units used this month * * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-number-of-units-used-this-month"> Documentation</a> */ async getAggregationUnitUsage() { return (await this.getAggregationUnitUsageWithHttpInfo()).body; } /** * Get number of units used this month. * This method includes HttpInfo object to return additional information. * * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-number-of-units-used-this-month"> Documentation</a> */ async getAggregationUnitUsageWithHttpInfo() { const res = await this.httpClient.get("/v2/bot/message/aggregation/info"); const text = await res.text(); const parsedBody = text ? JSON.parse(text) : null; return { httpResponse: res, body: parsedBody }; } /** * Get bot info * * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-bot-info"> Documentation</a> */ async getBotInfo() { return (await this.getBotInfoWithHttpInfo()).body; } /** * Get bot info. * This method includes HttpInfo object to return additional information. * * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-bot-info"> Documentation</a> */ async getBotInfoWithHttpInfo() { const res = await this.httpClient.get("/v2/bot/info"); const text = await res.text(); const parsedBody = text ? JSON.parse(text) : null; return { httpResponse: res, body: parsedBody }; } /** * Gets the ID of the default rich menu set with the Messaging API. * * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-default-rich-menu-id"> Documentation</a> */ async getDefaultRichMenuId() { return (await this.getDefaultRichMenuIdWithHttpInfo()).body; } /** * Gets the ID of the default rich menu set with the Messaging API.. * This method includes HttpInfo object to return additional information. * * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-default-rich-menu-id"> Documentation</a> */ async getDefaultRichMenuIdWithHttpInfo() { const res = await this.httpClient.get("/v2/bot/user/all/richmenu"); const text = await res.text(); const parsedBody = text ? JSON.parse(text) : null; return { httpResponse: res, body: parsedBody }; } /** * Get a list of users who added your LINE Official Account as a friend * @param start Value of the continuation token found in the next property of the JSON object returned in the response. Include this parameter to get the next array of user IDs. * @param limit The maximum number of user IDs to retrieve in a single request. * * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-follower-ids"> Documentation</a> */ async getFollowers(start, limit) { return (await this.getFollowersWithHttpInfo(start, limit)).body; } /** * Get a list of users who added your LINE Official Account as a friend. * This method includes HttpInfo object to return additional information. * @param start Value of the continuation token found in the next property of the JSON object returned in the response. Include this parameter to get the next array of user IDs. * @param limit The maximum number of user IDs to retrieve in a single request. * * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-follower-ids"> Documentation</a> */ async getFollowersWithHttpInfo(start, limit) { const queryParams = { start: start, limit: limit, }; Object.keys(queryParams).forEach((key) => { if (queryParams[key] === undefined) { delete queryParams[key]; } }); const res = await this.httpClient.get("/v2/bot/followers/ids", queryParams); const text = await res.text(); const parsedBody = text ? JSON.parse(text) : null; return { httpResponse: res, body: parsedBody }; } /** * Get number of users in a group chat * @param groupId Group ID * * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-members-group-count"> Documentation</a> */ async getGroupMemberCount(groupId) { return (await this.getGroupMemberCountWithHttpInfo(groupId)).body; } /** * Get number of users in a group chat. * This method includes HttpInfo object to return additional information. * @param groupId Group ID * * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-members-group-count"> Documentation</a> */ async getGroupMemberCountWithHttpInfo(groupId) { const res = await this.httpClient.get("/v2/bot/group/{groupId}/members/count".replace("{groupId}", String(groupId))); const text = await res.text(); const parsedBody = text ? JSON.parse(text) : null; return { httpResponse: res, body: parsedBody }; } /** * Get group chat member profile * @param groupId Group ID * @param userId User ID * * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-group-member-profile"> Documentation</a> */ async getGroupMemberProfile(groupId, userId) { return (await this.getGroupMemberProfileWithHttpInfo(groupId, userId)).body; } /** * Get group chat member profile. * This method includes HttpInfo object to return additional information. * @param groupId Group ID * @param userId User ID * * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-group-member-profile"> Documentation</a> */ async getGroupMemberProfileWithHttpInfo(groupId, userId) { const res = await this.httpClient.get("/v2/bot/group/{groupId}/member/{userId}" .replace("{groupId}", String(groupId)) .replace("{userId}", String(userId))); const text = await res.text(); const parsedBody = text ? JSON.parse(text) : null; return { httpResponse: res, body: parsedBody }; } /** * Get group chat member user IDs * @param groupId Group ID * @param start Value of the continuation token found in the `next` property of the JSON object returned in the response. Include this parameter to get the next array of user IDs for the members of the group. * * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-group-member-user-ids"> Documentation</a> */ async getGroupMembersIds(groupId, start) { return (await this.getGroupMembersIdsWithHttpInfo(groupId, start)).body; } /** * Get group chat member user IDs. * This method includes HttpInfo object to return additional information. * @param groupId Group ID * @param start Value of the continuation token found in the `next` property of the JSON object returned in the response. Include this parameter to get the next array of user IDs for the members of the group. * * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-group-member-user-ids"> Documentation</a> */ async getGroupMembersIdsWithHttpInfo(groupId, start) { const queryParams = { start: start, }; Object.keys(queryParams).forEach((key) => { if (queryParams[key] === undefined) { delete queryParams[key]; } }); const res = await this.httpClient.get("/v2/bot/group/{groupId}/members/ids".replace("{groupId}", String(groupId)), queryParams); const text = await res.text(); const parsedBody = text ? JSON.parse(text) : null; return { httpResponse: res, body: parsedBody }; } /** * Get group chat summary * @param groupId Group ID * * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-group-summary"> Documentation</a> */ async getGroupSummary(groupId) { return (await this.getGroupSummaryWithHttpInfo(groupId)).body; } /** * Get group chat summary. * This method includes HttpInfo object to return additional information. * @param groupId Group ID * * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-group-summary"> Documentation</a> */ async getGroupSummaryWithHttpInfo(groupId) { const res = await this.httpClient.get("/v2/bot/group/{groupId}/summary".replace("{groupId}", String(groupId))); const text = await res.text(); const parsedBody = text ? JSON.parse(text) : null; return { httpResponse: res, body: parsedBody }; } /** * Get a list of memberships. * * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-membership-plans"> Documentation</a> */ async getMembershipList() { return (await this.getMembershipListWithHttpInfo()).body; } /** * Get a list of memberships.. * This method includes HttpInfo object to return additional information. * * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-membership-plans"> Documentation</a> */ async getMembershipListWithHttpInfo() { const res = await this.httpClient.get("/v2/bot/membership/list"); const text = await res.text(); const parsedBody = text ? JSON.parse(text) : null; return { httpResponse: res, body: parsedBody }; } /** * Get a user\'s membership subscription. * @param userId User ID * * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-a-users-membership-subscription-status"> Documentation</a> */ async getMembershipSubscription(userId) { return (await this.getMembershipSubscriptionWithHttpInfo(userId)).body; } /** * Get a user\'s membership subscription.. * This method includes HttpInfo object to return additional information. * @param userId User ID * * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-a-users-membership-subscription-status"> Documentation</a> */ async getMembershipSubscriptionWithHttpInfo(userId) { const res = await this.httpClient.get("/v2/bot/membership/subscription/{userId}".replace("{userId}", String(userId))); const text = await res.text(); const parsedBody = text ? JSON.parse(text) : null; return { httpResponse: res, body: parsedBody }; } /** * Gets the target limit for sending messages in the current month. The total number of the free messages and the additional messages is returned. * * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-quota"> Documentation</a> */ async getMessageQuota() { return (await this.getMessageQuotaWithHttpInfo()).body; } /** * Gets the target limit for sending messages in the current month. The total number of the free messages and the additional messages is returned.. * This method includes HttpInfo object to return additional information. * * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-quota"> Documentation</a> */ async getMessageQuotaWithHttpInfo() { const res = await this.httpClient.get("/v2/bot/message/quota"); const text = await res.text(); const parsedBody = text ? JSON.parse(text) : null; return { httpResponse: res, body: parsedBody }; } /** * Gets the number of messages sent in the current month. * * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-consumption"> Documentation</a> */ async getMessageQuotaConsumption() { return (await this.getMessageQuotaConsumptionWithHttpInfo()).body; } /** * Gets the number of messages sent in the current month.. * This method includes HttpInfo object to return additional information. * * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-consumption"> Documentation</a> */ async getMessageQuotaConsumptionWithHttpInfo() { const res = await this.httpClient.get("/v2/bot/message/quota/consumption"); const text = await res.text(); const parsedBody = text ? JSON.parse(text) : null; return { httpResponse: res, body: parsedBody }; } /** * Gets the status of a narrowcast message. * @param requestId The narrowcast message\'s request ID. Each Messaging API request has a request ID. * * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-narrowcast-progress-status"> Documentation</a> */ async getNarrowcastProgress(requestId) { return (await this.getNarrowcastProgressWithHttpInfo(requestId)).body; } /** * Gets the status of a narrowcast message.. * This method includes HttpInfo object to return additional information. * @param requestId The narrowcast message\'s request ID. Each Messaging API request has a request ID. * * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-narrowcast-progress-status"> Documentation</a> */ async getNarrowcastProgressWithHttpInfo(requestId) { const queryParams = { requestId: requestId, }; Object.keys(queryParams).forEach((key) => { if (queryParams[key] === undefined) { delete queryParams[key]; } }); const res = await this.httpClient.get("/v2/bot/message/progress/narrowcast", queryParams); const text = await res.text(); const parsedBody = text ? JSON.parse(text) : null; return { httpResponse: res, body: parsedBody }; } /** * Get number of sent broadcast messages * @param date Date the messages were sent Format: yyyyMMdd (e.g. 20191231) Timezone: UTC+9 * * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-number-of-broadcast-messages"> Documentation</a> */ async getNumberOfSentBroadcastMessages(date) { return (await this.getNumberOfSentBroadcastMessagesWithHttpInfo(date)).body; } /** * Get number of sent broadcast messages. * This method includes HttpInfo object to return additional information. * @param date Date the messages were sent Format: yyyyMMdd (e.g. 20191231) Timezone: UTC+9 * * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-number-of-broadcast-messages"> Documentation</a> */ async getNumberOfSentBroadcastMessagesWithHttpInfo(date) { const queryParams = { date: date, }; Object.keys(queryParams).forEach((key) => { if (queryParams[key] === undefined) { delete queryParams[key]; } }); const res = await this.httpClient.get("/v2/bot/message/delivery/broadcast", queryParams); const text = await res.text(); const parsedBody = text ? JSON.parse(text) : null; return { httpResponse: res, body: parsedBody }; } /** * Get number of sent multicast messages * @param date Date the messages were sent Format: `yyyyMMdd` (e.g. `20191231`) Timezone: UTC+9 * * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-number-of-multicast-messages"> Documentation</a> */ async getNumberOfSentMulticastMessages(date) { return (await this.getNumberOfSentMulticastMessagesWithHttpInfo(date)).body; } /** * Get number of sent multicast messages. * This method includes HttpInfo object to return additional information. * @param date Date the messages were sent Format: `yyyyMMdd` (e.g. `20191231`) Timezone: UTC+9 * * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-number-of-multicast-messages"> Documentation</a> */ async getNumberOfSentMulticastMessagesWithHttpInfo(date) { const queryParams = { date: date, }; Object.keys(queryParams).forEach((key) => { if (queryParams[key] === undefined) { delete queryParams[key]; } }); const res = await this.httpClient.get("/v2/bot/message/delivery/multicast", queryParams); const text = await res.text(); const parsedBody = text ? JSON.parse(text) : null; return { httpResponse: res, body: parsedBody }; } /** * Get number of sent push messages * @param date Date the messages were sent Format: `yyyyMMdd` (e.g. `20191231`) Timezone: UTC+9 * * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-number-of-push-messages"> Documentation</a> */ async getNumberOfSentPushMessages(date) { return (await this.getNumberOfSentPushMessagesWithHttpInfo(date)).body; } /** * Get number of sent push messages. * This method includes HttpInfo object to return additional information. * @param date Date the messages were sent Format: `yyyyMMdd` (e.g. `20191231`) Timezone: UTC+9 * * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-number-of-push-messages"> Documentation</a> */ async getNumberOfSentPushMessagesWithHttpInfo(date) { const queryParams = { date: date, }; Object.keys(queryParams).forEach((key) => { if (queryParams[key] === undefined) { delete queryParams[key]; } }); const res = await this.httpClient.get("/v2/bot/message/delivery/push", queryParams); const text = await res.text(); const parsedBody = text ? JSON.parse(text) : null; return { httpResponse: res, body: parsedBody }; } /** * Get number of sent reply messages * @param date Date the messages were sent Format: `yyyyMMdd` (e.g. `20191231`) Timezone: UTC+9 * * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-number-of-reply-messages"> Documentation</a> */ async getNumberOfSentReplyMessages(date) { return (await this.getNumberOfSentReplyMessagesWithHttpInfo(date)).body; } /** * Get number of sent reply messages. * This method includes HttpInfo object to return additional information. * @param date Date the messages were sent Format: `yyyyMMdd` (e.g. `20191231`) Timezone: UTC+9 * * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-number-of-reply-messages"> Documentation</a> */ async getNumberOfSentReplyMessagesWithHttpInfo(date) { const queryParams = { date: date, }; Object.keys(queryParams).forEach((key) => { if (queryParams[key] === undefined) { delete queryParams[key]; } }); const res = await this.httpClient.get("/v2/bot/message/delivery/reply", queryParams); const text = await res.text(); const parsedBody = text ? JSON.parse(text) : null; return { httpResponse: res, body: parsedBody }; } /** * Get number of sent LINE notification messages * @param date Date the message was sent Format: `yyyyMMdd` (Example:`20211231`) Time zone: UTC+9 * * @see <a href="https://developers.line.biz/en/reference/partner-docs/#get-number-of-sent-line-notification-messages"> Documentation</a> */ async getPNPMessageStatistics(date) { return (await this.getPNPMessageStatisticsWithHttpInfo(date)).body; } /** * Get number of sent LINE notification messages . * This method includes HttpInfo object to return additional information. * @param date Date the message was sent Format: `yyyyMMdd` (Example:`20211231`) Time zone: UTC+9 * * @see <a href="https://developers.line.biz/en/reference/partner-docs/#get-number-of-sent-line-notification-messages"> Documentation</a> */ async getPNPMessageStatisticsWithHttpInfo(date) { const queryParams = { date: date, }; Object.keys(queryParams).forEach((key) => { if (queryParams[key] === undefined) { delete queryParams[key]; } }); const res = await this.httpClient.get("/v2/bot/message/delivery/pnp", queryParams); const text = await res.text(); const parsedBody = text ? JSON.parse(text) : null; return { httpResponse: res, body: parsedBody }; } /** * Get profile * @param userId User ID * * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-profile"> Documentation</a> */ async getProfile(userId) { return (await this.getProfileWithHttpInfo(userId)).body; } /** * Get profile. * This method includes HttpInfo object to return additional information. * @param userId User ID * * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-profile"> Documentation</a> */ async getProfileWithHttpInfo(userId) { const res = await this.httpClient.get("/v2/bot/profile/{userId}".replace("{userId}", String(userId))); const text = await res.text(); const parsedBody = text ? JSON.parse(text) : null; return { httpResponse: res, body: parsedBody }; } /** * Gets a rich menu via a rich menu ID. * @param richMenuId ID of a rich menu * * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-rich-menu"> Documentation</a> */ async getRichMenu(richMenuId) { return (await this.getRichMenuWithHttpInfo(richMenuId)).body; } /** * Gets a rich menu via a rich menu ID.. * This method includes HttpInfo object to return additional information. * @param richMenuId ID of a rich menu * * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-rich-menu"> Documentation</a> */ async getRichMenuWithHttpInfo(richMenuId) { const res = await this.httpClient.get("/v2/bot/richmenu/{richMenuId}".replace("{richMenuId}", String(richMenuId))); const text = await res.text(); const parsedBody = text ? JSON.parse(text) : null; return { httpResponse: res, body: parsedBody }; } /** * Get rich menu alias information * @param richMenuAliasId The rich menu alias ID whose information you want to obtain. * * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-rich-menu-alias-by-id"> Documentation</a> */ async getRichMenuAlias(richMenuAliasId) { return (await this.getRichMenuAliasWithHttpInfo(richMenuAliasId)).body; } /** * Get rich menu alias information. * This method includes HttpInfo object to return additional information. * @param richMenuAliasId The rich menu alias ID whose information you want to obtain. * * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-rich-menu-alias-by-id"> Documentation</a> */ async getRichMenuAliasWithHttpInfo(richMenuAliasId) { const res = await this.httpClient.get("/v2/bot/richmenu/alias/{richMenuAliasId}".replace("{richMenuAliasId}", String(richMenuAliasId))); const text = await res.text(); const parsedBody = text ? JSON.parse(text) : null; return { httpResponse: res, body: parsedBody }; } /** * Get list of rich menu alias * * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-rich-menu-alias-list"> Documentation</a> */ async getRichMenuAliasList() { return (await this.getRichMenuAliasListWithHttpInfo()).body; } /** * Get list of rich menu alias. * This method includes HttpInfo object to return additional information. * * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-rich-menu-alias-list"> Documentation</a> */ async getRichMenuAliasListWithHttpInfo() { const res = await this.httpClient.get("/v2/bot/richmenu/alias/list"); const text = await res.text(); const parsedBody = text ? JSON.parse(text) : null; return { httpResponse: res, body: parsedBody }; } /** * Get the status of Replace or unlink a linked rich menus in batches. * @param requestId A request ID used to batch control the rich menu linked to the user. Each Messaging API request has a request ID. * * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-batch-control-rich-menus-progress-status"> Documentation</a> */ async getRichMenuBatchProgress(requestId) { return (await this.getRichMenuBatchProgressWithHttpInfo(requestId)).body; } /** * Get the status of Replace or unlink a linked rich menus in batches.. * This method includes HttpInfo object to return additional information. * @param requestId A request ID used to batch control the rich menu linked to the user. Each Messaging API request has a request ID. * * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-batch-control-rich-menus-progress-status"> Documentation</a> */ async getRichMenuBatchProgressWithHttpInfo(requestId) { const queryParams = { requestId: requestId, }; Object.keys(queryParams).forEach((key) => { if (queryParams[key] === undefined) { delete queryParams[key]; } }); const res = await this.httpClient.get("/v2/bot/richmenu/progress/batch", queryParams); const text = await res.text(); const parsedBody = text ? JSON.parse(text) : null; return { httpResponse: res, body: parsedBody }; } /** * Get rich menu ID of user * @param userId User ID. Found in the `source` object of webhook event objects. Do not use the LINE ID used in LINE. * * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-rich-menu-id-of-user"> Documentation</a> */ async getRichMenuIdOfUser(userId) { return (await this.getRichMenuIdOfUserWithHttpInfo(userId)).body; } /** * Get rich menu ID of user. * This method includes HttpInfo object to return additional information. * @param userId User ID. Found in the `source` object of webhook event objects. Do not use the LINE ID used in LINE. * * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-rich-menu-id-of-user"> Documentation</a> */ async getRichMenuIdOfUserWithHttpInfo(userId) { const res = await this.httpClient.get("/v2/bot/user/{userId}/richmenu".replace("{userId}", String(userId))); const text = await res.text(); const parsedBody = text ? JSON.parse(text) : null; return { httpResponse: res, body: parsedBody }; } /** * Get rich menu list * * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-rich-menu-list"> Documentation</a> */ async getRichMenuList() { return (await this.getRichMenuListWithHttpInfo()).body; } /** * Get rich menu list. * This method includes HttpInfo object to return additional information. * * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-rich-menu-list"> Documentation</a> */ async getRichMenuListWithHttpInfo() { const res = await this.httpClient.get("/v2/bot/richmenu/list"); const text = await res.text(); const parsedBody = text ? JSON.parse(text) : null; return { httpResponse: res, body: parsedBody }; } /** * Get number of users in a multi-person chat * @param roomId Room ID * * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-members-room-count"> Documentation</a> */ async getRoomMemberCount(roomId) { return (await this.getRoomMemberCountWithHttpInfo(roomId)).body; } /** * Get number of users in a multi-person chat. * This method includes HttpInfo object to return additional information. * @param roomId Room ID * * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-members-room-count"> Documentation</a> */ async getRoomMemberCountWithHttpInfo(roomId) { const res = await this.httpClient.get("/v2/bot/room/{roomId}/members/count".replace("{roomId}", String(roomId))); const text = await res.text(); const parsedBody = text ? JSON.parse(text) : null; return { httpResponse: res, body: parsedBody }; } /** * Get multi-person chat member profile * @param roomId Room ID * @param userId User ID * * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-room-member-profile"> Documentation</a> */ async getRoomMemberProfile(roomId, userId) { return (await this.getRoomMemberProfileWithHttpInfo(roomId, userId)).body; } /** * Get multi-person chat member profile. * This method includes HttpInfo object to return additional information. * @param roomId Room ID * @param userId User ID * * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-room-member-profile"> Documentation</a> */ async getRoomMemberProfileWithHttpInfo(roomId, userId) { const res = await this.httpClient.get("/v2/bot/room/{roomId}/member/{userId}" .replace("{roomId}", String(roomId)) .replace("{userId}", String(userId))); const text = await res.text(); const parsedBody = text ? JSON.parse(text) : null; return { httpResponse: res, body: parsedBody }; } /** * Get multi-person chat member user IDs * @param roomId Room ID * @param start Value of the continuation token found in the `next` property of the JSON object returned in the response. Include this parameter to get the next array of user IDs for the members of the group. * * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-room-member-user-ids"> Documentation</a> */ async getRoomMembersIds(roomId, start) { return (await this.getRoomMembersIdsWithHttpInfo(roomId, start)).body; } /** * Get multi-person chat member user IDs. * This method includes HttpInfo object to return additional information. * @param roomId Room ID * @param start Value of the continuation token found in the `next` property of the JSON object returned in the response. Include this parameter to get the next array of user IDs for the members of the group. * * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-room-member-user-ids"> Documentation</a> */ async getRoomMembersIdsWithHttpInfo(roomId, start) { const queryParams = { start: start, }; Object.keys(queryParams).forEach((key) => { if (queryParams[key] === undefined) { delete queryParams[key]; } }); const res = await this.httpClient.get("/v2/bot/room/{roomId}/members/ids".replace("{roomId}", String(roomId)), queryParams); const text = await res.text(); const parsedBody = text ? JSON.parse(text) : null; return { httpResponse: res, body: parsedBody }; } /** * Get webhook endpoint information * * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-webhook-endpoint-information"> Documentation</a> */ async getWebhookEndpoint() { return (await this.getWebhookEndpointWithHttpInfo()).body; } /** * Get webhook endpoint information. * This method includes HttpInfo object to return additional information. * * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-webhook-endpoint-information"> Documentation</a> */ async getWebhookEndpointWithHttpInfo() { const res = await this.httpClient.get("/v2/bot/channel/webhook/endpoint"); const text = await res.text(); const parsedBody = text ? JSON.parse(text) : null; return { httpResponse: res, body: parsedBody }; } /** * Issue link token * @param userId User ID for the LINE account to be linked. Found in the `source` object of account link event objects. Do not use the LINE ID used in LINE. * * @see <a href="https://developers.line.biz/en/reference/messaging-api/#issue-link-token"> Documentation</a> */ async issueLinkToken(userId) { return (await this.issueLinkTokenWithHttpInfo(userId)).body; } /** * Issue link token. * This method includes HttpInfo object to return additional information. * @param userId User ID for the LINE account to be linked. Found in the `source` object of account link event objects. Do not use the LINE ID used in LINE. * * @see <a href="https://developers.line.biz/en/reference/messaging-api/#issue-link-token"> Documentation</a> */ async issueLinkTokenWithHttpInfo(userId) { const res = await this.httpClient.post("/v2/bot/user/{userId}/linkToken".replace("{userId}", String(userId))); const text = await res.text(); const parsedBody = text ? JSON.parse(text) : null; return { httpResponse: res, body: parsedBody }; } /** * Leave group chat * @param groupId Group ID * * @see <a href="https://developers.line.biz/en/reference/messaging-api/#leave-group"> Documentation</a> */ async leaveGroup(groupId) { return (await this.leaveGroupWithHttpInfo(groupId)).body; } /** * Leave group chat. * This method includes HttpInfo object to return additional information. * @param groupId Group ID * * @see <a href="https://developers.line.biz/en/reference/messaging-api/#leave-group"> Documentation</a> */ async leaveGroupWithHttpInfo(groupId) { const res = await this.httpClient.post("/v2/bot/group/{groupId}/leave".replace("{groupId}", String(groupId))); const text = await res.text(); const parsedBody = text ? JSON.parse(text) : null; return { httpResponse: res, body: parsedBody }; } /** * Leave multi-person chat * @param roomId Room ID * * @see <a href="https://developers.line.biz/en/reference/messaging-api/#leave-room"> Documentation</a> */ async leaveRoom(roomId) { return (await this.leaveRoomWithHttpInfo(roomId)).body; } /** * Leave multi-person chat. * This method includes HttpInfo object to return additional information. * @param roomId Room ID * * @see <a href="https://developers.line.biz/en/reference/messaging-api/#leave-room"> Documentation</a> */ async leaveRoomWithHttpInfo(roomId) { const res = await this.httpClient.post("/v2/bot/room/{roomId}/leave".replace("{roomId}", String(roomId))); const text = await res.text(); const parsedBody = text ? JSON.parse(text) : null; return { httpResponse: res, body: parsedBody }; } /** * Link rich menu to user. * @param userId User ID. Found in the `source` object of webhook event objects. Do not use the LINE ID used in LINE. * @param richMenuId ID of a rich menu * * @see <a href="https://developers.line.biz/en/reference/messaging-api/#link-rich-menu-to-user"> Documentation</a> */ async linkRichMenuIdToUser(userId, richMenuId) { return (await this.linkRichMenuIdToUserWithHttpInfo(userId, richMenuId)) .body; } /** * Link rich menu to user.. * This method includes HttpInfo object to return additional information. * @param userId User ID. Found in the `source` object of webhook event objects. Do not use the LINE ID used in LINE. * @param richMenuId ID of a rich menu * * @see <a href="https://developers.line.biz/en/reference/messaging-api/#link-rich-menu-to-user"> Documentation</a> */ async linkRichMenuIdToUserWithHttpInfo(userId, richMenuId) { const res = await this.httpClient.post("/v2/bot/user/{userId}/richmenu/{richMenuId}" .replace("{userId}", String(userId)) .replace("{richMenuId}", String(richMenuId))); const text = await res.text(); const parsedBody = text ? JSON.parse(text) : null; return { httpResponse: res, body: parsedBody }; } /** * Link rich menu to multiple users * @param richMenuBulkLinkRequest * * @see <a href="https://developers.line.biz/en/reference/messaging-api/#link-rich-menu-to-users"> Documentation</a> */ async linkRichMenuIdToUsers(richMenuBulkLinkRequest) { return (await this.linkRichMenuIdToUsersWithHttpInfo(richMenuBulkLinkRequest)).body; } /** * Link rich menu to multiple users. * This method includes HttpInfo object to return additional information. * @param richMenuBulkLinkRequest * * @see <a href="https://developers.line.biz/en/reference/messaging-api/#link-rich-menu-to-users"> Documentation</a> */ async linkRichMenuIdToUsersWithHttpInfo(richMenuBulkLinkRequest) { const params = richMenuBulkLinkRequest; const res = await this.httpClient.post("/v2/bot/richmenu/bulk/link", params); const text = await res.text(); const parsedBody = text ? JSON.parse(text) : null; return { httpResponse: res, body: parsedBody }; }