...
• CandidateDeleted
• CandidateUpdated
• CandidateStatusUpdated
• CandidateDeletedByUser
• CandidateDeletedOwn
...
Code Block |
---|
using Newtonsoft.Json; using Newtonsoft.Json.Linq; using System; using System.Net; using System.Net.Http; using System.Threading.Tasks; using System.Web.Http; namespace HrmtsEventsReceiver.Controllers { public class HRMTSMessage { public string EventType; public int ProjectId; } public class HRMTSEvent { public int DepartmentId; public int CustomerId; public HRMTSMessage Message; } public class EventsController : ApiController { [HttpPost] public async Task<HttpResponseMessage> ReceiveEvent() { var content = await Request.Content.ReadAsStringAsync(); HRMTSEvent hrmtsEvent = (HRMTSEvent)JsonConvert.DeserializeObject(content, typeof(HRMTSEvent)); if (hrmtsEvent != null) { if (hrmtsEvent.Message.EventType == "ProjectUpdated") { HttpClient client = new HttpClient(); client.BaseAddress = new Uri("https://recruiter-api.hr-manager.net/restful.svc/v2/"); string url = string.Format("{0}/{1}/positions/json?posid={2}", "<customeralias>", "<apikey>", hrmtsEvent.Message.ProjectId); HttpResponseMessage res = await client.GetAsync(url); JObject json = await res.Content.ReadAsAsync<JObject>(); JObject position = ((JObject)((JArray)json.GetValue("Items"))[0]); // DO stuff with the Position object in my integration app return new HttpResponseMessage(HttpStatusCode.OK); } else if (hrmtsEvent.Message.EventType == "CandidateStatusUpdated") { HttpClient client = new HttpClient(); //Do authentication stuff here. //call application api to get application details client.BaseAddress = new Uri($"https://api.talentech.io/TalentRecruiter/V2/"); string url = string.Format($"/applications/{hrmtsEvent.Message.ApplicationId}"); HttpResponseMessage res = await client.GetAsync(url); JObject applicationDetails = await res.Content.ReadAsAsync<JObject>(); // DO stuff with the application object in my integration app return new HttpResponseMessage(HttpStatusCode.OK); } return new HttpResponseMessage(HttpStatusCode.OK); } return new HttpResponseMessage(HttpStatusCode.NotImplemented); } } } |
Testing with NGROK
You can test your integration locally before you deploy by creating a pipeline to your localhost by using ngrok.
...