UNPKG

fruitstand

Version:
39 lines (33 loc) 882 B
/** * Parse profile. * * @param {Object|String} json * @return {Object} * @api private */ exports.parse = function(json) { if ('string' == typeof json) { json = JSON.parse(json); } var profile = {}; profile.id = json.id; profile.username = json.username; profile.displayName = json.name; profile.name = { familyName: json.last_name, givenName: json.first_name, middleName: json.middle_name }; profile.gender = json.gender; profile.profileUrl = json.link; if (json.email) { profile.emails = [{ value: json.email }]; } if (json.picture) { if (typeof json.picture == 'object' && json.picture.data) { // October 2012 Breaking Changes profile.photos = [{ value: json.picture.data.url }]; } else { profile.photos = [{ value: json.picture }]; } } return profile; };