all files / api/toJSON/ video.js

100% Statements 7/7
75% Branches 3/4
100% Functions 0/0
100% Lines 7/7
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33                                                   
'use strict';
 
const R = require('ramda');
 
module.exports = R.curry(tuple => {
 
    const video = tuple[1];
    const staticContent = !R.isNil(tuple[0].static_content) ? tuple[0].static_content : {};
 
    const attributes = R.merge({
        subType: video.sub_type,
        videoId: video.video_id,
        title: video.title
    }, staticContent);
 
    const meta = R.merge(tuple[0], {
        "type": "video",
        "lastModifiedDate": video.last_modified_date || video.updated_at,
        "id": video.id
    });
 
    return [meta, {
        data: {
            type: 'video',
            id: video.escenic_id,
            attributes: attributes,
            links: {
                screenshotUrl: video.thumbnail_url
            }
        }
    }];
});