profile.js
528 Bytes
/**
* Parse profile.
*
* @param {object|string} json
* @return {object}
* @access public
*/
exports.parse = function(json) {
if ('string' == typeof json) {
json = JSON.parse(json);
}
var profile = {};
profile.id = String(json.id);
profile.displayName = json.name;
profile.username = json.login;
profile.profileUrl = json.html_url;
if (json.email) {
profile.emails = [{ value: json.email }];
}
if (json.avatar_url) {
profile.photos = [{ value: json.avatar_url }];
}
return profile;
};