UNPKG

@line/bot-sdk

Version:
197 lines 8.35 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. */ 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.MessagingApiBlobClient = 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 MessagingApiBlobClient { constructor(config) { const baseURL = config.baseURL || "https://api-data.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, }); } /** * 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 (await this.getMessageContentWithHttpInfo(messageId)).body; } /** * Download image, video, and audio data sent from users.. * This method includes HttpInfo object to return additional information. * @param messageId Message ID of video or audio * * @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-content"> Documentation</a> */ async getMessageContentWithHttpInfo(messageId) { const requestPath = (0, utils_js_1.buildPath)("/v2/bot/message/{messageId}/content", { messageId: messageId, }); const response = await this.httpClient.get(requestPath); return { httpResponse: response, body: (0, http_fetch_js_1.convertResponseToReadable)(response), }; } /** * 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 (await this.getMessageContentPreviewWithHttpInfo(messageId)).body; } /** * Get a preview image of the image or video. * This method includes HttpInfo object to return additional information. * @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 getMessageContentPreviewWithHttpInfo(messageId) { const requestPath = (0, utils_js_1.buildPath)("/v2/bot/message/{messageId}/content/preview", { messageId: messageId, }); const response = await this.httpClient.get(requestPath); return { httpResponse: response, body: (0, http_fetch_js_1.convertResponseToReadable)(response), }; } /** * 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) { return (await this.getMessageContentTranscodingByMessageIdWithHttpInfo(messageId)).body; } /** * Verify the preparation status of a video or audio for getting. * This method includes HttpInfo object to return additional information. * @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 getMessageContentTranscodingByMessageIdWithHttpInfo(messageId) { const requestPath = (0, utils_js_1.buildPath)("/v2/bot/message/{messageId}/content/transcoding", { messageId: messageId, }); const res = await this.httpClient.get(requestPath); const text = await res.text(); const parsedBody = text ? JSON.parse(text) : null; return { httpResponse: res, body: parsedBody }; } /** * 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 (await this.getRichMenuImageWithHttpInfo(richMenuId)).body; } /** * Download rich menu image.. * This method includes HttpInfo object to return additional information. * @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 getRichMenuImageWithHttpInfo(richMenuId) { const requestPath = (0, utils_js_1.buildPath)("/v2/bot/richmenu/{richMenuId}/content", { richMenuId: richMenuId, }); const response = await this.httpClient.get(requestPath); return { httpResponse: response, body: (0, http_fetch_js_1.convertResponseToReadable)(response), }; } /** * 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) { return (await this.setRichMenuImageWithHttpInfo(richMenuId, body)).body; } /** * Upload rich menu image. * This method includes HttpInfo object to return additional information. * @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 setRichMenuImageWithHttpInfo(richMenuId, body) { const requestPath = (0, utils_js_1.buildPath)("/v2/bot/richmenu/{richMenuId}/content", { richMenuId: richMenuId, }); const params = body; const res = await this.httpClient.postBinaryContent(requestPath, params); const text = await res.text(); const parsedBody = text ? JSON.parse(text) : null; return { httpResponse: res, body: parsedBody }; } } exports.MessagingApiBlobClient = MessagingApiBlobClient; //# sourceMappingURL=messagingApiBlobClient.js.map