Skip to content

Commit

Permalink
Add HttpCompletionOptions
Browse files Browse the repository at this point in the history
  • Loading branch information
bytefish committed Nov 20, 2020
1 parent fc7df0b commit 2d94483
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
24 changes: 12 additions & 12 deletions OpenSkyRestClient/OpenSkyRestClient/OpenSkyClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public OpenSkyClient(HttpClient httpClient)
this.apiUrl = "https://opensky-network.org/api";
}

public async Task<StateVectorResponse> GetAllStateVectorsAsync(int? time = null, string icao24 = null, BoundingBox boundingBox = null, Credentials credentials = null, CancellationToken cancellationToken = default)
public async Task<StateVectorResponse> GetAllStateVectorsAsync(int? time = null, string icao24 = null, BoundingBox boundingBox = null, Credentials credentials = null, HttpCompletionOption httpCompletionOption = HttpCompletionOption.ResponseContentRead, CancellationToken cancellationToken = default)
{
var url = $"{apiUrl}/states/all";

Expand Down Expand Up @@ -65,7 +65,7 @@ public async Task<StateVectorResponse> GetAllStateVectorsAsync(int? time = null,
}

var httpResponse = await httpClient
.SendAsync(httpRequestMessage, cancellationToken)
.SendAsync(httpRequestMessage, httpCompletionOption, cancellationToken)
.ConfigureAwait(false);

if (!httpResponse.IsSuccessStatusCode)
Expand All @@ -85,7 +85,7 @@ public async Task<StateVectorResponse> GetAllStateVectorsAsync(int? time = null,
return stateVectorResponse;
}

public async Task<StateVectorResponse> GetOwnStateVectorsAsync(int? time = null, string icao24 = null, int[] serials = null, Credentials credentials = null, BoundingBox boundingBox = null, CancellationToken cancellationToken = default)
public async Task<StateVectorResponse> GetOwnStateVectorsAsync(int? time = null, string icao24 = null, int[] serials = null, Credentials credentials = null, BoundingBox boundingBox = null, HttpCompletionOption httpCompletionOption = HttpCompletionOption.ResponseContentRead, CancellationToken cancellationToken = default)
{
var url = $"{apiUrl}/states/own";

Expand Down Expand Up @@ -125,7 +125,7 @@ public async Task<StateVectorResponse> GetOwnStateVectorsAsync(int? time = null,
}

var httpResponse = await httpClient
.SendAsync(httpRequestMessage, cancellationToken)
.SendAsync(httpRequestMessage, httpCompletionOption, cancellationToken)
.ConfigureAwait(false);

if (!httpResponse.IsSuccessStatusCode)
Expand All @@ -145,7 +145,7 @@ public async Task<StateVectorResponse> GetOwnStateVectorsAsync(int? time = null,
return stateVectorResponse;
}

public async Task<FlightResponse> GetAllFlightsBetweenAsync(DateTime begin, DateTime end, Credentials credentials = null, CancellationToken cancellationToken = default)
public async Task<FlightResponse> GetAllFlightsBetweenAsync(DateTime begin, DateTime end, Credentials credentials = null, HttpCompletionOption httpCompletionOption = HttpCompletionOption.ResponseContentRead, CancellationToken cancellationToken = default)
{
var beginUnixTs = DateTimeUtils.GetUnixTimestamp(begin);
var endUnixTs = DateTimeUtils.GetUnixTimestamp(end);
Expand All @@ -164,7 +164,7 @@ public async Task<FlightResponse> GetAllFlightsBetweenAsync(DateTime begin, Date
}

var httpResponse = await httpClient
.SendAsync(httpRequestMessage, cancellationToken)
.SendAsync(httpRequestMessage, httpCompletionOption, cancellationToken)
.ConfigureAwait(false);

if (!httpResponse.IsSuccessStatusCode)
Expand All @@ -182,7 +182,7 @@ public async Task<FlightResponse> GetAllFlightsBetweenAsync(DateTime begin, Date
return FlightResponseParser.Parse(json);
}

public async Task<FlightResponse> GetFlightsByAircraftAsync(string icao24, DateTime begin, DateTime end, Credentials credentials = null, CancellationToken cancellationToken = default)
public async Task<FlightResponse> GetFlightsByAircraftAsync(string icao24, DateTime begin, DateTime end, Credentials credentials = null, HttpCompletionOption httpCompletionOption = HttpCompletionOption.ResponseContentRead, CancellationToken cancellationToken = default)
{
var beginUnixTs = DateTimeUtils.GetUnixTimestamp(begin);
var endUnixTs = DateTimeUtils.GetUnixTimestamp(end);
Expand All @@ -202,7 +202,7 @@ public async Task<FlightResponse> GetFlightsByAircraftAsync(string icao24, DateT
}

var httpResponse = await httpClient
.SendAsync(httpRequestMessage, cancellationToken)
.SendAsync(httpRequestMessage, httpCompletionOption, cancellationToken)
.ConfigureAwait(false);

if (!httpResponse.IsSuccessStatusCode)
Expand All @@ -220,7 +220,7 @@ public async Task<FlightResponse> GetFlightsByAircraftAsync(string icao24, DateT
return FlightResponseParser.Parse(json);
}

public async Task<FlightResponse> GetArrivalsByAirportAsync(string airport, DateTime begin, DateTime end, Credentials credentials = null, CancellationToken cancellationToken = default)
public async Task<FlightResponse> GetArrivalsByAirportAsync(string airport, DateTime begin, DateTime end, Credentials credentials = null, HttpCompletionOption httpCompletionOption = HttpCompletionOption.ResponseContentRead, CancellationToken cancellationToken = default)
{
var beginUnixTs = DateTimeUtils.GetUnixTimestamp(begin);
var endUnixTs = DateTimeUtils.GetUnixTimestamp(end);
Expand All @@ -240,7 +240,7 @@ public async Task<FlightResponse> GetArrivalsByAirportAsync(string airport, Date
}

var httpResponse = await httpClient
.SendAsync(httpRequestMessage, cancellationToken)
.SendAsync(httpRequestMessage, httpCompletionOption, cancellationToken)
.ConfigureAwait(false);

if (!httpResponse.IsSuccessStatusCode)
Expand All @@ -258,7 +258,7 @@ public async Task<FlightResponse> GetArrivalsByAirportAsync(string airport, Date
return FlightResponseParser.Parse(json);
}

public async Task<FlightResponse> GetDeparturesByAirportAsync(Credentials credentials, string airport, DateTime begin, DateTime end, CancellationToken cancellationToken = default)
public async Task<FlightResponse> GetDeparturesByAirportAsync(Credentials credentials, string airport, DateTime begin, DateTime end, HttpCompletionOption httpCompletionOption = HttpCompletionOption.ResponseContentRead, CancellationToken cancellationToken = default)
{
var beginUnixTs = DateTimeUtils.GetUnixTimestamp(begin);
var endUnixTs = DateTimeUtils.GetUnixTimestamp(end);
Expand All @@ -278,7 +278,7 @@ public async Task<FlightResponse> GetDeparturesByAirportAsync(Credentials creden
}

var httpResponse = await httpClient
.SendAsync(httpRequestMessage, cancellationToken)
.SendAsync(httpRequestMessage, httpCompletionOption, cancellationToken)
.ConfigureAwait(false);

if (!httpResponse.IsSuccessStatusCode)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<Version>0.1.0</Version>
<Version>0.2.0</Version>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Company />
<Authors>Philipp Wagner</Authors>
Expand Down
Binary file added Releases/nupkg/OpenSkyRestClient.0.2.0.nupkg
Binary file not shown.

0 comments on commit 2d94483

Please sign in to comment.