{"size": 1362, "ext": "js", "max_stars_repo_path": "src/features/users/services/UserApi.js", "max_stars_repo_name": "helabenkhalfallah/yo-mess-application", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/features/users/services/UserApi.js", "max_issues_repo_name": "helabenkhalfallah/yo-mess-application", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/features/users/services/UserApi.js", "max_forks_repo_name": "helabenkhalfallah/yo-mess-application", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 17.4615384615, "max_line_length": 60, "alphanum_fraction": 0.6534508076}
import axios from 'axios';
import {
  SessionUtils,
} from '../../../core';
import UserServicesConstants from './UserServicesConstants';

const {
  USER_LOGIN_SERVICE_PATH,
  USER_LOGOUT_SERVICE_PATH,
  USER_FRIENDS_SERVICE_PATH,
  USER_PROFILE_SERVICE_PATH,
} = UserServicesConstants;

const userLoginQuery = (params) => {
  const {
    userEmail,
    userPassword,
  } = params || {};
  let url = USER_LOGIN_SERVICE_PATH;
  url += `?user_email=${userEmail}`;
  url += `&user_password=${userPassword}`;

  const headers = {
    Authorization: SessionUtils.loadToken(),
  };

  return axios({
    method: 'get',
    url,
    headers,
  });
};

const userProfileQuery = () => {
  const headers = {
    Authorization: SessionUtils.loadToken(),
  };

  return axios({
    method: 'get',
    url: USER_PROFILE_SERVICE_PATH,
    headers,
  });
};

const userLogOutQuery = () => {
  const headers = {
    Authorization: SessionUtils.loadToken(),
  };

  return axios({
    method: 'get',
    url: USER_LOGOUT_SERVICE_PATH,
    headers,
  });
};

const userFriendsQuery = () => {
  const headers = {
    Authorization: SessionUtils.loadToken(),
  };

  return axios({
    method: 'get',
    url: USER_FRIENDS_SERVICE_PATH,
    headers,
  });
};

const UserApi = {
  userLoginQuery,
  userLogOutQuery,
  userFriendsQuery,
  userProfileQuery,
};

export default UserApi;
