public AgentWorkStatus GetAgentStatus(string status) { AgentWorkStatus AgentWorkStatus = new AgentWorkStatus(); if (status == "Assigned") { // todo } else if (status == "Unavailable") { AgentWorkStatus.reject = true; } else if (status == "Declined") { AgentWorkStatus.reject = true; } else if (status == "Opened") { AgentWorkStatus.accept = true; } else if (status == "Closed") { AgentWorkStatus.close = true; } else if (status == "DeclinedOnPushTimeout") { AgentWorkStatus.reject = true; } else if (status == "Canceled") { // todo } else if (status == "Transferred") { AgentWorkStatus.transferToUser = true; } return(AgentWorkStatus); }
public async Task <HttpContent> ProcessAgentWork(Payload Payload, AuthenticationResponse AuthenticationResponse, PushTopic PushTopic) { SalesforceObjects.AgentWork AgentWork = JsonConvert.DeserializeObject <SalesforceObjects.AgentWork> (JsonConvert.SerializeObject(PushTopic.SObject)); string SObjectPrefix = AgentWork.WorkItemId.Substring(0, 3); Dictionary <string, string> PrefixList = await this.RetrieveSObjects(AuthenticationResponse); string SObjectType = PrefixList.Where(Prefix => Prefix.Key == SObjectPrefix).FirstOrDefault().Value; WorkItem WorkItem = new WorkItem(AgentWork.WorkItemId, SObjectType); PicklistValue[] Statuses = await this.RetrieveStatuses(AuthenticationResponse); string status = Statuses[AgentWork.Status].Label; User User = await RetrieveUser(AuthenticationResponse, AgentWork.UserId); string UserName = User.Name; AgentWorkStatus AgentWorkStatus = this.GetAgentStatus(status); AgentWork _AgentWork = new AgentWork(AgentWork.Id, AgentWork.CreatedDate.ToString(), AgentWork.CreatedDate.ToString(), "update", AgentWorkStatus, WorkItem, UserName, AgentWork.UserId); Payload.agentWork = _AgentWork; string Content = JsonConvert.SerializeObject(Payload); return(new StringContent(Content, Encoding.UTF8, "application/json")); }