public async Task <HttpContent> ProcessPresence(Payload Payload, AuthenticationResponse AuthenticationResponse, PushTopic PushTopic) { SalesforceObjects.Presence Presence = JsonConvert.DeserializeObject <SalesforceObjects.Presence> (JsonConvert.SerializeObject(PushTopic.SObject)); SalesforceObjects.ServicePresenceStatus ServicePresenceStatus = await this.RetrievePresenceName(AuthenticationResponse, Presence); User User = await this.RetrieveUser(AuthenticationResponse, Presence.UserId); Payload.presence = new Presence(ServicePresenceStatus.MasterLabel, User.Name, Presence.UserId); string Content = JsonConvert.SerializeObject(Payload); return(new StringContent(Content, Encoding.UTF8, "application/json")); }
public async Task <SalesforceObjects.ServicePresenceStatus> RetrievePresenceName(AuthenticationResponse Auth, SalesforceObjects.Presence presence) { try { HttpRequestMessage RetrievePresenceName = new HttpRequestMessage(HttpMethod.Get, Auth.instance_url + "/services/data/v45.0/sobjects/ServicePresenceStatus/" + presence.ServicePresenceStatusId); RetrievePresenceName.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Auth.access_token); HttpResponseMessage RetrievePresenceNameResponse = await httpClient.SendAsync(RetrievePresenceName); SalesforceObjects.ServicePresenceStatus ServicePresenceStatus = JsonConvert.DeserializeObject <SalesforceObjects.ServicePresenceStatus> ( await RetrievePresenceNameResponse.Content.ReadAsStringAsync()); return(ServicePresenceStatus); } catch (Exception ex) { throw ex; } }