UNPKG

@line/bot-sdk

Version:
905 lines 111 kB
/** * 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. */ import { buildPath } from "../../utils.js"; import HTTPFetchClient, { mergeHeaders, } from "../../http-fetch.js"; /** * @see {@link LineBotClient} for a unified interface that wraps this client. */ export class MessagingApiClient { httpClient; /** * Initializes a new `MessagingApiClient`. * * @param config Configuration for this API client. * @param config.baseURL The base URL for requests. Defaults to `https://api.line.me`. * @param config.channelAccessToken The channel access token used for authorization. * @param config.defaultHeaders Extra headers merged into every request. * * @example * const client = new MessagingApiClient({ * channelAccessToken: process.env.LINE_CHANNEL_ACCESS_TOKEN!, * }); */ constructor(config) { const baseURL = config.baseURL || "https://api.line.me"; const defaultHeaders = mergeHeaders(config.defaultHeaders, { Authorization: "Bearer " + config.channelAccessToken, }); this.httpClient = new HTTPFetchClient({ defaultHeaders: defaultHeaders, baseURL: baseURL, }); } /** * Sends a message to multiple users at any time. * Calls `POST https://api.line.me/v2/bot/message/broadcast`. * To inspect the HTTP status code or response headers, use {@link broadcastWithHttpInfo}. * @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. * @returns A promise resolving to the response body. * @see <a href="https://developers.line.biz/en/reference/messaging-api/#send-broadcast-message">LINE Developers documentation</a> */ async broadcast(broadcastRequest, xLineRetryKey) { return (await this.broadcastWithHttpInfo(broadcastRequest, xLineRetryKey)) .body; } /** * Sends a message to multiple users at any time. * Calls `POST https://api.line.me/v2/bot/message/broadcast`. * This method returns the response body together with the underlying `httpResponse`. * @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. * @returns A promise resolving to the response body together with the underlying `httpResponse`. * @see <a href="https://developers.line.biz/en/reference/messaging-api/#send-broadcast-message">LINE Developers documentation</a> */ async broadcastWithHttpInfo(broadcastRequest, xLineRetryKey) { const params = broadcastRequest; const headerParams = { ...(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 * Calls `DELETE https://api.line.me/v2/bot/user/all/richmenu`. * To inspect the HTTP status code or response headers, use {@link cancelDefaultRichMenuWithHttpInfo}. * @returns A promise resolving to the response body. * @see <a href="https://developers.line.biz/en/reference/messaging-api/#cancel-default-rich-menu">LINE Developers documentation</a> */ async cancelDefaultRichMenu() { return (await this.cancelDefaultRichMenuWithHttpInfo()).body; } /** * Cancel default rich menu * Calls `DELETE https://api.line.me/v2/bot/user/all/richmenu`. * This method returns the response body together with the underlying `httpResponse`. * @returns A promise resolving to the response body together with the underlying `httpResponse`. * @see <a href="https://developers.line.biz/en/reference/messaging-api/#cancel-default-rich-menu">LINE Developers 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 }; } /** * Close coupon * Calls `PUT https://api.line.me/v2/bot/coupon/{couponId}/close`. * To inspect the HTTP status code or response headers, use {@link closeCouponWithHttpInfo}. * @param couponId * @returns A promise resolving to the response body. * @see <a href="https://developers.line.biz/en/reference/messaging-api/#discontinue-coupon">LINE Developers documentation</a> */ async closeCoupon(couponId) { return (await this.closeCouponWithHttpInfo(couponId)).body; } /** * Close coupon * Calls `PUT https://api.line.me/v2/bot/coupon/{couponId}/close`. * This method returns the response body together with the underlying `httpResponse`. * @param couponId * @returns A promise resolving to the response body together with the underlying `httpResponse`. * @see <a href="https://developers.line.biz/en/reference/messaging-api/#discontinue-coupon">LINE Developers documentation</a> */ async closeCouponWithHttpInfo(couponId) { const requestPath = buildPath("/v2/bot/coupon/{couponId}/close", { couponId: couponId, }); const res = await this.httpClient.put(requestPath); const text = await res.text(); const parsedBody = text ? JSON.parse(text) : null; return { httpResponse: res, body: parsedBody }; } /** * Create a new coupon. Define coupon details such as type, title, and validity period. * Calls `POST https://api.line.me/v2/bot/coupon`. * To inspect the HTTP status code or response headers, use {@link createCouponWithHttpInfo}. * @param couponCreateRequest * @returns A promise resolving to the response body. * @see <a href="https://developers.line.biz/en/reference/messaging-api/#create-coupon">LINE Developers documentation</a> */ async createCoupon(couponCreateRequest) { return (await this.createCouponWithHttpInfo(couponCreateRequest)).body; } /** * Create a new coupon. Define coupon details such as type, title, and validity period. * Calls `POST https://api.line.me/v2/bot/coupon`. * This method returns the response body together with the underlying `httpResponse`. * @param couponCreateRequest * @returns A promise resolving to the response body together with the underlying `httpResponse`. * @see <a href="https://developers.line.biz/en/reference/messaging-api/#create-coupon">LINE Developers documentation</a> */ async createCouponWithHttpInfo(couponCreateRequest) { const params = couponCreateRequest; const res = await this.httpClient.post("/v2/bot/coupon", params); const text = await res.text(); const parsedBody = text ? JSON.parse(text) : null; return { httpResponse: res, body: parsedBody }; } /** * Create rich menu * Calls `POST https://api.line.me/v2/bot/richmenu`. * To inspect the HTTP status code or response headers, use {@link createRichMenuWithHttpInfo}. * @param richMenuRequest * @returns A promise resolving to the response body. * @see <a href="https://developers.line.biz/en/reference/messaging-api/#create-rich-menu">LINE Developers documentation</a> */ async createRichMenu(richMenuRequest) { return (await this.createRichMenuWithHttpInfo(richMenuRequest)).body; } /** * Create rich menu * Calls `POST https://api.line.me/v2/bot/richmenu`. * This method returns the response body together with the underlying `httpResponse`. * @param richMenuRequest * @returns A promise resolving to the response body together with the underlying `httpResponse`. * @see <a href="https://developers.line.biz/en/reference/messaging-api/#create-rich-menu">LINE Developers 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 * Calls `POST https://api.line.me/v2/bot/richmenu/alias`. * To inspect the HTTP status code or response headers, use {@link createRichMenuAliasWithHttpInfo}. * @param createRichMenuAliasRequest * @returns A promise resolving to the response body. * @see <a href="https://developers.line.biz/en/reference/messaging-api/#create-rich-menu-alias">LINE Developers documentation</a> */ async createRichMenuAlias(createRichMenuAliasRequest) { return (await this.createRichMenuAliasWithHttpInfo(createRichMenuAliasRequest)).body; } /** * Create rich menu alias * Calls `POST https://api.line.me/v2/bot/richmenu/alias`. * This method returns the response body together with the underlying `httpResponse`. * @param createRichMenuAliasRequest * @returns A promise resolving to the response body together with the underlying `httpResponse`. * @see <a href="https://developers.line.biz/en/reference/messaging-api/#create-rich-menu-alias">LINE Developers 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. * Calls `DELETE https://api.line.me/v2/bot/richmenu/{richMenuId}`. * To inspect the HTTP status code or response headers, use {@link deleteRichMenuWithHttpInfo}. * @param richMenuId ID of a rich menu * @returns A promise resolving to the response body. * @see <a href="https://developers.line.biz/en/reference/messaging-api/#delete-rich-menu">LINE Developers documentation</a> */ async deleteRichMenu(richMenuId) { return (await this.deleteRichMenuWithHttpInfo(richMenuId)).body; } /** * Deletes a rich menu. * Calls `DELETE https://api.line.me/v2/bot/richmenu/{richMenuId}`. * This method returns the response body together with the underlying `httpResponse`. * @param richMenuId ID of a rich menu * @returns A promise resolving to the response body together with the underlying `httpResponse`. * @see <a href="https://developers.line.biz/en/reference/messaging-api/#delete-rich-menu">LINE Developers documentation</a> */ async deleteRichMenuWithHttpInfo(richMenuId) { const requestPath = buildPath("/v2/bot/richmenu/{richMenuId}", { richMenuId: richMenuId, }); const res = await this.httpClient.delete(requestPath); const text = await res.text(); const parsedBody = text ? JSON.parse(text) : null; return { httpResponse: res, body: parsedBody }; } /** * Delete rich menu alias * Calls `DELETE https://api.line.me/v2/bot/richmenu/alias/{richMenuAliasId}`. * To inspect the HTTP status code or response headers, use {@link deleteRichMenuAliasWithHttpInfo}. * @param richMenuAliasId Rich menu alias ID that you want to delete. * @returns A promise resolving to the response body. * @see <a href="https://developers.line.biz/en/reference/messaging-api/#delete-rich-menu-alias">LINE Developers documentation</a> */ async deleteRichMenuAlias(richMenuAliasId) { return (await this.deleteRichMenuAliasWithHttpInfo(richMenuAliasId)).body; } /** * Delete rich menu alias * Calls `DELETE https://api.line.me/v2/bot/richmenu/alias/{richMenuAliasId}`. * This method returns the response body together with the underlying `httpResponse`. * @param richMenuAliasId Rich menu alias ID that you want to delete. * @returns A promise resolving to the response body together with the underlying `httpResponse`. * @see <a href="https://developers.line.biz/en/reference/messaging-api/#delete-rich-menu-alias">LINE Developers documentation</a> */ async deleteRichMenuAliasWithHttpInfo(richMenuAliasId) { const requestPath = buildPath("/v2/bot/richmenu/alias/{richMenuAliasId}", { richMenuAliasId: richMenuAliasId, }); const res = await this.httpClient.delete(requestPath); 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 * Calls `GET https://api.line.me/v2/bot/message/aggregation/list`. * To inspect the HTTP status code or response headers, use {@link getAggregationUnitNameListWithHttpInfo}. * @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. * @returns A promise resolving to the response body. * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-name-list-of-units-used-this-month">LINE Developers documentation</a> */ async getAggregationUnitNameList(limit, start) { return (await this.getAggregationUnitNameListWithHttpInfo(limit, start)) .body; } /** * Get name list of units used this month * Calls `GET https://api.line.me/v2/bot/message/aggregation/list`. * This method returns the response body together with the underlying `httpResponse`. * @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. * @returns A promise resolving to the response body together with the underlying `httpResponse`. * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-name-list-of-units-used-this-month">LINE Developers documentation</a> */ async getAggregationUnitNameListWithHttpInfo(limit, start) { const queryParams = { limit: limit, start: start, }; if (queryParams["limit"] === undefined) { delete queryParams["limit"]; } if (queryParams["start"] === undefined) { delete queryParams["start"]; } 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 * Calls `GET https://api.line.me/v2/bot/message/aggregation/info`. * To inspect the HTTP status code or response headers, use {@link getAggregationUnitUsageWithHttpInfo}. * @returns A promise resolving to the response body. * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-number-of-units-used-this-month">LINE Developers documentation</a> */ async getAggregationUnitUsage() { return (await this.getAggregationUnitUsageWithHttpInfo()).body; } /** * Get number of units used this month * Calls `GET https://api.line.me/v2/bot/message/aggregation/info`. * This method returns the response body together with the underlying `httpResponse`. * @returns A promise resolving to the response body together with the underlying `httpResponse`. * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-number-of-units-used-this-month">LINE Developers 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 * Calls `GET https://api.line.me/v2/bot/info`. * To inspect the HTTP status code or response headers, use {@link getBotInfoWithHttpInfo}. * @returns A promise resolving to the response body. * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-bot-info">LINE Developers documentation</a> */ async getBotInfo() { return (await this.getBotInfoWithHttpInfo()).body; } /** * Get bot info * Calls `GET https://api.line.me/v2/bot/info`. * This method returns the response body together with the underlying `httpResponse`. * @returns A promise resolving to the response body together with the underlying `httpResponse`. * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-bot-info">LINE Developers 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 }; } /** * Get coupon detail * Calls `GET https://api.line.me/v2/bot/coupon/{couponId}`. * To inspect the HTTP status code or response headers, use {@link getCouponDetailWithHttpInfo}. * @param couponId * @returns A promise resolving to the response body. * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-coupon">LINE Developers documentation</a> */ async getCouponDetail(couponId) { return (await this.getCouponDetailWithHttpInfo(couponId)).body; } /** * Get coupon detail * Calls `GET https://api.line.me/v2/bot/coupon/{couponId}`. * This method returns the response body together with the underlying `httpResponse`. * @param couponId * @returns A promise resolving to the response body together with the underlying `httpResponse`. * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-coupon">LINE Developers documentation</a> */ async getCouponDetailWithHttpInfo(couponId) { const requestPath = buildPath("/v2/bot/coupon/{couponId}", { couponId: couponId, }); const res = await this.httpClient.get(requestPath); 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. * Calls `GET https://api.line.me/v2/bot/user/all/richmenu`. * To inspect the HTTP status code or response headers, use {@link getDefaultRichMenuIdWithHttpInfo}. * @returns A promise resolving to the response body. * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-default-rich-menu-id">LINE Developers documentation</a> */ async getDefaultRichMenuId() { return (await this.getDefaultRichMenuIdWithHttpInfo()).body; } /** * Gets the ID of the default rich menu set with the Messaging API. * Calls `GET https://api.line.me/v2/bot/user/all/richmenu`. * This method returns the response body together with the underlying `httpResponse`. * @returns A promise resolving to the response body together with the underlying `httpResponse`. * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-default-rich-menu-id">LINE Developers 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 * Calls `GET https://api.line.me/v2/bot/followers/ids`. * To inspect the HTTP status code or response headers, use {@link getFollowersWithHttpInfo}. * @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. * @returns A promise resolving to the response body. * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-follower-ids">LINE Developers 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 * Calls `GET https://api.line.me/v2/bot/followers/ids`. * This method returns the response body together with the underlying `httpResponse`. * @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. * @returns A promise resolving to the response body together with the underlying `httpResponse`. * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-follower-ids">LINE Developers documentation</a> */ async getFollowersWithHttpInfo(start, limit) { const queryParams = { start: start, limit: limit, }; if (queryParams["start"] === undefined) { delete queryParams["start"]; } if (queryParams["limit"] === undefined) { delete queryParams["limit"]; } 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 * Calls `GET https://api.line.me/v2/bot/group/{groupId}/members/count`. * To inspect the HTTP status code or response headers, use {@link getGroupMemberCountWithHttpInfo}. * @param groupId Group ID * @returns A promise resolving to the response body. * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-members-group-count">LINE Developers documentation</a> */ async getGroupMemberCount(groupId) { return (await this.getGroupMemberCountWithHttpInfo(groupId)).body; } /** * Get number of users in a group chat * Calls `GET https://api.line.me/v2/bot/group/{groupId}/members/count`. * This method returns the response body together with the underlying `httpResponse`. * @param groupId Group ID * @returns A promise resolving to the response body together with the underlying `httpResponse`. * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-members-group-count">LINE Developers documentation</a> */ async getGroupMemberCountWithHttpInfo(groupId) { const requestPath = buildPath("/v2/bot/group/{groupId}/members/count", { groupId: groupId, }); const res = await this.httpClient.get(requestPath); const text = await res.text(); const parsedBody = text ? JSON.parse(text) : null; return { httpResponse: res, body: parsedBody }; } /** * Get group chat member profile * Calls `GET https://api.line.me/v2/bot/group/{groupId}/member/{userId}`. * To inspect the HTTP status code or response headers, use {@link getGroupMemberProfileWithHttpInfo}. * @param groupId Group ID * @param userId User ID * @returns A promise resolving to the response body. * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-group-member-profile">LINE Developers documentation</a> */ async getGroupMemberProfile(groupId, userId) { return (await this.getGroupMemberProfileWithHttpInfo(groupId, userId)).body; } /** * Get group chat member profile * Calls `GET https://api.line.me/v2/bot/group/{groupId}/member/{userId}`. * This method returns the response body together with the underlying `httpResponse`. * @param groupId Group ID * @param userId User ID * @returns A promise resolving to the response body together with the underlying `httpResponse`. * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-group-member-profile">LINE Developers documentation</a> */ async getGroupMemberProfileWithHttpInfo(groupId, userId) { const requestPath = buildPath("/v2/bot/group/{groupId}/member/{userId}", { groupId: groupId, userId: userId, }); const res = await this.httpClient.get(requestPath); const text = await res.text(); const parsedBody = text ? JSON.parse(text) : null; return { httpResponse: res, body: parsedBody }; } /** * Get group chat member user IDs * Calls `GET https://api.line.me/v2/bot/group/{groupId}/members/ids`. * To inspect the HTTP status code or response headers, use {@link getGroupMembersIdsWithHttpInfo}. * @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. * @returns A promise resolving to the response body. * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-group-member-user-ids">LINE Developers documentation</a> */ async getGroupMembersIds(groupId, start) { return (await this.getGroupMembersIdsWithHttpInfo(groupId, start)).body; } /** * Get group chat member user IDs * Calls `GET https://api.line.me/v2/bot/group/{groupId}/members/ids`. * This method returns the response body together with the underlying `httpResponse`. * @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. * @returns A promise resolving to the response body together with the underlying `httpResponse`. * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-group-member-user-ids">LINE Developers documentation</a> */ async getGroupMembersIdsWithHttpInfo(groupId, start) { const requestPath = buildPath("/v2/bot/group/{groupId}/members/ids", { groupId: groupId, }); const queryParams = { start: start, }; if (queryParams["start"] === undefined) { delete queryParams["start"]; } const res = await this.httpClient.get(requestPath, queryParams); const text = await res.text(); const parsedBody = text ? JSON.parse(text) : null; return { httpResponse: res, body: parsedBody }; } /** * Get group chat summary * Calls `GET https://api.line.me/v2/bot/group/{groupId}/summary`. * To inspect the HTTP status code or response headers, use {@link getGroupSummaryWithHttpInfo}. * @param groupId Group ID * @returns A promise resolving to the response body. * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-group-summary">LINE Developers documentation</a> */ async getGroupSummary(groupId) { return (await this.getGroupSummaryWithHttpInfo(groupId)).body; } /** * Get group chat summary * Calls `GET https://api.line.me/v2/bot/group/{groupId}/summary`. * This method returns the response body together with the underlying `httpResponse`. * @param groupId Group ID * @returns A promise resolving to the response body together with the underlying `httpResponse`. * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-group-summary">LINE Developers documentation</a> */ async getGroupSummaryWithHttpInfo(groupId) { const requestPath = buildPath("/v2/bot/group/{groupId}/summary", { groupId: groupId, }); const res = await this.httpClient.get(requestPath); const text = await res.text(); const parsedBody = text ? JSON.parse(text) : null; return { httpResponse: res, body: parsedBody }; } /** * Get a list of user IDs who joined the membership. * Calls `GET https://api.line.me/v2/bot/membership/{membershipId}/users/ids`. * To inspect the HTTP status code or response headers, use {@link getJoinedMembershipUsersWithHttpInfo}. * @param membershipId Membership plan ID. * @param start A continuation token to get next remaining membership user IDs. Returned only when there are remaining user IDs that weren't returned in the userIds property in the previous request. The continuation token expires in 24 hours (86,400 seconds). * @param limit The max number of items to return for this API call. The value is set to 300 by default, but the max acceptable value is 1000. * @returns A promise resolving to the response body. * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-membership-user-ids">LINE Developers documentation</a> */ async getJoinedMembershipUsers(membershipId, start, limit) { return (await this.getJoinedMembershipUsersWithHttpInfo(membershipId, start, limit)).body; } /** * Get a list of user IDs who joined the membership. * Calls `GET https://api.line.me/v2/bot/membership/{membershipId}/users/ids`. * This method returns the response body together with the underlying `httpResponse`. * @param membershipId Membership plan ID. * @param start A continuation token to get next remaining membership user IDs. Returned only when there are remaining user IDs that weren't returned in the userIds property in the previous request. The continuation token expires in 24 hours (86,400 seconds). * @param limit The max number of items to return for this API call. The value is set to 300 by default, but the max acceptable value is 1000. * @returns A promise resolving to the response body together with the underlying `httpResponse`. * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-membership-user-ids">LINE Developers documentation</a> */ async getJoinedMembershipUsersWithHttpInfo(membershipId, start, limit) { const requestPath = buildPath("/v2/bot/membership/{membershipId}/users/ids", { membershipId: membershipId, }); const queryParams = { start: start, limit: limit, }; if (queryParams["start"] === undefined) { delete queryParams["start"]; } if (queryParams["limit"] === undefined) { delete queryParams["limit"]; } const res = await this.httpClient.get(requestPath, queryParams); const text = await res.text(); const parsedBody = text ? JSON.parse(text) : null; return { httpResponse: res, body: parsedBody }; } /** * Get a list of memberships. * Calls `GET https://api.line.me/v2/bot/membership/list`. * To inspect the HTTP status code or response headers, use {@link getMembershipListWithHttpInfo}. * @returns A promise resolving to the response body. * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-membership-plans">LINE Developers documentation</a> */ async getMembershipList() { return (await this.getMembershipListWithHttpInfo()).body; } /** * Get a list of memberships. * Calls `GET https://api.line.me/v2/bot/membership/list`. * This method returns the response body together with the underlying `httpResponse`. * @returns A promise resolving to the response body together with the underlying `httpResponse`. * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-membership-plans">LINE Developers 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. * Calls `GET https://api.line.me/v2/bot/membership/subscription/{userId}`. * To inspect the HTTP status code or response headers, use {@link getMembershipSubscriptionWithHttpInfo}. * @param userId User ID * @returns A promise resolving to the response body. * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-a-users-membership-subscription-status">LINE Developers documentation</a> */ async getMembershipSubscription(userId) { return (await this.getMembershipSubscriptionWithHttpInfo(userId)).body; } /** * Get a user's membership subscription. * Calls `GET https://api.line.me/v2/bot/membership/subscription/{userId}`. * This method returns the response body together with the underlying `httpResponse`. * @param userId User ID * @returns A promise resolving to the response body together with the underlying `httpResponse`. * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-a-users-membership-subscription-status">LINE Developers documentation</a> */ async getMembershipSubscriptionWithHttpInfo(userId) { const requestPath = buildPath("/v2/bot/membership/subscription/{userId}", { userId: userId, }); const res = await this.httpClient.get(requestPath); 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. * Calls `GET https://api.line.me/v2/bot/message/quota`. * To inspect the HTTP status code or response headers, use {@link getMessageQuotaWithHttpInfo}. * @returns A promise resolving to the response body. * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-quota">LINE Developers 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. * Calls `GET https://api.line.me/v2/bot/message/quota`. * This method returns the response body together with the underlying `httpResponse`. * @returns A promise resolving to the response body together with the underlying `httpResponse`. * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-quota">LINE Developers 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. * Calls `GET https://api.line.me/v2/bot/message/quota/consumption`. * To inspect the HTTP status code or response headers, use {@link getMessageQuotaConsumptionWithHttpInfo}. * @returns A promise resolving to the response body. * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-consumption">LINE Developers documentation</a> */ async getMessageQuotaConsumption() { return (await this.getMessageQuotaConsumptionWithHttpInfo()).body; } /** * Gets the number of messages sent in the current month. * Calls `GET https://api.line.me/v2/bot/message/quota/consumption`. * This method returns the response body together with the underlying `httpResponse`. * @returns A promise resolving to the response body together with the underlying `httpResponse`. * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-consumption">LINE Developers 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. * Calls `GET https://api.line.me/v2/bot/message/progress/narrowcast`. * To inspect the HTTP status code or response headers, use {@link getNarrowcastProgressWithHttpInfo}. * @param requestId The narrowcast message's request ID. Each Messaging API request has a request ID. * @returns A promise resolving to the response body. * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-narrowcast-progress-status">LINE Developers documentation</a> */ async getNarrowcastProgress(requestId) { return (await this.getNarrowcastProgressWithHttpInfo(requestId)).body; } /** * Gets the status of a narrowcast message. * Calls `GET https://api.line.me/v2/bot/message/progress/narrowcast`. * This method returns the response body together with the underlying `httpResponse`. * @param requestId The narrowcast message's request ID. Each Messaging API request has a request ID. * @returns A promise resolving to the response body together with the underlying `httpResponse`. * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-narrowcast-progress-status">LINE Developers documentation</a> */ async getNarrowcastProgressWithHttpInfo(requestId) { const queryParams = { requestId: requestId, }; 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 * Calls `GET https://api.line.me/v2/bot/message/delivery/broadcast`. * To inspect the HTTP status code or response headers, use {@link getNumberOfSentBroadcastMessagesWithHttpInfo}. * @param date Date the messages were sent Format: yyyyMMdd (e.g. 20191231) Timezone: UTC+9 * @returns A promise resolving to the response body. * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-number-of-broadcast-messages">LINE Developers documentation</a> */ async getNumberOfSentBroadcastMessages(date) { return (await this.getNumberOfSentBroadcastMessagesWithHttpInfo(date)).body; } /** * Get number of sent broadcast messages * Calls `GET https://api.line.me/v2/bot/message/delivery/broadcast`. * This method returns the response body together with the underlying `httpResponse`. * @param date Date the messages were sent Format: yyyyMMdd (e.g. 20191231) Timezone: UTC+9 * @returns A promise resolving to the response body together with the underlying `httpResponse`. * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-number-of-broadcast-messages">LINE Developers documentation</a> */ async getNumberOfSentBroadcastMessagesWithHttpInfo(date) { const queryParams = { date: date, }; 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 * Calls `GET https://api.line.me/v2/bot/message/delivery/multicast`. * To inspect the HTTP status code or response headers, use {@link getNumberOfSentMulticastMessagesWithHttpInfo}. * @param date Date the messages were sent Format: `yyyyMMdd` (e.g. `20191231`) Timezone: UTC+9 * @returns A promise resolving to the response body. * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-number-of-multicast-messages">LINE Developers documentation</a> */ async getNumberOfSentMulticastMessages(date) { return (await this.getNumberOfSentMulticastMessagesWithHttpInfo(date)).body; } /** * Get number of sent multicast messages * Calls `GET https://api.line.me/v2/bot/message/delivery/multicast`. * This method returns the response body together with the underlying `httpResponse`. * @param date Date the messages were sent Format: `yyyyMMdd` (e.g. `20191231`) Timezone: UTC+9 * @returns A promise resolving to the response body together with the underlying `httpResponse`. * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-number-of-multicast-messages">LINE Developers documentation</a> */ async getNumberOfSentMulticastMessagesWithHttpInfo(date) { const queryParams = { date: date, }; 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 * Calls `GET https://api.line.me/v2/bot/message/delivery/push`. * To inspect the HTTP status code or response headers, use {@link getNumberOfSentPushMessagesWithHttpInfo}. * @param date Date the messages were sent Format: `yyyyMMdd` (e.g. `20191231`) Timezone: UTC+9 * @returns A promise resolving to the response body. * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-number-of-push-messages">LINE Developers documentation</a> */ async getNumberOfSentPushMessages(date) { return (await this.getNumberOfSentPushMessagesWithHttpInfo(date)).body; } /** * Get number of sent push messages * Calls `GET https://api.line.me/v2/bot/message/delivery/push`. * This method returns the response body together with the underlying `httpResponse`. * @param date Date the messages were sent Format: `yyyyMMdd` (e.g. `20191231`) Timezone: UTC+9 * @returns A promise resolving to the response body together with the underlying `httpResponse`. * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-number-of-push-messages">LINE Developers documentation</a> */ async getNumberOfSentPushMessagesWithHttpInfo(date) { const queryParams = { date: date, }; 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 * Calls `GET https://api.line.me/v2/bot/message/delivery/reply`. * To inspect the HTTP status code or response headers, use {@link getNumberOfSentReplyMessagesWithHttpInfo}. * @param date Date the messages were sent Format: `yyyyMMdd` (e.g. `20191231`) Timezone: UTC+9 * @returns A promise resolving to the response body. * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-number-of-reply-messages">LINE Developers documentation</a> */ async getNumberOfSentReplyMessages(date) { return (await this.getNumberOfSentReplyMessagesWithHttpInfo(date)).body; } /** * Get number of sent reply messages * Calls `GET https://api.line.me/v2/bot/message/delivery/reply`. * This method returns the response body together with the underlying `httpResponse`. * @param date Date the messages were sent Format: `yyyyMMdd` (e.g. `20191231`) Timezone: UTC+9 * @returns A promise resolving to the response body together with the underlying `httpResponse`. * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-number-of-reply-messages">LINE Developers documentation</a> */ async getNumberOfSentReplyMessagesWithHttpInfo(date) { const queryParams = { date: date, }; 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 * Calls `GET https://api.line.me/v2/bot/message/delivery/pnp`. * To inspect the HTTP status code or response headers, use {@link getPNPMessageStatisticsWithHttpInfo}. * @param date Date the message was sent Format: `yyyyMMdd` (Example:`20211231`) Time zone: UTC+9 * @returns A promise resolving to the response body. * @see <a href="https://developers.line.biz/en/reference/partner-docs/#get-number-of-sent-line-notification-messages">LINE Developers documentation</a> */ async getPNPMessageStatistics(date) { return (await this.getPNPMessageStatisticsWithHttpInfo(date)).body; } /** * Get number of sent LINE notification messages * Calls `GET https://api.line.me/v2/bot/message/delivery/pnp`. * This method returns the response body together with the underlying `httpResponse`. * @param date Date the message was sent Format: `yyyyMMdd` (Example:`20211231`) Time zone: UTC+9 * @returns A promise resolving to the response body together with the underlying `httpResponse`. * @see <a href="https://developers.line.biz/en/reference/partner-docs/#get-number-of-sent-line-notification-messages">LINE Developers documentation</a> */ async getPNPMessageStatisticsWithHttpInfo(date) { const queryParams = { date: date, }; 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 * Calls `GET https://api.line.me/v2/bot/profile/{userId}`. * To inspect the HTTP status code or response headers, use {@link getProfileWithHttpInfo}. * @param userId User ID * @returns A promise resolving to the response body. * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-profile">LINE Developers documentation</a> */ async getProfile(userId) { return (await this.getProfileWithHttpInfo(userId)).body; } /** * Get profile * Calls `GET https://api.line.me/v2/bot/profile/{userId}`. * This method returns the response body together with the underlying `httpResponse`. * @param userId User ID * @returns A promise resolving to the response body together with the underlying `httpResponse`. * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-profile">LINE Developers documentation</a> */ async getProfileWithHttpInfo(userId) { const requestPath = buildPath("/v2/bot/profile/{userId}", { userId: userId, }); const res = await this.httpClient.get(requestPath); 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. * Calls `GET https://api.line.me/v2/bot/richmenu/{richMenuId}`. * To inspect the HTTP status code or response headers, use {@link getRichMenuWithHttpInfo}. * @param richMenuId ID of a rich menu * @returns A promise resolving to the response body. * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-rich-menu">LINE Developers documentation</a> */ async getRichMenu(richMenuId) { return (await this.getRichMenuWithHttpInfo(richMenuId)).body; } /** * Gets a rich menu via a rich menu ID. * Calls `GET https://api.line.me/v2/bot/richmenu/{richMenuId}`. * This method returns the response body together with the underlying `httpResponse`. * @param richMenuId ID of a rich menu * @returns A promise resolving to the response body together with the