public Task <SuggestEmailResponse> QueryEmail(string email) { var request = new RestRequest(EMAIL_RESOURCE, Method.POST); var query = new SuggestQuery(email); return(Execute <SuggestEmailResponse>(request, query)); }
private async Task <T> Execute <T>(RestRequest request, SuggestQuery query) where T : new() { request.AddHeader("Authorization", "Token " + token); request.AddHeader("Content-Type", contentType.Name); request.AddHeader("Accept", contentType.Name); request.RequestFormat = contentType.Format; request.XmlSerializer.ContentType = contentType.Name; request.JsonSerializer = NewtonsoftJsonSerializer.Default; request.AddJsonBody(query); var response = await client.ExecuteTaskAsync <T>(request); if (response.ErrorException != null) { throw response.ErrorException; } return(response.Data); }