'use strict';
const R = require('ramda');
function createInstagram(type, data) {
return {
data: {
type,
id: data.instagramId,
attributes: {
//kept for compatability with the pulveriser.
instagramId: data.instagramId,
caption: data.caption,
username: data.username,
imageUrl: R.path(['image_url'], data),
profileImageUrl: R.path(['profileImageUrl'], data)
},
links: {
url: `${data.url}/embed`
}
}
};
}
function createTweet(id, type, data) {
return {
data: {
type: type,
id: id,
//kept for compatability with the pulveriser.
attributes: R.merge({[`tweetId`]: id}, data)
}
};
}
module.exports = tuple => {
const item = tuple[1];
const meta = R.assoc("id", tuple[0].source_id || item.id, tuple[0]);
return [meta, meta.type === 'tweet' ?
createTweet(item.id, meta.type, item.data) :
createInstagram(meta.type, item.data)];
};
|