Skip to content

Commit

Permalink
CheckConnectionAsync LoginReponse replaced with _session.IsValid, Ign…
Browse files Browse the repository at this point in the history
…oreNullValues replaced with JsonIgnoreCondition.WhenWritingNull
  • Loading branch information
VaclavElias committed Mar 31, 2022
1 parent 209fdb4 commit a1ab958
Showing 1 changed file with 5 additions and 22 deletions.
27 changes: 5 additions & 22 deletions src/Bullhorn/Api/BullhornApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,28 +50,11 @@ public async Task CheckConnectionAsync()
throw new NullReferenceException($"{nameof(BullhornSettings)}, Set the {nameof(BullhornSettings)} parameter before connecting!");
}

if (_session.LoginResponse != null || _session.IsValid) return;

//BullhornApi.SetAuthorizationMeta(_bullhornSettings);
if (_session.IsValid) return;

await _session.ConnectAsync();
}

//public async Task ConnectAsync(int callsRefresh = 0)
//{
// if (_bullhornSettings == null) throw new NullReferenceException($"{nameof(BullhornSettings)}, Set the {nameof(BullhornSettings)} parameter before connecting!");

// _logger.LogInformation("Connecting to Bullhorn");

// _authorization = new Authorization(_bullhornSettings, _httpClient, _logger);
// await _authorization.AuthorizeAsync();

// UpdateBhRestTokenHeader();
// Authorized = true;

// _logger.LogInformation("Connected to Bullhorn");
//}

//public async Task<DynamicQueryResponse> ApiQueryToDynamicAsync(string query, int count, int start = 0)
//{
// query = $"query/{query}&start={start}&count={count}&showTotalMatched=true&usev2=true";
Expand Down Expand Up @@ -179,7 +162,7 @@ public async Task<HttpResponseMessage> ApiGetAsync(string query)

var restUrl = $"{_session.LoginResponse!.RestUrl}{query}";

_logger.LogDebug($"Request: {restUrl}");
//_logger.LogDebug($"Request: {restUrl}");

return await _httpClient.GetAsync(restUrl);
}
Expand Down Expand Up @@ -225,16 +208,16 @@ public async Task UpdateAsync<T>(int id, string entityName, T updateDto) => awai
new StringContent(JsonSerializer.Serialize<T>(updateDto, new JsonSerializerOptions
{
AllowTrailingCommas = true,
IgnoreNullValues = true
//IgnoreNullValues = true
//ContractResolver = new EmptyStringResolver()
//DefaultIgnoreCondition = JsonIgnoreCondition.Always
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull
}), Encoding.UTF8, "application/json"));

public async Task MassUpdateAsync<T>(string entityName, T updateDto) => await ApiPostAsync($"massUpdate/{entityName}?",
new StringContent(JsonSerializer.Serialize<T>(updateDto, new JsonSerializerOptions
{
AllowTrailingCommas = true,
IgnoreNullValues = true,
//IgnoreNullValues = true,
//ContractResolver = new EmptyStringResolver()
DefaultIgnoreCondition = JsonIgnoreCondition.Always
}), Encoding.UTF8, "application/json"));
Expand Down

0 comments on commit a1ab958

Please sign in to comment.