public async Task <FullContactResponse> Enrichment(PersonSummaryObject personSummary) { using (HttpClient client = new HttpClient()) { client.BaseAddress = new Uri(enrichApi); client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", _clientId); var json = SerializeObject(personSummary); var response = await client.PostAsync("person.enrich", new StringContent(json, Encoding.UTF8, "application/json")); if (response.IsSuccessStatusCode) { var rawResponse = await response.Content.ReadAsStringAsync(); RawEnrichment rawEnrichment = JsonConvert.DeserializeObject <RawEnrichment>(rawResponse); return(FullContactResponse.CreateNew(rawEnrichment)); } else if (response.StatusCode == System.Net.HttpStatusCode.NotFound) { return(FullContactResponse.NotFound()); } else { return(FullContactResponse.Error(response.ToString())); } } }
public static FullContactResponse CreateNew(RawEnrichment rawEnrichment) { return(new FullContactResponse(rawEnrichment, FullContactResponseStatus.DataFound)); }
protected FullContactResponse(RawEnrichment rawEnrichment, FullContactResponseStatus status) { Enrichment = rawEnrichment; Status = status; }