diff --git a/src/Mandrill.net/MandrillExportsApi.cs b/src/Mandrill.net/MandrillExportsApi.cs index d1ed4db..a24a0fd 100644 --- a/src/Mandrill.net/MandrillExportsApi.cs +++ b/src/Mandrill.net/MandrillExportsApi.cs @@ -16,40 +16,40 @@ public MandrillExportsApi(MandrillApi mandrillApi) } public MandrillApi MandrillApi { get; set; } - public async Task> ListAsync() + public Task> ListAsync() { - return await MandrillApi.PostAsync>("exports/list.json", + return MandrillApi.PostAsync>("exports/list.json", new MandrillExportRequest()); } - public async Task InfoAsync(string id) + public Task InfoAsync(string id) { - return await MandrillApi.PostAsync("exports/info.json", + return MandrillApi.PostAsync("exports/info.json", new MandrillExportRequest { Id = id }); } - public async Task RejectsAsync(string notifyEmail) + public Task RejectsAsync(string notifyEmail) { - return await MandrillApi.PostAsync("exports/rejects.json", + return MandrillApi.PostAsync("exports/rejects.json", new MandrillExportRequest { NotifyEmail = notifyEmail }); } - public async Task WhitelistAsync(string notifyEmail) + public Task WhitelistAsync(string notifyEmail) { - return await MandrillApi.PostAsync("exports/whitelist.json", + return MandrillApi.PostAsync("exports/whitelist.json", new MandrillExportRequest { NotifyEmail = notifyEmail }); } - public async Task ActivityAsync(string notifyEmail, + public Task ActivityAsync(string notifyEmail, DateTime? dateFrom = null, DateTime? dateTo = null, IList tags = null, @@ -57,7 +57,7 @@ public async Task ActivityAsync(string notifyEmail, IList states = null, IList apiKeys = null) { - return await MandrillApi.PostAsync("exports/activity", + return MandrillApi.PostAsync("exports/activity", new MandrillExportRequest { NotifyEmail = notifyEmail, diff --git a/src/Mandrill.net/MandrillRequest.cs b/src/Mandrill.net/MandrillRequest.cs index c034141..fd651c5 100644 --- a/src/Mandrill.net/MandrillRequest.cs +++ b/src/Mandrill.net/MandrillRequest.cs @@ -82,17 +82,18 @@ public override async Task PostAsync(string requ MandrillSerializer.Serialize(jsonWriter, value); jsonWriter.Flush(); inputStream.Seek(0, SeekOrigin.Begin); - using (var requestStream = await request.GetRequestStreamAsync()) + using (var requestStream = await request.GetRequestStreamAsync().ConfigureAwait(false)) { - await inputStream.CopyToAsync(requestStream); + await inputStream.CopyToAsync(requestStream).ConfigureAwait(false); } } try { - using (var response = (HttpWebResponse) await request.GetResponseAsync()) + using (var response = (HttpWebResponse) await request.GetResponseAsync().ConfigureAwait(false)) using (var responseStream = response.GetResponseStream()) - using (var jsonReader = new JsonTextReader(new StreamReader(responseStream))) + using(var responseReader = new StreamReader(responseStream)) + using (var jsonReader = new JsonTextReader(responseReader)) { return MandrillSerializer.Deserialize(jsonReader); } @@ -113,7 +114,8 @@ private static MandrillException ExtractMandrillErrorResponse(string requestUri, { using (var response = webResponse) using (var responseStream = response.GetResponseStream()) - using (var jsonReader = new JsonTextReader(new StreamReader(responseStream))) + using (var responseReader = new StreamReader(responseStream)) + using (var jsonReader = new JsonTextReader(responseReader)) { error = MandrillSerializer.Deserialize(jsonReader); } diff --git a/src/Mandrill.net/MandrillUsersApi.cs b/src/Mandrill.net/MandrillUsersApi.cs index 6158662..3ee86d5 100644 --- a/src/Mandrill.net/MandrillUsersApi.cs +++ b/src/Mandrill.net/MandrillUsersApi.cs @@ -17,7 +17,7 @@ public MandrillUsersApi(MandrillApi mandrillApi) public async Task PingAsync() { return (await MandrillApi.PostAsync("users/ping2.json", - new MandrillUsersRequest()))["PING"].Value(); + new MandrillUsersRequest()).ConfigureAwait(false))["PING"].Value(); } public Task> SendersAsync()