UNPKG

@line/bot-sdk

Version:
91 lines (90 loc) 3.78 kB
"use strict"; /** * 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. */ Object.defineProperty(exports, "__esModule", { value: true }); exports.MessagingApiBlobClient = void 0; const Types = require("../../types"); const utils_1 = require("../../utils"); const http_1 = require("../../http"); class MessagingApiBlobClient { constructor(config) { if (!config.baseURL) { config.baseURL = "https://api-data.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; } /** * Download image, video, and audio data sent from users. * @param messageId Message ID of video or audio * * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-content"> Documentation</a> */ async getMessageContent(messageId) { return this.httpClient.getStream("/v2/bot/message/{messageId}/content".replace("{" + "messageId" + "}", String(messageId))); } /** * Get a preview image of the image or video * @param messageId Message ID of image or video * * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-image-or-video-preview"> Documentation</a> */ async getMessageContentPreview(messageId) { return this.httpClient.getStream("/v2/bot/message/{messageId}/content/preview".replace("{" + "messageId" + "}", String(messageId))); } /** * Verify the preparation status of a video or audio for getting * @param messageId Message ID of video or audio * * @see <a href="https://developers.line.biz/en/reference/messaging-api/#verify-video-or-audio-preparation-status"> Documentation</a> */ async getMessageContentTranscodingByMessageId(messageId) { const res = this.httpClient.get("/v2/bot/message/{messageId}/content/transcoding".replace("{messageId}", String(messageId))); return (0, utils_1.ensureJSON)(res); } /** * Download rich menu image. * @param richMenuId ID of the rich menu with the image to be downloaded * * @see <a href="https://developers.line.biz/en/reference/messaging-api/#download-rich-menu-image"> Documentation</a> */ async getRichMenuImage(richMenuId) { return this.httpClient.getStream("/v2/bot/richmenu/{richMenuId}/content".replace("{" + "richMenuId" + "}", String(richMenuId))); } /** * Upload rich menu image * @param richMenuId The ID of the rich menu to attach the image to * @param body * * @see <a href="https://developers.line.biz/en/reference/messaging-api/#upload-rich-menu-image"> Documentation</a> */ async setRichMenuImage(richMenuId, body) { const params = body; const res = this.httpClient.postBinaryContent("/v2/bot/richmenu/{richMenuId}/content".replace("{richMenuId}", String(richMenuId)), params); return (0, utils_1.ensureJSON)(res); } } exports.MessagingApiBlobClient = MessagingApiBlobClient;