UNPKG

9.59 kBJavaScriptView Raw
1"use strict";
2/**
3 * LINE Messaging API(Insight)
4 * This document describes LINE Messaging API(Insight).
5 *
6 * The version of the OpenAPI document: 0.0.1
7 *
8 *
9 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
10 * https://openapi-generator.tech
11 * Do not edit the class manually.
12 */
13Object.defineProperty(exports, "__esModule", { value: true });
14exports.InsightClient = void 0;
15const Types = require("../../types");
16const http_fetch_1 = require("../../http-fetch");
17class InsightClient {
18 constructor(config) {
19 if (!config.baseURL) {
20 config.baseURL = "https://api.line.me";
21 }
22 this.httpClient = new http_fetch_1.default({
23 defaultHeaders: {
24 Authorization: "Bearer " + config.channelAccessToken,
25 },
26 baseURL: config.baseURL,
27 });
28 }
29 async parseHTTPResponse(response) {
30 const { LINE_REQUEST_ID_HTTP_HEADER_NAME } = Types;
31 let resBody = Object.assign({}, (await response.json()));
32 if (response.headers.get(LINE_REQUEST_ID_HTTP_HEADER_NAME)) {
33 resBody[LINE_REQUEST_ID_HTTP_HEADER_NAME] = response.headers.get(LINE_REQUEST_ID_HTTP_HEADER_NAME);
34 }
35 return resBody;
36 }
37 /**
38 * Retrieves the demographic attributes for a LINE Official Account\'s friends.You can only retrieve information about friends for LINE Official Accounts created by users in Japan (JP), Thailand (TH), Taiwan (TW) and Indonesia (ID).
39 *
40 * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-demographic"> Documentation</a>
41 */
42 async getFriendsDemographics() {
43 return (await this.getFriendsDemographicsWithHttpInfo()).body;
44 }
45 /**
46 * Retrieves the demographic attributes for a LINE Official Account\'s friends.You can only retrieve information about friends for LINE Official Accounts created by users in Japan (JP), Thailand (TH), Taiwan (TW) and Indonesia (ID). .
47 * This method includes HttpInfo object to return additional information.
48 *
49 * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-demographic"> Documentation</a>
50 */
51 async getFriendsDemographicsWithHttpInfo() {
52 const res = await this.httpClient.get("/v2/bot/insight/demographic");
53 return { httpResponse: res, body: await res.json() };
54 }
55 /**
56 * Returns statistics about how users interact with narrowcast messages or broadcast messages sent from your LINE Official Account.
57 * @summary Get user interaction statistics
58 * @param requestId Request ID of a narrowcast message or broadcast message. Each Messaging API request has a request ID.
59 *
60 * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-message-event">Get user interaction statistics Documentation</a>
61 */
62 async getMessageEvent(requestId) {
63 return (await this.getMessageEventWithHttpInfo(requestId)).body;
64 }
65 /**
66 * Returns statistics about how users interact with narrowcast messages or broadcast messages sent from your LINE Official Account. .
67 * This method includes HttpInfo object to return additional information.
68 * @summary Get user interaction statistics
69 * @param requestId Request ID of a narrowcast message or broadcast message. Each Messaging API request has a request ID.
70 *
71 * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-message-event">Get user interaction statistics Documentation</a>
72 */
73 async getMessageEventWithHttpInfo(requestId) {
74 const queryParams = {
75 requestId: requestId,
76 };
77 Object.keys(queryParams).forEach((key) => {
78 if (queryParams[key] === undefined) {
79 delete queryParams[key];
80 }
81 });
82 const res = await this.httpClient.get("/v2/bot/insight/message/event", queryParams);
83 return { httpResponse: res, body: await res.json() };
84 }
85 /**
86 * Returns the number of users who have added the LINE Official Account on or before a specified date.
87 * @summary Get number of followers
88 * @param date Date for which to retrieve the number of followers. Format: yyyyMMdd (e.g. 20191231) Timezone: UTC+9
89 *
90 * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-number-of-followers">Get number of followers Documentation</a>
91 */
92 async getNumberOfFollowers(date) {
93 return (await this.getNumberOfFollowersWithHttpInfo(date)).body;
94 }
95 /**
96 * Returns the number of users who have added the LINE Official Account on or before a specified date. .
97 * This method includes HttpInfo object to return additional information.
98 * @summary Get number of followers
99 * @param date Date for which to retrieve the number of followers. Format: yyyyMMdd (e.g. 20191231) Timezone: UTC+9
100 *
101 * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-number-of-followers">Get number of followers Documentation</a>
102 */
103 async getNumberOfFollowersWithHttpInfo(date) {
104 const queryParams = {
105 date: date,
106 };
107 Object.keys(queryParams).forEach((key) => {
108 if (queryParams[key] === undefined) {
109 delete queryParams[key];
110 }
111 });
112 const res = await this.httpClient.get("/v2/bot/insight/followers", queryParams);
113 return { httpResponse: res, body: await res.json() };
114 }
115 /**
116 * Returns the number of messages sent from LINE Official Account on a specified day.
117 * @summary Get number of message deliveries
118 * @param date Date for which to retrieve number of sent messages. - Format: yyyyMMdd (e.g. 20191231) - Timezone: UTC+9
119 *
120 * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-number-of-delivery-messages">Get number of message deliveries Documentation</a>
121 */
122 async getNumberOfMessageDeliveries(date) {
123 return (await this.getNumberOfMessageDeliveriesWithHttpInfo(date)).body;
124 }
125 /**
126 * Returns the number of messages sent from LINE Official Account on a specified day. .
127 * This method includes HttpInfo object to return additional information.
128 * @summary Get number of message deliveries
129 * @param date Date for which to retrieve number of sent messages. - Format: yyyyMMdd (e.g. 20191231) - Timezone: UTC+9
130 *
131 * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-number-of-delivery-messages">Get number of message deliveries Documentation</a>
132 */
133 async getNumberOfMessageDeliveriesWithHttpInfo(date) {
134 const queryParams = {
135 date: date,
136 };
137 Object.keys(queryParams).forEach((key) => {
138 if (queryParams[key] === undefined) {
139 delete queryParams[key];
140 }
141 });
142 const res = await this.httpClient.get("/v2/bot/insight/message/delivery", queryParams);
143 return { httpResponse: res, body: await res.json() };
144 }
145 /**
146 * You can check the per-unit statistics of how users interact with push messages and multicast messages sent from your LINE Official Account.
147 * @param customAggregationUnit Name of aggregation unit specified when sending the message. Case-sensitive. For example, `Promotion_a` and `Promotion_A` are regarded as different unit names.
148 * @param from Start date of aggregation period. Format: yyyyMMdd (e.g. 20210301) Time zone: UTC+9
149 * @param to End date of aggregation period. The end date can be specified for up to 30 days later. For example, if the start date is 20210301, the latest end date is 20210331. Format: yyyyMMdd (e.g. 20210301) Time zone: UTC+9
150 *
151 * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-statistics-per-unit"> Documentation</a>
152 */
153 async getStatisticsPerUnit(customAggregationUnit, from, to) {
154 return (await this.getStatisticsPerUnitWithHttpInfo(customAggregationUnit, from, to)).body;
155 }
156 /**
157 * You can check the per-unit statistics of how users interact with push messages and multicast messages sent from your LINE Official Account. .
158 * This method includes HttpInfo object to return additional information.
159 * @param customAggregationUnit Name of aggregation unit specified when sending the message. Case-sensitive. For example, `Promotion_a` and `Promotion_A` are regarded as different unit names.
160 * @param from Start date of aggregation period. Format: yyyyMMdd (e.g. 20210301) Time zone: UTC+9
161 * @param to End date of aggregation period. The end date can be specified for up to 30 days later. For example, if the start date is 20210301, the latest end date is 20210331. Format: yyyyMMdd (e.g. 20210301) Time zone: UTC+9
162 *
163 * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-statistics-per-unit"> Documentation</a>
164 */
165 async getStatisticsPerUnitWithHttpInfo(customAggregationUnit, from, to) {
166 const queryParams = {
167 customAggregationUnit: customAggregationUnit,
168 from: from,
169 to: to,
170 };
171 Object.keys(queryParams).forEach((key) => {
172 if (queryParams[key] === undefined) {
173 delete queryParams[key];
174 }
175 });
176 const res = await this.httpClient.get("/v2/bot/insight/message/event/aggregation", queryParams);
177 return { httpResponse: res, body: await res.json() };
178 }
179}
180exports.InsightClient = InsightClient;