mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2025-04-22 12:56:29 +02:00
Version 3.0.375
This commit is contained in:
parent
2c790239cb
commit
ca080c87c0
194 changed files with 10092 additions and 10464 deletions
|
@ -54,8 +54,11 @@ 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>
|
||||
/// <returns>Response holding list of bikes.</returns>
|
||||
public async Task<Result<BikesAvailableResponse>> GetBikesAvailable(bool fromCache = false)
|
||||
public async Task<Result<BikesAvailableResponse>> GetBikesAvailable(
|
||||
bool fromCache = false,
|
||||
Uri operatorUri = null)
|
||||
{
|
||||
Log.ForContext<CopriProviderHttps>().Debug($"Request to get bikes available{(fromCache ? " from cache" : "")}...");
|
||||
if (!CacheServer.IsBikesAvailableExpired
|
||||
|
@ -63,14 +66,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();
|
||||
var bikesAvailableResponse = await CacheServer.GetBikesAvailableAsync(operatorUri);
|
||||
return new Result<BikesAvailableResponse>(typeof(CopriCallsMonkeyStore), bikesAvailableResponse, bikesAvailableResponse.GetGeneralData());
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
Log.ForContext<CopriProviderHttps>().Debug($"Querying bikes available from copri.");
|
||||
var bikesAvailableResponse = await HttpsServer.GetBikesAvailableAsync();
|
||||
var bikesAvailableResponse = await HttpsServer.GetBikesAvailableAsync(operatorUri);
|
||||
return new Result<BikesAvailableResponse>(
|
||||
typeof(CopriCallsHttps),
|
||||
bikesAvailableResponse.GetIsResponseOk(MultilingualResources.AppResources.ErrorBikesAvailableResponseNotOk),
|
||||
|
@ -80,7 +83,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();
|
||||
var bikesAvailableResponse = await CacheServer.GetBikesAvailableAsync(operatorUri);
|
||||
return new Result<BikesAvailableResponse>(typeof(CopriCallsMonkeyStore), bikesAvailableResponse, bikesAvailableResponse.GetGeneralData(), exception);
|
||||
}
|
||||
}
|
||||
|
@ -171,9 +174,10 @@ namespace TINK.Model.Services.CopriApi
|
|||
}
|
||||
|
||||
/// <summary>Adds https--response to cache if response is ok. </summary>
|
||||
/// <param name="response">Response to add to cache.</param>
|
||||
/// <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)
|
||||
public void AddToCache(Result<BikesAvailableResponse> result, Uri operatorUri = null)
|
||||
{
|
||||
Log.ForContext<CopriProviderHttps>().Debug($"Request to add bikes available response to cache...");
|
||||
if (result.Source == typeof(CopriCallsMonkeyStore)
|
||||
|
@ -184,7 +188,7 @@ namespace TINK.Model.Services.CopriApi
|
|||
}
|
||||
|
||||
Log.ForContext<CopriProviderHttps>().Debug($"Add bikes available response to cache.");
|
||||
CacheServer.AddToCache(result.Response);
|
||||
CacheServer.AddToCache(result.Response, operatorUri);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -108,8 +108,9 @@ namespace TINK.Model.Services.CopriApi
|
|||
public async Task<AuthorizationoutResponse> DoAuthoutAsync()
|
||||
=> await monkeyStore.DoAuthoutAsync();
|
||||
|
||||
public async Task<BikesAvailableResponse> GetBikesAvailableAsync()
|
||||
=> await monkeyStore.GetBikesAvailableAsync();
|
||||
/// <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);
|
||||
|
||||
public async Task<BikesReservedOccupiedResponse> GetBikesOccupiedAsync()
|
||||
=> await monkeyStore.GetBikesOccupiedAsync();
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using TINK.Repository;
|
||||
using TINK.Repository.Response;
|
||||
|
@ -14,8 +15,9 @@ namespace TINK.Model.Services.CopriApi
|
|||
Task<Result<StationsAvailableResponse>> GetStations(bool fromCache = false);
|
||||
|
||||
/// <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>
|
||||
/// <returns>Response holding list of bikes.</returns>
|
||||
Task<Result<BikesAvailableResponse>> GetBikesAvailable(bool fromCache = false);
|
||||
Task<Result<BikesAvailableResponse>> GetBikesAvailable(bool fromCache = false, Uri operatorUri = null);
|
||||
|
||||
/// <summary> Gets a list of bikes reserved/ booked by active user from Copri.</summary>
|
||||
/// <returns>Response holding list of bikes.</returns>
|
||||
|
@ -26,8 +28,9 @@ namespace TINK.Model.Services.CopriApi
|
|||
void AddToCache(Result<StationsAvailableResponse> result);
|
||||
|
||||
/// <summary>Adds https--response to cache if response is ok. </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="response">Response to add to cache.</param>
|
||||
void AddToCache(Result<BikesAvailableResponse> result);
|
||||
void AddToCache(Result<BikesAvailableResponse> result, Uri operatorUri = null);
|
||||
|
||||
/// <summary>Adds https--response to cache if response is ok. </summary>
|
||||
/// <param name="response">Response to add to cache.</param>
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using TINK.Repository;
|
||||
using System;
|
||||
using TINK.Repository;
|
||||
using TINK.Repository.Response;
|
||||
using TINK.Repository.Response.Stations;
|
||||
|
||||
|
@ -17,8 +18,9 @@ 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);
|
||||
void AddToCache(BikesAvailableResponse bikes, Uri operatorUri = 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