jaredhanson/passport-twitter

View on GitHub
lib/profile.js

Summary

Maintainability
A
0 mins
Test Coverage
/**
 * Parse profile.
 *
 * @param {object|string} json
 * @return {object}
 * @api public
 */
exports.parse = function(json) {
  if ('string' == typeof json) {
    json = JSON.parse(json);
  }
  
  var profile = {};
  profile.id = String(json.id);
  if (json.id_str) { profile.id = json.id_str; }
  profile.username = json.screen_name;
  profile.displayName = json.name;
  if (json.email) {
    profile.emails = [{ value: json.email }];
  }
  profile.photos = [{ value: json.profile_image_url_https }];
  
  return profile;
};