all files / api/toJSON/ html.js

93.33% Statements 14/15
66.67% Branches 4/6
100% Functions 0/0
93.33% Lines 14/15
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 34 35 36 37 38 39 40 41 42 43                                                         
'use strict';
 
const R = require('ramda');
let createSocial = require('./social');
 
module.exports = tuple => {
    const html = tuple[1];
    const tweet = R.path(['html_content_item', 'tweet'], html);
    const instagram = R.path(['html_content_item', 'instagram'], html);
    
    if (!R.isNil(tweet)) {
        return createSocial([{type: 'tweet', source_id: html.id}, tweet]);
    }
 
    Iif (!R.isNil(instagram)) {
        return createSocial([{type: 'instagram', source_id: html.id}, instagram]);
    }
 
    const meta = {
        "type": "html",
        "id": html.id,
        "lastModifiedDate": html.last_modified_date || html.updated_at
    };
 
    const attributes = {
        "subType": "interactiveHTML",
        "label": "Interactive Content"
    };
 
    const links = {
        "url": "embeddedHTMLurlPlaceholder"
    };
 
    const data = {
        "type":"embed",
        "id": html.escenic_id,
        attributes,
        links
    };
 
    return [meta, {data}];
};