mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2025-07-08 20:46:29 +02:00
Version 3.0.376
This commit is contained in:
parent
ca080c87c0
commit
f963c0a219
158 changed files with 3228 additions and 1279 deletions
|
@ -55,10 +55,14 @@ namespace TINK.Model.Services.CopriApi
|
|||
|
||||
/// <summary>Gets bikes available.</summary>
|
||||
/// <param name="operatorUri">Uri of the operator host to get bikes from or null if bikes have to be gotten form primary host.</param>
|
||||
/// <param name="stationId"> Id of station which is used for filtering bikes. Null if no filtering should be applied.</param>
|
||||
/// <param name="bikeId"> Id of bike which is used for filtering bikes. Null if no filtering should be applied.</param>
|
||||
/// <returns>Response holding list of bikes.</returns>
|
||||
public async Task<Result<BikesAvailableResponse>> GetBikesAvailable(
|
||||
bool fromCache = false,
|
||||
Uri operatorUri = null)
|
||||
Uri operatorUri = null,
|
||||
string stationId = null,
|
||||
string bikeId = null)
|
||||
{
|
||||
Log.ForContext<CopriProviderHttps>().Debug($"Request to get bikes available{(fromCache ? " from cache" : "")}...");
|
||||
if (!CacheServer.IsBikesAvailableExpired
|
||||
|
@ -66,14 +70,14 @@ namespace TINK.Model.Services.CopriApi
|
|||
{
|
||||
// No need to query because previous answer is not yet outdated.
|
||||
Log.ForContext<CopriProviderHttps>().Debug($"Returning bikes available from cache.");
|
||||
var bikesAvailableResponse = await CacheServer.GetBikesAvailableAsync(operatorUri);
|
||||
var bikesAvailableResponse = await CacheServer.GetBikesAvailableAsync(operatorUri, stationId, bikeId);
|
||||
return new Result<BikesAvailableResponse>(typeof(CopriCallsMonkeyStore), bikesAvailableResponse, bikesAvailableResponse.GetGeneralData());
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
Log.ForContext<CopriProviderHttps>().Debug($"Querying bikes available from copri.");
|
||||
var bikesAvailableResponse = await HttpsServer.GetBikesAvailableAsync(operatorUri);
|
||||
var bikesAvailableResponse = await HttpsServer.GetBikesAvailableAsync(operatorUri, stationId, bikeId);
|
||||
return new Result<BikesAvailableResponse>(
|
||||
typeof(CopriCallsHttps),
|
||||
bikesAvailableResponse.GetIsResponseOk(MultilingualResources.AppResources.ErrorBikesAvailableResponseNotOk),
|
||||
|
@ -83,7 +87,7 @@ namespace TINK.Model.Services.CopriApi
|
|||
{
|
||||
// Return response from cache.
|
||||
Log.ForContext<CopriProviderHttps>().Debug("An error occurred querying bikes available. {Exception}.", exception);
|
||||
var bikesAvailableResponse = await CacheServer.GetBikesAvailableAsync(operatorUri);
|
||||
var bikesAvailableResponse = await CacheServer.GetBikesAvailableAsync(operatorUri, stationId, bikeId);
|
||||
return new Result<BikesAvailableResponse>(typeof(CopriCallsMonkeyStore), bikesAvailableResponse, bikesAvailableResponse.GetGeneralData(), exception);
|
||||
}
|
||||
}
|
||||
|
@ -176,8 +180,12 @@ namespace TINK.Model.Services.CopriApi
|
|||
/// <summary>Adds https--response to cache if response is ok. </summary>
|
||||
/// <param name="result">Response to add to cache.</param>
|
||||
/// <param name="operatorUri">Uri of the operator host to get bikes from or null if bikes have to be gotten form primary host.</param>
|
||||
/// <returns></returns>
|
||||
public void AddToCache(Result<BikesAvailableResponse> result, Uri operatorUri = null)
|
||||
/// <param name="stationId"> Id of station which is used for filtering bikes. Null if no filtering should be applied.</param>
|
||||
public void AddToCache(
|
||||
Result<BikesAvailableResponse> result,
|
||||
Uri operatorUri = null,
|
||||
string stationId = null,
|
||||
string bikeId = null)
|
||||
{
|
||||
Log.ForContext<CopriProviderHttps>().Debug($"Request to add bikes available response to cache...");
|
||||
if (result.Source == typeof(CopriCallsMonkeyStore)
|
||||
|
@ -188,8 +196,7 @@ namespace TINK.Model.Services.CopriApi
|
|||
}
|
||||
|
||||
Log.ForContext<CopriProviderHttps>().Debug($"Add bikes available response to cache.");
|
||||
CacheServer.AddToCache(result.Response, operatorUri);
|
||||
|
||||
CacheServer.AddToCache(result.Response, operatorUri, stationId, bikeId);
|
||||
}
|
||||
|
||||
/// <summary>Adds https--response to cache if response is ok. </summary>
|
||||
|
|
|
@ -108,9 +108,12 @@ namespace TINK.Model.Services.CopriApi
|
|||
public async Task<AuthorizationoutResponse> DoAuthoutAsync()
|
||||
=> await monkeyStore.DoAuthoutAsync();
|
||||
|
||||
/// <summary> Gets a list of bikes from Copri. </summary>
|
||||
/// <param name="operatorUri">Uri of the operator host to get bikes from or null if bikes have to be gotten form primary host.</param>
|
||||
public async Task<BikesAvailableResponse> GetBikesAvailableAsync(Uri operatorUri = null)
|
||||
=> await monkeyStore.GetBikesAvailableAsync(operatorUri);
|
||||
/// <param name="stationId"> Id of station which is used for filtering bikes. Null if no filtering should be applied.</param>
|
||||
/// <param name="bikeId"> Id of bike which is used for filtering bikes. Null if no filtering should be applied.</param>
|
||||
public async Task<BikesAvailableResponse> GetBikesAvailableAsync(Uri operatorUri = null, string stationId = null, string bikeId = null)
|
||||
=> await monkeyStore.GetBikesAvailableAsync(operatorUri, stationId, bikeId);
|
||||
|
||||
public async Task<BikesReservedOccupiedResponse> GetBikesOccupiedAsync()
|
||||
=> await monkeyStore.GetBikesOccupiedAsync();
|
||||
|
|
|
@ -16,8 +16,14 @@ namespace TINK.Model.Services.CopriApi
|
|||
|
||||
/// <summary> Gets a list of bikes from Copri. </summary>
|
||||
/// <param name="operatorUri">Uri of the operator host to get bikes from or null if bikes have to be gotten form primary host.</param>
|
||||
/// <param name="stationId"> Id of station which is used for filtering bikes. Null if no filtering should be applied.</param>
|
||||
/// <param name="bikeId"> Id of bike which is used for filtering bikes. Null if no filtering should be applied.</param>
|
||||
/// <returns>Response holding list of bikes.</returns>
|
||||
Task<Result<BikesAvailableResponse>> GetBikesAvailable(bool fromCache = false, Uri operatorUri = null);
|
||||
Task<Result<BikesAvailableResponse>> GetBikesAvailable(
|
||||
bool fromCache = false,
|
||||
Uri operatorUri = null,
|
||||
string stationId = null,
|
||||
string bikeId = null);
|
||||
|
||||
/// <summary> Gets a list of bikes reserved/ booked by active user from Copri.</summary>
|
||||
/// <returns>Response holding list of bikes.</returns>
|
||||
|
@ -28,9 +34,15 @@ namespace TINK.Model.Services.CopriApi
|
|||
void AddToCache(Result<StationsAvailableResponse> result);
|
||||
|
||||
/// <summary>Adds https--response to cache if response is ok. </summary>
|
||||
/// <param name="result">Response to add to cache.</param>
|
||||
/// <param name="operatorUri">Uri of the operator host to get bikes from or null if bikes have to be gotten form primary host.</param>
|
||||
/// <param name="response">Response to add to cache.</param>
|
||||
void AddToCache(Result<BikesAvailableResponse> result, Uri operatorUri = null);
|
||||
/// <param name="stationId"> Id of station which is used for filtering bikes. Null if no filtering should be applied.</param>
|
||||
/// <param name="bikeId"> Id of bike which is used for filtering bikes. Null if no filtering should be applied.</param>
|
||||
void AddToCache(
|
||||
Result<BikesAvailableResponse> result,
|
||||
Uri operatorUri = null,
|
||||
string stationId = null,
|
||||
string bikeId = null);
|
||||
|
||||
/// <summary>Adds https--response to cache if response is ok. </summary>
|
||||
/// <param name="response">Response to add to cache.</param>
|
||||
|
|
|
@ -18,9 +18,11 @@ namespace TINK.Model.Services.CopriApi
|
|||
bool IsBikesAvailableExpired { get; }
|
||||
|
||||
/// <summary> Adds a bikes response to cache.</summary>
|
||||
/// <param name="operatorUri">Uri of the operator host to get bikes from or null if bikes have to be gotten form primary host.</param>
|
||||
/// <param name="bikes">Bikes to add.</param>
|
||||
void AddToCache(BikesAvailableResponse bikes, Uri operatorUri = null);
|
||||
/// <param name="operatorUri">Uri of the operator host to get bikes from or null if bikes have to be gotten form primary host.</param>
|
||||
/// <param name="stationId"> Id of station which is used for filtering bikes. Null if no filtering should be applied.</param>
|
||||
/// <param name="bikeId"> Id of bike to get.</param>
|
||||
void AddToCache(BikesAvailableResponse bikes, Uri operatorUri = null, string stationId = null, string bikeId = null);
|
||||
|
||||
/// <summary> Gets a value indicating whether stations are expired or not.</summary>
|
||||
bool IsBikesOccupiedExpired { get; }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue