@@ -314,6 +314,93 @@ async function getJobs(criteria) {
314314 } ;
315315}
316316
317+ /**
318+ * Get member details
319+ * @param {string } handle the handle of the user
320+ * @param {string } query the query criteria
321+ * @return {Object } the object of member details
322+ */
323+ async function getMember ( handle , query ) {
324+ const token = await getM2MToken ( ) ;
325+ const url = `${ config . API . V5 } /members/${ handle } ` ;
326+ const res = await request
327+ . get ( url )
328+ . query ( query )
329+ . set ( "Authorization" , `Bearer ${ token } ` )
330+ . set ( "Accept" , "application/json" ) ;
331+ localLogger . debug ( {
332+ context : "getMember" ,
333+ message : `response body: ${ JSON . stringify ( res . body ) } ` ,
334+ } ) ;
335+ return res . body ;
336+ }
337+
338+ /**
339+ * Update member details
340+ * @param {string } handle the handle of the user
341+ * @param {object } data the data to be updated
342+ * @return {object } the object of updated member details
343+ */
344+ async function updateMember ( currentUser , data ) {
345+ const token = currentUser . jwtToken ;
346+ const url = `${ config . API . V5 } /members/${ currentUser . handle } ` ;
347+ const res = await request
348+ . put ( url )
349+ . set ( "Authorization" , token )
350+ . set ( "Content-Type" , "application/json" )
351+ . set ( "Accept" , "application/json" )
352+ . send ( data ) ;
353+ localLogger . debug ( {
354+ context : "updateMember" ,
355+ message : `response body: ${ JSON . stringify ( res . body ) } ` ,
356+ } ) ;
357+ return res . body ;
358+ }
359+
360+ /**
361+ * Get Recruit CRM profile details
362+ * @param {object } currentUser the user who performs the operation
363+ * @return {object } the object of profile details
364+ */
365+ async function getRCRMProfile ( currentUser ) {
366+ const token = currentUser . jwtToken ;
367+ const url = `${ config . RECRUIT_API } /api/recruit/profile` ;
368+ const res = await request
369+ . get ( url )
370+ . set ( "Authorization" , token )
371+ . set ( "Accept" , "application/json" ) ;
372+ localLogger . debug ( {
373+ context : "getRCRMProfile" ,
374+ message : `response body: ${ JSON . stringify ( res . body ) } ` ,
375+ } ) ;
376+ return res . body ;
377+ }
378+
379+ /**
380+ * Update Recruit CRM profile details
381+ * @param {object } currentUser the user who performs the operation
382+ * @param {object } file the resume file
383+ * @param {object } data the data to be updated
384+ * @return {object } the returned object
385+ */
386+ async function updateRCRMProfile ( currentUser , file , data ) {
387+ const token = currentUser . jwtToken ;
388+ const url = `${ config . RECRUIT_API } /api/recruit/profile` ;
389+ const res = await request
390+ . post ( url )
391+ . set ( "Authorization" , token )
392+ . set ( "Content-Type" , "multipart/form-data" )
393+ . set ( "Accept" , "application/json" )
394+ . field ( "phone" , data . phone )
395+ . field ( "availability" , data . availability )
396+ . attach ( "resume" , file . data , file . name ) ;
397+ localLogger . debug ( {
398+ context : "updateRCRMProfile" ,
399+ message : `response body: ${ JSON . stringify ( res . body ) } ` ,
400+ } ) ;
401+ return res . body ;
402+ }
403+
317404module . exports = {
318405 errorHandler,
319406 interceptor,
@@ -324,4 +411,8 @@ module.exports = {
324411 getCurrentUserDetails,
325412 getJobCandidates,
326413 getJobs,
414+ getMember,
415+ updateMember,
416+ getRCRMProfile,
417+ updateRCRMProfile,
327418} ;
0 commit comments