@line/bot-sdk
Version:
Node.js SDK for LINE Messaging API
86 lines (85 loc) • 3.13 kB
JavaScript
;
/**
* LIFF server API
* LIFF Server API.
*
* The version of the OpenAPI document: 1.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.LiffClient = void 0;
const Types = require("../../types");
const utils_1 = require("../../utils");
const http_1 = require("../../http");
class LiffClient {
constructor(config) {
if (!config.baseURL) {
config.baseURL = "https://api.line.me";
}
this.httpClient = new http_1.default({
defaultHeaders: {
Authorization: "Bearer " + config.channelAccessToken,
},
responseParser: this.parseHTTPResponse.bind(this),
baseURL: config.baseURL,
});
}
parseHTTPResponse(response) {
const { LINE_REQUEST_ID_HTTP_HEADER_NAME } = Types;
let resBody = Object.assign({}, response.data);
if (response.headers[LINE_REQUEST_ID_HTTP_HEADER_NAME]) {
resBody[LINE_REQUEST_ID_HTTP_HEADER_NAME] =
response.headers[LINE_REQUEST_ID_HTTP_HEADER_NAME];
}
return resBody;
}
/**
* Adding the LIFF app to a channel
* @param addLiffAppRequest
*
* @see <a href="https://developers.line.biz/en/reference/liff-server/#add-liff-app"> Documentation</a>
*/
async addLIFFApp(addLiffAppRequest) {
const params = addLiffAppRequest;
const res = this.httpClient.post("/liff/v1/apps", params);
return (0, utils_1.ensureJSON)(res);
}
/**
* Deletes a LIFF app from a channel.
* @summary Delete LIFF app from a channel
* @param liffId ID of the LIFF app to be updated
*
* @see <a href="https://developers.line.biz/en/reference/liff-server/#delete-liff-app">Delete LIFF app from a channel Documentation</a>
*/
async deleteLIFFApp(liffId) {
const res = this.httpClient.delete("/liff/v1/apps/{liffId}".replace("{liffId}", String(liffId)));
return (0, utils_1.ensureJSON)(res);
}
/**
* Gets information on all the LIFF apps added to the channel.
* @summary Get all LIFF apps
*
* @see <a href="https://developers.line.biz/en/reference/liff-server/#get-all-liff-apps">Get all LIFF apps Documentation</a>
*/
async getAllLIFFApps() {
const res = this.httpClient.get("/liff/v1/apps");
return (0, utils_1.ensureJSON)(res);
}
/**
* Update LIFF app settings
* @param liffId ID of the LIFF app to be updated
* @param updateLiffAppRequest
*
* @see <a href="https://developers.line.biz/en/reference/liff-server/#update-liff-app"> Documentation</a>
*/
async updateLIFFApp(liffId, updateLiffAppRequest) {
const params = updateLiffAppRequest;
const res = this.httpClient.put("/liff/v1/apps/{liffId}".replace("{liffId}", String(liffId)), params);
return (0, utils_1.ensureJSON)(res);
}
}
exports.LiffClient = LiffClient;