text: /**
   * name : users.js
   * author : Aman Jung Karki
   * Date : 11-Nov-2019
   * Description : All users related api call.
   */
  
  //dependencies
  const request = require('request');
  const userServiceUrl = process.env.USER_SERVICE_URL;
  
  const profile = function ( token,userId = "" ) {
      return new Promise(async (resolve, reject) => {
          try {
  
              let url = userServiceUrl + messageConstants.endpoints.USER_READ;
  
              if( userId !== "" ) {
                  url = url + "/" + userId;
              }
  
              const options = {
                  headers : {
                      "content-type": "application/json",
                      "x-authenticated-user-token" : token
                  }
              };
  
              request.post(url,options,kendraCallback);
  
              function kendraCallback(err, data) {
  
                  let result = {
                      success : true
                  };
  
                  if (err) {
                      result.success = false;
                  } else {
  
                      let response = JSON.parse(data.body);
                      if( response.status === HTTP_STATUS_CODE['ok'].status ) {
                          result["data"] = response.result;
                      } else {
                          result.success = false;
                      }
  
                  }
  
                  return resolve(result);
              }
  
          } catch (error) {
              return reject(error);
          }
      })
  }
  
  module.exports = {
      profile : profile
  }
  