UNPKG

@line/bot-sdk

Version:
196 lines 8.92 kB
"use strict"; /** * LIFF server API * LIFF Server API. * * The version of the OpenAPI document: 1.0.0 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || (function () { var ownKeys = function(o) { ownKeys = Object.getOwnPropertyNames || function (o) { var ar = []; for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; return ar; }; return ownKeys(o); }; return function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); __setModuleDefault(result, mod); return result; }; })(); Object.defineProperty(exports, "__esModule", { value: true }); exports.LiffClient = void 0; const utils_js_1 = require("../../utils.js"); const http_fetch_js_1 = __importStar(require("../../http-fetch.js")); /** * @see {@link LineBotClient} for a unified interface that wraps this client. */ class LiffClient { /** * Initializes a new `LiffClient`. * * @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 LiffClient({ * channelAccessToken: process.env.LINE_CHANNEL_ACCESS_TOKEN!, * }); */ constructor(config) { const baseURL = config.baseURL || "https://api.line.me"; const defaultHeaders = (0, http_fetch_js_1.mergeHeaders)(config.defaultHeaders, { Authorization: "Bearer " + config.channelAccessToken, }); this.httpClient = new http_fetch_js_1.default({ defaultHeaders: defaultHeaders, baseURL: baseURL, }); } /** * Adding the LIFF app to a channel * Calls `POST https://api.line.me/liff/v1/apps`. * To inspect the HTTP status code or response headers, use {@link addLIFFAppWithHttpInfo}. * @summary Create LIFF app * @param addLiffAppRequest * @returns A promise resolving to the response body. * @see <a href="https://developers.line.biz/en/reference/liff-server/#add-liff-app">LINE Developers documentation</a> */ async addLIFFApp(addLiffAppRequest) { return (await this.addLIFFAppWithHttpInfo(addLiffAppRequest)).body; } /** * Adding the LIFF app to a channel * Calls `POST https://api.line.me/liff/v1/apps`. * This method returns the response body together with the underlying `httpResponse`. * @summary Create LIFF app * @param addLiffAppRequest * @returns A promise resolving to the response body together with the underlying `httpResponse`. * @see <a href="https://developers.line.biz/en/reference/liff-server/#add-liff-app">LINE Developers documentation</a> */ async addLIFFAppWithHttpInfo(addLiffAppRequest) { const params = addLiffAppRequest; const res = await this.httpClient.post("/liff/v1/apps", params); const text = await res.text(); const parsedBody = text ? JSON.parse(text) : null; return { httpResponse: res, body: parsedBody }; } /** * Deletes a LIFF app from a channel. * Calls `DELETE https://api.line.me/liff/v1/apps/{liffId}`. * To inspect the HTTP status code or response headers, use {@link deleteLIFFAppWithHttpInfo}. * @summary Delete LIFF app from a channel * @param liffId ID of the LIFF app to be updated * @returns A promise resolving to the response body. * @see <a href="https://developers.line.biz/en/reference/liff-server/#delete-liff-app">LINE Developers documentation</a> */ async deleteLIFFApp(liffId) { return (await this.deleteLIFFAppWithHttpInfo(liffId)).body; } /** * Deletes a LIFF app from a channel. * Calls `DELETE https://api.line.me/liff/v1/apps/{liffId}`. * This method returns the response body together with the underlying `httpResponse`. * @summary Delete LIFF app from a channel * @param liffId ID of the LIFF app to be updated * @returns A promise resolving to the response body together with the underlying `httpResponse`. * @see <a href="https://developers.line.biz/en/reference/liff-server/#delete-liff-app">LINE Developers documentation</a> */ async deleteLIFFAppWithHttpInfo(liffId) { const requestPath = (0, utils_js_1.buildPath)("/liff/v1/apps/{liffId}", { liffId: liffId, }); const res = await this.httpClient.delete(requestPath); const text = await res.text(); const parsedBody = text ? JSON.parse(text) : null; return { httpResponse: res, body: parsedBody }; } /** * Gets information on all the LIFF apps added to the channel. * Calls `GET https://api.line.me/liff/v1/apps`. * To inspect the HTTP status code or response headers, use {@link getAllLIFFAppsWithHttpInfo}. * @summary Get all LIFF apps * @returns A promise resolving to the response body. * @see <a href="https://developers.line.biz/en/reference/liff-server/#get-all-liff-apps">LINE Developers documentation</a> */ async getAllLIFFApps() { return (await this.getAllLIFFAppsWithHttpInfo()).body; } /** * Gets information on all the LIFF apps added to the channel. * Calls `GET https://api.line.me/liff/v1/apps`. * This method returns the response body together with the underlying `httpResponse`. * @summary Get all LIFF apps * @returns A promise resolving to the response body together with the underlying `httpResponse`. * @see <a href="https://developers.line.biz/en/reference/liff-server/#get-all-liff-apps">LINE Developers documentation</a> */ async getAllLIFFAppsWithHttpInfo() { const res = await this.httpClient.get("/liff/v1/apps"); const text = await res.text(); const parsedBody = text ? JSON.parse(text) : null; return { httpResponse: res, body: parsedBody }; } /** * Update LIFF app settings * Calls `PUT https://api.line.me/liff/v1/apps/{liffId}`. * To inspect the HTTP status code or response headers, use {@link updateLIFFAppWithHttpInfo}. * @summary Update LIFF app from a channel * @param liffId ID of the LIFF app to be updated * @param updateLiffAppRequest * @returns A promise resolving to the response body. * @see <a href="https://developers.line.biz/en/reference/liff-server/#update-liff-app">LINE Developers documentation</a> */ async updateLIFFApp(liffId, updateLiffAppRequest) { return (await this.updateLIFFAppWithHttpInfo(liffId, updateLiffAppRequest)) .body; } /** * Update LIFF app settings * Calls `PUT https://api.line.me/liff/v1/apps/{liffId}`. * This method returns the response body together with the underlying `httpResponse`. * @summary Update LIFF app from a channel * @param liffId ID of the LIFF app to be updated * @param updateLiffAppRequest * @returns A promise resolving to the response body together with the underlying `httpResponse`. * @see <a href="https://developers.line.biz/en/reference/liff-server/#update-liff-app">LINE Developers documentation</a> */ async updateLIFFAppWithHttpInfo(liffId, updateLiffAppRequest) { const requestPath = (0, utils_js_1.buildPath)("/liff/v1/apps/{liffId}", { liffId: liffId, }); const params = updateLiffAppRequest; const res = await this.httpClient.put(requestPath, params); const text = await res.text(); const parsedBody = text ? JSON.parse(text) : null; return { httpResponse: res, body: parsedBody }; } } exports.LiffClient = LiffClient; //# sourceMappingURL=liffClient.js.map