Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
pushCarouselTemplate(
altText: string,
columns: LineTypes.ColumnObject[],
{
imageAspectRatio,
imageSize,
...options
}: {
imageAspectRatio?: 'rectangle' | 'square';
imageSize?: 'cover' | 'contain';
} & LineTypes.MessageOptions = {}
) {
return this.push(
[
Line.createCarouselTemplate(altText, columns, {
imageAspectRatio,
imageSize,
...options,
}),
],
options
);
}
toLineMessage() {
const columns = this.data.map(el => {
return {
thumbnailImageUrl: el.images === undefined ? el.album.images[1].url : el.images[1].url,
title: el.name === undefined ? el.title.slice(0, 40) : el.name.slice(0, 40),
text: el.description === undefined || el.description === '' ? ' ' : el.description.slice(0, 60),
actions: [{
type: 'uri',
label: 'Open in KKBOX',
uri: this.dataType === 'artist' ? el.url : `https://widget.kkbox.com/v1/?id=${el.id}&type=${this.dataType === 'track' ? 'song' : this.dataType}`
}]
}
}).slice(0, 10)
return Line.createCarouselTemplate('為您播放', columns, {imageAspectRatio: 'square', imageSize: 'cover'})
}
replyCarouselTemplate(
altText: string,
columns: LineTypes.ColumnObject[],
{
imageAspectRatio,
imageSize,
...options
}: {
imageAspectRatio?: 'rectangle' | 'square';
imageSize?: 'cover' | 'contain';
} & LineTypes.MessageOptions = {}
) {
return this.reply(
[
Line.createCarouselTemplate(altText, columns, {
imageAspectRatio,
imageSize,
...options,
}),
],
options
);
}
sendCarouselTemplate(
altText: string,
columns: LineTypes.ColumnObject[],
{
imageAspectRatio,
imageSize,
...options
}: {
imageAspectRatio?: 'rectangle' | 'square';
imageSize?: 'cover' | 'contain';
} & LineTypes.MessageOptions = {}
) {
return this.send(
[
Line.createCarouselTemplate(altText, columns, {
imageAspectRatio,
imageSize,
...options,
}),
],
options
);
}