Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/HttpClientServiceHelper.Tests/Mock/Person.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ namespace HttpClientServiceHelper.Tests.Mock
{
public class Person
{
private string FirstName { get; set; }
private string LastName { get; set; }
private string FullName => $"{FirstName} {LastName}";
public string FirstName { get; set; }
public string LastName { get; set; }
public string FullName => $"{FirstName} {LastName}";

public static Person GetPerson()
{
Expand Down
6 changes: 3 additions & 3 deletions src/HttpClientServiceHelper/Delete.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public static async Task<HttpResponseMessage> DeleteAsync(string Route, string T
{
using (HttpClient httpClient = new HttpClient())
{
httpClient.DefaultRequestHeaders.Authorization = string.IsNullOrEmpty(Token) ? new AuthenticationHeaderValue("Bearer", Token) : null;
httpClient.DefaultRequestHeaders.Authorization = !string.IsNullOrEmpty(Token) ? new AuthenticationHeaderValue("Bearer", Token) : null;
var httpResponse = await httpClient.DeleteAsync(new Uri(Route));
return httpResponse;
}
Expand Down Expand Up @@ -101,7 +101,7 @@ public static async Task<string> DeleteAndGetResponseAsStringAsync(string Route,
{
using (HttpClient httpClient = new HttpClient())
{
httpClient.DefaultRequestHeaders.Authorization = string.IsNullOrEmpty(Token) ? new AuthenticationHeaderValue("Bearer", Token) : null;
httpClient.DefaultRequestHeaders.Authorization = !string.IsNullOrEmpty(Token) ? new AuthenticationHeaderValue("Bearer", Token) : null;
var httpResponse = await httpClient.DeleteAsync(new Uri(Route));
return await httpResponse.Content.ReadAsStringAsync();
}
Expand Down Expand Up @@ -195,7 +195,7 @@ public static async Task<string> DeleteAndGetResponseAsStringAsync(string Route,
//{
// using (HttpClient httpClient = new HttpClient())
// {
// httpClient.DefaultRequestHeaders.Authorization = string.IsNullOrEmpty(Token) ? new AuthenticationHeaderValue("Bearer", Token) : null;
// httpClient.DefaultRequestHeaders.Authorization = !string.IsNullOrEmpty(Token) ? new AuthenticationHeaderValue("Bearer", Token) : null;
// var httpResponse = await httpClient.DeleteAsync(new Uri(Route));
// if (httpResponse.IsSuccessStatusCode)
// {
Expand Down
6 changes: 3 additions & 3 deletions src/HttpClientServiceHelper/Get.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public partial class HttpClientHelper
//{
// using (HttpClient httpClient = new HttpClient())
// {
// httpClient.DefaultRequestHeaders.Authorization = string.IsNullOrEmpty(Token) ? new AuthenticationHeaderValue("Bearer", Token) : null;
// httpClient.DefaultRequestHeaders.Authorization = !string.IsNullOrEmpty(Token) ? new AuthenticationHeaderValue("Bearer", Token) : null;
// var httpResponse = await httpClient.GetAsync(new Uri(Route));
// if (httpResponse.IsSuccessStatusCode)
// {
Expand Down Expand Up @@ -208,7 +208,7 @@ public static async Task<HttpResponseMessage> GetAsync(string Route, string Toke
{
using (HttpClient httpClient = new HttpClient())
{
httpClient.DefaultRequestHeaders.Authorization = string.IsNullOrEmpty(Token) ? new AuthenticationHeaderValue("Bearer", Token) : null;
httpClient.DefaultRequestHeaders.Authorization = !string.IsNullOrEmpty(Token) ? new AuthenticationHeaderValue("Bearer", Token) : null;
var httpResponse = await httpClient.GetAsync(new Uri(Route));
return httpResponse;
}
Expand Down Expand Up @@ -276,7 +276,7 @@ public static async Task<string> GetAsStringAsync(string Route, string Token = n
{
using (HttpClient httpClient = new HttpClient())
{
httpClient.DefaultRequestHeaders.Authorization = string.IsNullOrEmpty(Token) ? new AuthenticationHeaderValue("Bearer", Token) : null;
httpClient.DefaultRequestHeaders.Authorization = !string.IsNullOrEmpty(Token) ? new AuthenticationHeaderValue("Bearer", Token) : null;
var httpResponse = await httpClient.GetAsync(new Uri(Route));
return await httpResponse.Content.ReadAsStringAsync();
}
Expand Down
6 changes: 3 additions & 3 deletions src/HttpClientServiceHelper/Patch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public static async Task<HttpResponseMessage> PatchAsync(string Route, object Mo
using (HttpClient httpClient = new HttpClient())
{
var uri = new Uri(Route);
httpClient.DefaultRequestHeaders.Authorization = string.IsNullOrEmpty(Token) ? new AuthenticationHeaderValue("Bearer", Token) : null;
httpClient.DefaultRequestHeaders.Authorization = !string.IsNullOrEmpty(Token) ? new AuthenticationHeaderValue("Bearer", Token) : null;
string jsonTransport = JsonConvert.SerializeObject(Model);
var jsonPayload = new StringContent(jsonTransport, Encoding.UTF8, "application/json");
var httpResponse = await httpClient.PatchAsync(uri, jsonPayload);
Expand Down Expand Up @@ -124,7 +124,7 @@ public static async Task<string> PatchAndGetResponseAsStringAsync(string Route,
using (HttpClient httpClient = new HttpClient())
{
var uri = new Uri(Route);
httpClient.DefaultRequestHeaders.Authorization = string.IsNullOrEmpty(Token) ? new AuthenticationHeaderValue("Bearer", Token) : null;
httpClient.DefaultRequestHeaders.Authorization = !string.IsNullOrEmpty(Token) ? new AuthenticationHeaderValue("Bearer", Token) : null;
string jsonTransport = JsonConvert.SerializeObject(Model);
var jsonPayload = new StringContent(jsonTransport, Encoding.UTF8, "application/json");
var httpResponse = await httpClient.PatchAsync(uri, jsonPayload);
Expand Down Expand Up @@ -234,7 +234,7 @@ public static async Task<string> PatchAndGetResponseAsStringAsync(string Route,
// using (HttpClient httpClient = new HttpClient())
// {
// var uri = new Uri(Route);
// httpClient.DefaultRequestHeaders.Authorization = string.IsNullOrEmpty(Token) ? new AuthenticationHeaderValue("Bearer", Token) : null;
// httpClient.DefaultRequestHeaders.Authorization = !string.IsNullOrEmpty(Token) ? new AuthenticationHeaderValue("Bearer", Token) : null;
// string jsonTransport = JsonConvert.SerializeObject(Model);
// var jsonPayload = new StringContent(jsonTransport, Encoding.UTF8, "application/json");
// var httpResponse = await httpClient.PatchAsync(uri, jsonPayload);
Expand Down
6 changes: 3 additions & 3 deletions src/HttpClientServiceHelper/Post.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public static async Task<HttpResponseMessage> PostAsync(string Route, object Mod
using (HttpClient httpClient = new HttpClient())
{
var uri = new Uri(Route);
httpClient.DefaultRequestHeaders.Authorization = string.IsNullOrEmpty(Token) ? new AuthenticationHeaderValue("Bearer", Token) : null;
httpClient.DefaultRequestHeaders.Authorization = !string.IsNullOrEmpty(Token) ? new AuthenticationHeaderValue("Bearer", Token) : null;
string jsonTransport = JsonConvert.SerializeObject(Model);
var jsonPayload = new StringContent(jsonTransport, Encoding.UTF8, "application/json");
var httpResponse = await httpClient.PostAsync(uri, jsonPayload);
Expand Down Expand Up @@ -124,7 +124,7 @@ public static async Task<string> PostAndGetResponseAsStringAsync(string Route, o
using (HttpClient httpClient = new HttpClient())
{
var uri = new Uri(Route);
httpClient.DefaultRequestHeaders.Authorization = string.IsNullOrEmpty(Token) ? new AuthenticationHeaderValue("Bearer", Token) : null;
httpClient.DefaultRequestHeaders.Authorization = !string.IsNullOrEmpty(Token) ? new AuthenticationHeaderValue("Bearer", Token) : null;
string jsonTransport = JsonConvert.SerializeObject(Model);
var jsonPayload = new StringContent(jsonTransport, Encoding.UTF8, "application/json");
var httpResponse = await httpClient.PostAsync(uri, jsonPayload);
Expand Down Expand Up @@ -234,7 +234,7 @@ public static async Task<string> PostAndGetResponseAsStringAsync(string Route, o
// using (HttpClient httpClient = new HttpClient())
// {
// var uri = new Uri(Route);
// httpClient.DefaultRequestHeaders.Authorization = string.IsNullOrEmpty(Token) ? new AuthenticationHeaderValue("Bearer", Token) : null;
// httpClient.DefaultRequestHeaders.Authorization = !string.IsNullOrEmpty(Token) ? new AuthenticationHeaderValue("Bearer", Token) : null;
// string jsonTransport = JsonConvert.SerializeObject(Model);
// var jsonPayload = new StringContent(jsonTransport, Encoding.UTF8, "application/json");
// var httpResponse = await httpClient.PostAsync(uri, jsonPayload);
Expand Down
6 changes: 3 additions & 3 deletions src/HttpClientServiceHelper/Put.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public static async Task<HttpResponseMessage> PutAsync(string Route, object Mode
using (HttpClient httpClient = new HttpClient())
{
var uri = new Uri(Route);
httpClient.DefaultRequestHeaders.Authorization = string.IsNullOrEmpty(Token) ? new AuthenticationHeaderValue("Bearer", Token) : null;
httpClient.DefaultRequestHeaders.Authorization = !string.IsNullOrEmpty(Token) ? new AuthenticationHeaderValue("Bearer", Token) : null;
string jsonTransport = JsonConvert.SerializeObject(Model);
var jsonPayload = new StringContent(jsonTransport, Encoding.UTF8, "application/json");
var httpResponse = await httpClient.PutAsync(uri, jsonPayload);
Expand Down Expand Up @@ -124,7 +124,7 @@ public static async Task<string> PutAndGetResponseAsStringAsync(string Route, ob
using (HttpClient httpClient = new HttpClient())
{
var uri = new Uri(Route);
httpClient.DefaultRequestHeaders.Authorization = string.IsNullOrEmpty(Token) ? new AuthenticationHeaderValue("Bearer", Token) : null;
httpClient.DefaultRequestHeaders.Authorization = !string.IsNullOrEmpty(Token) ? new AuthenticationHeaderValue("Bearer", Token) : null;
string jsonTransport = JsonConvert.SerializeObject(Model);
var jsonPayload = new StringContent(jsonTransport, Encoding.UTF8, "application/json");
var httpResponse = await httpClient.PutAsync(uri, jsonPayload);
Expand Down Expand Up @@ -234,7 +234,7 @@ public static async Task<string> PutAndGetResponseAsStringAsync(string Route, ob
// using (HttpClient httpClient = new HttpClient())
// {
// var uri = new Uri(Route);
// httpClient.DefaultRequestHeaders.Authorization = string.IsNullOrEmpty(Token) ? new AuthenticationHeaderValue("Bearer", Token) : null;
// httpClient.DefaultRequestHeaders.Authorization = !string.IsNullOrEmpty(Token) ? new AuthenticationHeaderValue("Bearer", Token) : null;
// string jsonTransport = JsonConvert.SerializeObject(Model);
// var jsonPayload = new StringContent(jsonTransport, Encoding.UTF8, "application/json");
// var httpResponse = await httpClient.PutAsync(uri, jsonPayload);
Expand Down
Loading