Created
October 3, 2017 18:37
-
-
Save mlimaloureiro/7ebef5f60ff726d9998451bbb0911a08 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
const delimiter = "\n"; | |
const utils = require('./utils.js'); | |
function transform(item) { | |
// don't worry about this utils function, just look at transformProfile is doing, | |
// receiving the streamData and creating an array of object literals with the atomic facts | |
// we want to store | |
return utils.arrayObjectToString(transformProfile(item), delimiter); | |
} | |
function transformProfile(streamData) { | |
return [ | |
{ | |
id: streamData['id'], | |
event_name: 'accommodation_provider_updated_name', | |
accommodation_provider_id: streamData['accommodation_provider_id'], | |
field: 'name', | |
value: streamData['profile']['name'], | |
timestamp: streamData['timestamp'] | |
}, | |
{ | |
id: streamData['id'], | |
event_name: 'accommodation_provider_updated_email_address', | |
accommodation_provider_id: streamData['accommodation_provider_id'], | |
field: 'email_address', | |
value: streamData['profile']['email_address']['email_address'], | |
timestamp: streamData['timestamp'] | |
}, | |
]; | |
} | |
exports.transform = transform; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment