UNPKG

@line/bot-sdk

Version:
1,050 lines (986 loc) 122 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. */ /* tslint:disable:no-unused-locals */ import { BotInfoResponse } from "../model/botInfoResponse.js"; import { BroadcastRequest } from "../model/broadcastRequest.js"; import { CouponCreateRequest } from "../model/couponCreateRequest.js"; import { CouponCreateResponse } from "../model/couponCreateResponse.js"; import { CouponResponse } from "../model/couponResponse.js"; import { CreateRichMenuAliasRequest } from "../model/createRichMenuAliasRequest.js"; import { ErrorResponse } from "../model/errorResponse.js"; import { GetAggregationUnitNameListResponse } from "../model/getAggregationUnitNameListResponse.js"; import { GetAggregationUnitUsageResponse } from "../model/getAggregationUnitUsageResponse.js"; import { GetFollowersResponse } from "../model/getFollowersResponse.js"; import { GetJoinedMembershipUsersResponse } from "../model/getJoinedMembershipUsersResponse.js"; import { GetMembershipSubscriptionResponse } from "../model/getMembershipSubscriptionResponse.js"; import { GetWebhookEndpointResponse } from "../model/getWebhookEndpointResponse.js"; import { GroupMemberCountResponse } from "../model/groupMemberCountResponse.js"; import { GroupSummaryResponse } from "../model/groupSummaryResponse.js"; import { GroupUserProfileResponse } from "../model/groupUserProfileResponse.js"; import { IssueLinkTokenResponse } from "../model/issueLinkTokenResponse.js"; import { MarkMessagesAsReadByTokenRequest } from "../model/markMessagesAsReadByTokenRequest.js"; import { MarkMessagesAsReadRequest } from "../model/markMessagesAsReadRequest.js"; import { MembersIdsResponse } from "../model/membersIdsResponse.js"; import { MembershipListResponse } from "../model/membershipListResponse.js"; import { MessageQuotaResponse } from "../model/messageQuotaResponse.js"; import { MessagingApiPagerCouponListResponse } from "../model/messagingApiPagerCouponListResponse.js"; import { MulticastRequest } from "../model/multicastRequest.js"; import { NarrowcastProgressResponse } from "../model/narrowcastProgressResponse.js"; import { NarrowcastRequest } from "../model/narrowcastRequest.js"; import { NumberOfMessagesResponse } from "../model/numberOfMessagesResponse.js"; import { PnpMessagesRequest } from "../model/pnpMessagesRequest.js"; import { PushMessageRequest } from "../model/pushMessageRequest.js"; import { PushMessageResponse } from "../model/pushMessageResponse.js"; import { QuotaConsumptionResponse } from "../model/quotaConsumptionResponse.js"; import { ReplyMessageRequest } from "../model/replyMessageRequest.js"; import { ReplyMessageResponse } from "../model/replyMessageResponse.js"; import { RichMenuAliasListResponse } from "../model/richMenuAliasListResponse.js"; import { RichMenuAliasResponse } from "../model/richMenuAliasResponse.js"; import { RichMenuBatchProgressResponse } from "../model/richMenuBatchProgressResponse.js"; import { RichMenuBatchRequest } from "../model/richMenuBatchRequest.js"; import { RichMenuBulkLinkRequest } from "../model/richMenuBulkLinkRequest.js"; import { RichMenuBulkUnlinkRequest } from "../model/richMenuBulkUnlinkRequest.js"; import { RichMenuIdResponse } from "../model/richMenuIdResponse.js"; import { RichMenuListResponse } from "../model/richMenuListResponse.js"; import { RichMenuRequest } from "../model/richMenuRequest.js"; 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"; import { UserProfileResponse } from "../model/userProfileResponse.js"; import { ValidateMessageRequest } from "../model/validateMessageRequest.js"; import * as Types from "../../types.js"; import { ensureJSON, buildPath } from "../../utils.js"; import { Readable } from "node:stream"; import HTTPFetchClient, { convertResponseToReadable, mergeHeaders, } from "../../http-fetch.js"; // =============================================== // This file is autogenerated - Please do not edit // =============================================== interface httpClientConfig { /** * Base URL for requests. * Defaults to 'https://api.line.me'. * You can override this for testing or to use a mock server. */ baseURL?: string; /** * Channel access token used for authorization. */ channelAccessToken: string; /** * Extra headers merged into every request. */ defaultHeaders?: Record<string, string>; } /** * @see {@link LineBotClient} for a unified interface that wraps this client. */ export class MessagingApiClient { private httpClient: HTTPFetchClient; /** * 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: httpClientConfig) { 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> */ public async broadcast( broadcastRequest: BroadcastRequest, xLineRetryKey?: string, ): Promise<object> { 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> */ public async broadcastWithHttpInfo( broadcastRequest: BroadcastRequest, xLineRetryKey?: string, ): Promise<Types.ApiResponseType<object>> { 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> */ public async cancelDefaultRichMenu(): Promise<Types.MessageAPIResponseBase> { 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> */ public async cancelDefaultRichMenuWithHttpInfo(): Promise< Types.ApiResponseType<Types.MessageAPIResponseBase> > { 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> */ public async closeCoupon( couponId: string, ): Promise<Types.MessageAPIResponseBase> { 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> */ public async closeCouponWithHttpInfo( couponId: string, ): Promise<Types.ApiResponseType<Types.MessageAPIResponseBase>> { 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> */ public async createCoupon( couponCreateRequest?: CouponCreateRequest, ): Promise<CouponCreateResponse> { 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> */ public async createCouponWithHttpInfo( couponCreateRequest?: CouponCreateRequest, ): Promise<Types.ApiResponseType<CouponCreateResponse>> { 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> */ public async createRichMenu( richMenuRequest: RichMenuRequest, ): Promise<RichMenuIdResponse> { 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> */ public async createRichMenuWithHttpInfo( richMenuRequest: RichMenuRequest, ): Promise<Types.ApiResponseType<RichMenuIdResponse>> { 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> */ public async createRichMenuAlias( createRichMenuAliasRequest: CreateRichMenuAliasRequest, ): Promise<Types.MessageAPIResponseBase> { 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> */ public async createRichMenuAliasWithHttpInfo( createRichMenuAliasRequest: CreateRichMenuAliasRequest, ): Promise<Types.ApiResponseType<Types.MessageAPIResponseBase>> { 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> */ public async deleteRichMenu( richMenuId: string, ): Promise<Types.MessageAPIResponseBase> { 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> */ public async deleteRichMenuWithHttpInfo( richMenuId: string, ): Promise<Types.ApiResponseType<Types.MessageAPIResponseBase>> { 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> */ public async deleteRichMenuAlias( richMenuAliasId: string, ): Promise<Types.MessageAPIResponseBase> { 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> */ public async deleteRichMenuAliasWithHttpInfo( richMenuAliasId: string, ): Promise<Types.ApiResponseType<Types.MessageAPIResponseBase>> { 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> */ public async getAggregationUnitNameList( limit?: string, start?: string, ): Promise<GetAggregationUnitNameListResponse> { 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> */ public async getAggregationUnitNameListWithHttpInfo( limit?: string, start?: string, ): Promise<Types.ApiResponseType<GetAggregationUnitNameListResponse>> { 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> */ public async getAggregationUnitUsage(): Promise<GetAggregationUnitUsageResponse> { 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> */ public async getAggregationUnitUsageWithHttpInfo(): Promise< Types.ApiResponseType<GetAggregationUnitUsageResponse> > { 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> */ public async getBotInfo(): Promise<BotInfoResponse> { 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> */ public async getBotInfoWithHttpInfo(): Promise< Types.ApiResponseType<BotInfoResponse> > { 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> */ public async getCouponDetail(couponId: string): Promise<CouponResponse> { 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> */ public async getCouponDetailWithHttpInfo( couponId: string, ): Promise<Types.ApiResponseType<CouponResponse>> { 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> */ public async getDefaultRichMenuId(): Promise<RichMenuIdResponse> { 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> */ public async getDefaultRichMenuIdWithHttpInfo(): Promise< Types.ApiResponseType<RichMenuIdResponse> > { 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> */ public async getFollowers( start?: string, limit?: number, ): Promise<GetFollowersResponse> { 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> */ public async getFollowersWithHttpInfo( start?: string, limit?: number, ): Promise<Types.ApiResponseType<GetFollowersResponse>> { 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> */ public async getGroupMemberCount( groupId: string, ): Promise<GroupMemberCountResponse> { 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> */ public async getGroupMemberCountWithHttpInfo( groupId: string, ): Promise<Types.ApiResponseType<GroupMemberCountResponse>> { 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> */ public async getGroupMemberProfile( groupId: string, userId: string, ): Promise<GroupUserProfileResponse> { 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> */ public async getGroupMemberProfileWithHttpInfo( groupId: string, userId: string, ): Promise<Types.ApiResponseType<GroupUserProfileResponse>> { 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> */ public async getGroupMembersIds( groupId: string, start?: string, ): Promise<MembersIdsResponse> { 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> */ public async getGroupMembersIdsWithHttpInfo( groupId: string, start?: string, ): Promise<Types.ApiResponseType<MembersIdsResponse>> { 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> */ public async getGroupSummary(groupId: string): Promise<GroupSummaryResponse> { 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> */ public async getGroupSummaryWithHttpInfo( groupId: string, ): Promise<Types.ApiResponseType<GroupSummaryResponse>> { 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> */ public async getJoinedMembershipUsers( membershipId: number, start?: string, limit?: number, ): Promise<GetJoinedMembershipUsersResponse> { 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> */ public async getJoinedMembershipUsersWithHttpInfo( membershipId: number, start?: string, limit?: number, ): Promise<Types.ApiResponseType<GetJoinedMembershipUsersResponse>> { 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> */ public async getMembershipList(): Promise<MembershipListResponse> { 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> */ public async getMembershipListWithHttpInfo(): Promise< Types.ApiResponseType<MembershipListResponse> > { 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> */ public async getMembershipSubscription( userId: string, ): Promise<GetMembershipSubscriptionResponse> { 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> */ public async getMembershipSubscriptionWithHttpInfo( userId: string, ): Promise<Types.ApiResponseType<GetMembershipSubscriptionResponse>> { 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> */ public async getMessageQuota(): Promise<MessageQuotaResponse> { 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> */ public async getMessageQuotaWithHttpInfo(): Promise< Types.ApiResponseType<MessageQuotaResponse> > { 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> */ public async getMessageQuotaConsumption(): Promise<QuotaConsumptionResponse> { 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> */ public async getMessageQuotaConsumptionWithHttpInfo(): Promise< Types.ApiResponseType<QuotaConsumptionResponse> > { 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> */ public async getNarrowcastProgress( requestId: string, ): Promise<NarrowcastProgressResponse> { 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> */ public async getNarrowcastProgressWithHttpInfo( requestId: string, ): Promise<Types.ApiResponseType<NarrowcastProgressResponse>> { 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> */ public async getNumberOfSentBroadcastMessages( date: string, ): Promise<NumberOfMessagesResponse> { 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> */ public async getNumberOfSentBroadcastMessagesWithHttpInfo( date: string, ): Promise<Types.ApiResponseType<NumberOfMessagesResponse>> { 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> */ public async getNumberOfSentMulticastMessages( date: string, ): Promise<NumberOfMessagesResponse> { 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> */ public async getNumberOfSentMulticastMessagesWithHttpInfo( date: string, ): Promise<Types.ApiResponseType<NumberOfMessagesResponse>> { 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 pro