{"size": 966, "ext": "js", "max_stars_repo_path": "imports/modules/get-oauth-profile.js", "max_stars_repo_name": "betharavikiran/art_gallery", "max_stars_repo_stars_event_min_datetime": "2019-05-21T23:32:46.000Z", "max_stars_repo_stars_event_max_datetime": "2019-05-21T23:32:46.000Z", "max_issues_repo_path": "code/imports/modules/get-oauth-profile.js", "max_issues_repo_name": "themeteorchef/building-a-nested-comments-feature", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "code/imports/modules/get-oauth-profile.js", "max_forks_repo_name": "themeteorchef/building-a-nested-comments-feature", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 24.15, "max_line_length": 89, "alphanum_fraction": 0.6739130435}
const parseGoogleData = service => ({
  email: service.email,
  name: {
    first: service.given_name,
    last: service.family_name,
  },
});

const parseGithubData = (profile, service) => {
  const name = profile.name.split(' ');
  return {
    email: service.email,
    name: {
      first: name[0],
      last: name[1],
    },
  };
};

const parseFacebookData = service => ({
  email: service.email,
  name: {
    first: service.first_name,
    last: service.last_name,
  },
});

const getDataForService = (profile, services) => {
  if (services.facebook) return parseFacebookData(services.facebook);
  if (services.github) return parseGithubData(profile, services.github);
  if (services.google) return parseGoogleData(services.google);
  return null;
};

export default (options, user) => {
  const isOAuth = !options.password;
  const serviceData = isOAuth ? getDataForService(options.profile, user.services) : null;
  return isOAuth ? serviceData : null;
};
