@@ -21,17 +21,17 @@ public class Response
21
21
/// <summary>
22
22
/// The status code returned from Twilio SendGrid.
23
23
/// </summary>
24
- private HttpStatusCode statusCode ;
24
+ private HttpStatusCode _statusCode ;
25
25
26
26
/// <summary>
27
27
/// The response body returned from Twilio SendGrid.
28
28
/// </summary>
29
- private HttpContent body ;
29
+ private HttpContent _body ;
30
30
31
31
/// <summary>
32
32
/// The response headers returned from Twilio SendGrid.
33
33
/// </summary>
34
- private HttpResponseHeaders headers ;
34
+ private HttpResponseHeaders _headers ;
35
35
36
36
/// <summary>
37
37
/// Initializes a new instance of the <see cref="Response"/> class.
@@ -53,12 +53,12 @@ public HttpStatusCode StatusCode
53
53
{
54
54
get
55
55
{
56
- return this . statusCode ;
56
+ return this . _statusCode ;
57
57
}
58
58
59
59
set
60
60
{
61
- this . statusCode = value ;
61
+ this . _statusCode = value ;
62
62
}
63
63
}
64
64
@@ -72,57 +72,67 @@ public bool IsSuccessStatusCode
72
72
73
73
/// <summary>
74
74
/// Gets or sets the response body returned from Twilio SendGrid.
75
+ /// <see href="https://docs.microsoft.com/dotnet/api/system.net.http.httpcontent"></see>
75
76
/// </summary>
76
77
public HttpContent Body
77
78
{
78
79
get
79
80
{
80
- return this . body ;
81
+ return this . _body ;
81
82
}
82
83
83
84
set
84
85
{
85
- this . body = value ;
86
+ this . _body = value ;
86
87
}
87
88
}
88
89
89
90
/// <summary>
90
91
/// 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>
91
93
/// </summary>
92
94
public HttpResponseHeaders Headers
93
95
{
94
96
get
95
97
{
96
- return this . headers ;
98
+ return this . _headers ;
97
99
}
98
100
99
101
set
100
102
{
101
- this . headers = value ;
103
+ this . _headers = value ;
102
104
}
103
105
}
104
106
105
107
/// <summary>
106
108
/// Converts string formatted response body to a Dictionary.
107
109
/// </summary>
108
- /// <param name="content">https://docs.microsoft.com/dotnet/api/system.net.http.httpcontent.</param>
109
110
/// <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 ( )
111
112
{
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 ) ;
113
119
var dsContent = JsonConvert . DeserializeObject < Dictionary < string , dynamic > > ( stringContent ) ;
114
120
return dsContent ;
115
121
}
116
122
117
123
/// <summary>
118
124
/// Converts string formatted response headers to a Dictionary.
119
125
/// </summary>
120
- /// <param name="content">https://docs.microsoft.com/dotnet/api/system.net.http.headers.httpresponseheaders.</param>
121
126
/// <returns>Dictionary object representation of HttpResponseHeaders.</returns>
122
- public virtual Dictionary < string , string > DeserializeResponseHeaders ( HttpResponseHeaders content )
127
+ public virtual Dictionary < string , string > DeserializeResponseHeaders ( )
123
128
{
124
129
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 )
126
136
{
127
137
dsContent . Add ( pair . Key , pair . Value . First ( ) ) ;
128
138
}
0 commit comments