messaging-api-line
Version:
Messaging API client for LINE
90 lines • 3.06 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
function createText(text, options = {}) {
return Object.assign({ type: 'text', text }, options);
}
function createImage(image, options = {}) {
return Object.assign({ type: 'image', originalContentUrl: image.originalContentUrl, previewImageUrl: image.previewImageUrl || image.originalContentUrl }, options);
}
function createVideo(video, options = {}) {
return Object.assign({ type: 'video', originalContentUrl: video.originalContentUrl, previewImageUrl: video.previewImageUrl }, options);
}
function createAudio(audio, options = {}) {
return Object.assign({ type: 'audio', originalContentUrl: audio.originalContentUrl, duration: audio.duration }, options);
}
function createLocation({ title, address, latitude, longitude }, options = {}) {
return Object.assign({ type: 'location', title,
address,
latitude,
longitude }, options);
}
function createSticker(sticker, options = {}) {
return Object.assign({ type: 'sticker', packageId: sticker.packageId, stickerId: sticker.stickerId }, options);
}
function createImagemap(altText, { baseUrl, baseSize, video, actions, }, options = {}) {
return Object.assign({ type: 'imagemap', baseUrl,
altText,
baseSize,
video,
actions }, options);
}
function createTemplate(altText, template, options = {}) {
return Object.assign({ type: 'template', altText,
template }, options);
}
function createButtonTemplate(altText, { thumbnailImageUrl, imageAspectRatio, imageSize, imageBackgroundColor, title, text, defaultAction, actions, }, options = {}) {
return createTemplate(altText, {
type: 'buttons',
thumbnailImageUrl,
imageAspectRatio,
imageSize,
imageBackgroundColor,
title,
text,
defaultAction,
actions,
}, options);
}
function createConfirmTemplate(altText, { text, actions, }, options = {}) {
return createTemplate(altText, {
type: 'confirm',
text,
actions,
}, options);
}
function createCarouselTemplate(altText, columns, { imageAspectRatio, imageSize, quickReply, } = {}) {
return createTemplate(altText, {
type: 'carousel',
columns,
imageAspectRatio,
imageSize,
}, { quickReply });
}
function createImageCarouselTemplate(altText, columns, options = {}) {
return createTemplate(altText, {
type: 'image_carousel',
columns,
}, options);
}
function createFlex(altText, contents, options = {}) {
return Object.assign({ type: 'flex', altText,
contents }, options);
}
const Line = {
createText,
createImage,
createVideo,
createAudio,
createLocation,
createSticker,
createImagemap,
createTemplate,
createButtonsTemplate: createButtonTemplate,
createButtonTemplate,
createConfirmTemplate,
createCarouselTemplate,
createImageCarouselTemplate,
createFlex,
};
exports.default = Line;
//# sourceMappingURL=Line.js.map