Skip to content

Commit 494737b

Browse files
Renaming Response variables
1 parent 85c05df commit 494737b

File tree

5 files changed

+27
-23
lines changed

5 files changed

+27
-23
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file.
33

44
This project adheres to [Semantic Versioning](http://semver.org/).
55

6+
## [2.0.0] - 2016-06-03
7+
### Changed
8+
- Made the Response variables non-redundant. e.g. response.ResponseBody becomes response.Body
9+
610
## [1.0.2] - 2016-03-17
711
### Added
812
- We are live!

CSharpHTTPClient/Client.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ namespace SendGrid.CSharp.HTTP.Client
1515
public class Response
1616
{
1717
public HttpStatusCode StatusCode;
18-
public HttpContent ResponseBody;
19-
public HttpResponseHeaders ResponseHeaders;
18+
public HttpContent Body;
19+
public HttpResponseHeaders Headers;
2020

2121
/// <summary>
2222
/// Holds the response from an API call.
@@ -27,8 +27,8 @@ public class Response
2727
public Response(HttpStatusCode statusCode, HttpContent responseBody, HttpResponseHeaders responseHeaders)
2828
{
2929
StatusCode = statusCode;
30-
ResponseBody = responseBody;
31-
ResponseHeaders = responseHeaders;
30+
Body = responseBody;
31+
Headers = responseHeaders;
3232
}
3333

3434
/// <summary>

Example/Example.cs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,16 @@ static void Main(string[] args)
2929
requestHeaders.Add("X-Test", "test");
3030
dynamic response = client.version("v3").api_keys.get(queryParams: queryParams, requestHeaders: requestHeaders);
3131
// Console.WriteLine(response.StatusCode);
32-
// Console.WriteLine(response.ResponseBody.ReadAsStringAsync().Result);
33-
// Console.WriteLine(response.ResponseHeaders.ToString());
32+
// Console.WriteLine(response.Body.ReadAsStringAsync().Result);
33+
// Console.WriteLine(response.Headers.ToString());
3434

35-
var dssResponseBody = response.DeserializeResponseBody(response.ResponseBody);
35+
var dssResponseBody = response.DeserializeResponseBody(response.Body);
3636
foreach ( var value in dssResponseBody["result"])
3737
{
3838
Console.WriteLine("name: {0}, api_key_id: {1}",value["name"], value["api_key_id"]);
3939
}
4040

41-
var dssResponseHeaders = response.DeserializeResponseHeaders(response.ResponseHeaders);
41+
var dssResponseHeaders = response.DeserializeResponseHeaders(response.Headers);
4242
foreach (var pair in dssResponseHeaders)
4343
{
4444
Console.WriteLine("{0}: {1}", pair.Key, pair.Value);
@@ -60,10 +60,10 @@ static void Main(string[] args)
6060
requestHeaders.Add("X-Test", "test2");
6161
response = client.api_keys.post(requestBody: requestBody, requestHeaders: requestHeaders);
6262
Console.WriteLine(response.StatusCode);
63-
Console.WriteLine(response.ResponseBody.ReadAsStringAsync().Result);
64-
Console.WriteLine(response.ResponseHeaders.ToString());
63+
Console.WriteLine(response.Body.ReadAsStringAsync().Result);
64+
Console.WriteLine(response.Headers.ToString());
6565
JavaScriptSerializer jss = new JavaScriptSerializer();
66-
var ds_response = jss.Deserialize<Dictionary<string, dynamic>>(response.ResponseBody.ReadAsStringAsync().Result);
66+
var ds_response = jss.Deserialize<Dictionary<string, dynamic>>(response.Body.ReadAsStringAsync().Result);
6767
string api_key_id = ds_response["api_key_id"];
6868

6969
Console.WriteLine("\n\nPress any key to continue to GET single.");
@@ -72,8 +72,8 @@ static void Main(string[] args)
7272
// GET Single
7373
response = client.api_keys._(api_key_id).get();
7474
Console.WriteLine(response.StatusCode);
75-
Console.WriteLine(response.ResponseBody.ReadAsStringAsync().Result);
76-
Console.WriteLine(response.ResponseHeaders.ToString());
75+
Console.WriteLine(response.Body.ReadAsStringAsync().Result);
76+
Console.WriteLine(response.Headers.ToString());
7777

7878
Console.WriteLine("\n\nPress any key to continue to PATCH.");
7979
Console.ReadLine();
@@ -84,8 +84,8 @@ static void Main(string[] args)
8484
}";
8585
response = client.api_keys._(api_key_id).patch(requestBody: requestBody);
8686
Console.WriteLine(response.StatusCode);
87-
Console.WriteLine(response.ResponseBody.ReadAsStringAsync().Result);
88-
Console.WriteLine(response.ResponseHeaders.ToString());
87+
Console.WriteLine(response.Body.ReadAsStringAsync().Result);
88+
Console.WriteLine(response.Headers.ToString());
8989

9090
Console.WriteLine("\n\nPress any key to continue to PUT.");
9191
Console.ReadLine();
@@ -100,16 +100,16 @@ static void Main(string[] args)
100100
}";
101101
response = client.api_keys._(api_key_id).put(requestBody: requestBody);
102102
Console.WriteLine(response.StatusCode);
103-
Console.WriteLine(response.ResponseBody.ReadAsStringAsync().Result);
104-
Console.WriteLine(response.ResponseHeaders.ToString());
103+
Console.WriteLine(response.Body.ReadAsStringAsync().Result);
104+
Console.WriteLine(response.Headers.ToString());
105105

106106
Console.WriteLine("\n\nPress any key to continue to DELETE.");
107107
Console.ReadLine();
108108

109109
// DELETE
110110
response = client.api_keys._(api_key_id).delete();
111111
Console.WriteLine(response.StatusCode);
112-
Console.WriteLine(response.ResponseHeaders.ToString());
112+
Console.WriteLine(response.Headers.ToString());
113113

114114
Console.WriteLine("\n\nPress any key to exit.");
115115
Console.ReadLine();

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ globalRequestHeaders.Add("Authorization", "Bearer XXXXXXX");
3434
dynamic client = new Client(host: baseUrl, requestHeaders: globalRequestHeaders);
3535
client.your.api._(param).call.get()
3636
Console.WriteLine(response.StatusCode);
37-
Console.WriteLine(response.ResponseBody.ReadAsStringAsync().Result);
38-
Console.WriteLine(response.ResponseHeaders.ToString());
37+
Console.WriteLine(response.Body.ReadAsStringAsync().Result);
38+
Console.WriteLine(response.Headers.ToString());
3939
```
4040

4141
`POST /your/api/{param}/call` with headers, query parameters and a request body with versioning.
@@ -51,8 +51,8 @@ var response = client.your.api._(param).call.post(requestBody: requestBody,
5151
queryParams: queryParams,
5252
requestHeaders: requestHeaders)
5353
Console.WriteLine(response.StatusCode);
54-
Console.WriteLine(response.ResponseBody.ReadAsStringAsync().Result);
55-
Console.WriteLine(response.ResponseHeaders.ToString());
54+
Console.WriteLine(response.Body.ReadAsStringAsync().Result);
55+
Console.WriteLine(response.Headers.ToString());
5656
```
5757

5858
# Usage

UnitTest/UnitTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public void TestMethodCall()
7272
Assert.IsNotNull(response);
7373
Assert.AreEqual(response.StatusCode, HttpStatusCode.OK);
7474
var content = new StringContent("{'test': 'test_content'}", Encoding.UTF8, "application/json");
75-
Assert.AreEqual(response.ResponseBody.ReadAsStringAsync().Result, content.ReadAsStringAsync().Result);
75+
Assert.AreEqual(response.Body.ReadAsStringAsync().Result, content.ReadAsStringAsync().Result);
7676
}
7777
}
7878
}

0 commit comments

Comments
 (0)