@@ -21,17 +21,17 @@ public class Response
2121 /// <summary>
2222 /// The status code returned from Twilio SendGrid.
2323 /// </summary>
24- private HttpStatusCode statusCode ;
24+ private HttpStatusCode _statusCode ;
2525
2626 /// <summary>
2727 /// The response body returned from Twilio SendGrid.
2828 /// </summary>
29- private HttpContent body ;
29+ private HttpContent _body ;
3030
3131 /// <summary>
3232 /// The response headers returned from Twilio SendGrid.
3333 /// </summary>
34- private HttpResponseHeaders headers ;
34+ private HttpResponseHeaders _headers ;
3535
3636 /// <summary>
3737 /// Initializes a new instance of the <see cref="Response"/> class.
@@ -53,12 +53,12 @@ public HttpStatusCode StatusCode
5353 {
5454 get
5555 {
56- return this . statusCode ;
56+ return this . _statusCode ;
5757 }
5858
5959 set
6060 {
61- this . statusCode = value ;
61+ this . _statusCode = value ;
6262 }
6363 }
6464
@@ -72,57 +72,67 @@ public bool IsSuccessStatusCode
7272
7373 /// <summary>
7474 /// Gets or sets the response body returned from Twilio SendGrid.
75+ /// <see href="https://docs.microsoft.com/dotnet/api/system.net.http.httpcontent"></see>
7576 /// </summary>
7677 public HttpContent Body
7778 {
7879 get
7980 {
80- return this . body ;
81+ return this . _body ;
8182 }
8283
8384 set
8485 {
85- this . body = value ;
86+ this . _body = value ;
8687 }
8788 }
8889
8990 /// <summary>
9091 /// Gets or sets the response headers returned from Twilio SendGrid.
92+ /// <see href="https://docs.microsoft.com/dotnet/api/system.net.http.headers.httpresponseheaders"></see>
9193 /// </summary>
9294 public HttpResponseHeaders Headers
9395 {
9496 get
9597 {
96- return this . headers ;
98+ return this . _headers ;
9799 }
98100
99101 set
100102 {
101- this . headers = value ;
103+ this . _headers = value ;
102104 }
103105 }
104106
105107 /// <summary>
106108 /// Converts string formatted response body to a Dictionary.
107109 /// </summary>
108- /// <param name="content">https://docs.microsoft.com/dotnet/api/system.net.http.httpcontent.</param>
109110 /// <returns>Dictionary object representation of HttpContent.</returns>
110- public virtual async Task < Dictionary < string , dynamic > > DeserializeResponseBodyAsync ( HttpContent content )
111+ public virtual async Task < Dictionary < string , dynamic > > DeserializeResponseBodyAsync ( )
111112 {
112- var stringContent = await content . ReadAsStringAsync ( ) . ConfigureAwait ( false ) ;
113+ if ( this . _body is null )
114+ {
115+ return new Dictionary < string , dynamic > ( ) ;
116+ }
117+
118+ var stringContent = await this . _body . ReadAsStringAsync ( ) . ConfigureAwait ( false ) ;
113119 var dsContent = JsonConvert . DeserializeObject < Dictionary < string , dynamic > > ( stringContent ) ;
114120 return dsContent ;
115121 }
116122
117123 /// <summary>
118124 /// Converts string formatted response headers to a Dictionary.
119125 /// </summary>
120- /// <param name="content">https://docs.microsoft.com/dotnet/api/system.net.http.headers.httpresponseheaders.</param>
121126 /// <returns>Dictionary object representation of HttpResponseHeaders.</returns>
122- public virtual Dictionary < string , string > DeserializeResponseHeaders ( HttpResponseHeaders content )
127+ public virtual Dictionary < string , string > DeserializeResponseHeaders ( )
123128 {
124129 var dsContent = new Dictionary < string , string > ( ) ;
125- foreach ( var pair in content )
130+ if ( this . _headers == null )
131+ {
132+ return dsContent ;
133+ }
134+
135+ foreach ( var pair in this . _headers )
126136 {
127137 dsContent . Add ( pair . Key , pair . Value . First ( ) ) ;
128138 }
0 commit comments