mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2025-07-09 04:47:31 +02:00
Version 3.0.376
This commit is contained in:
parent
ca080c87c0
commit
f963c0a219
158 changed files with 3228 additions and 1279 deletions
|
@ -85,11 +85,13 @@ namespace TINK.Repository
|
|||
|
||||
/// <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<BikesAvailableResponse> GetBikesAvailableAsync(Uri operatorUri = null)
|
||||
public async Task<BikesAvailableResponse> GetBikesAvailableAsync(Uri operatorUri = null, string stationId = null, string bikeId = null)
|
||||
=> await GetBikesAvailableAsync(
|
||||
operatorUri?.AbsoluteUri ?? m_oCopriHost.AbsoluteUri,
|
||||
requestBuilder.GetBikesAvailable(),
|
||||
requestBuilder.GetBikesAvailable(stationId, bikeId),
|
||||
UserAgent);
|
||||
|
||||
/// <summary> Gets a list of bikes reserved/ booked by active user. </summary>
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -119,7 +119,7 @@ namespace TINK.Repository
|
|||
public string SessionCookie => requestBuilder.SessionCookie;
|
||||
|
||||
/// <summary> Initializes a instance of the copri monkey store object. </summary>
|
||||
/// <param name="merchantId">Id of the merchant.</param>
|
||||
/// <param name="merchantId">Id of the merchant. Used to access </param>
|
||||
/// <param name="uiIsoLangugageName">Two letter ISO language name.</param>
|
||||
/// <param name="sessionCookie">Session cookie if user is logged in, null otherwise.</param>
|
||||
/// <param name="smartDevice">Holds info about smart device.</param>
|
||||
|
@ -235,13 +235,19 @@ namespace TINK.Repository
|
|||
throw new System.Exception(AppResources.ErrorNoWeb);
|
||||
}
|
||||
|
||||
/// <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>
|
||||
public async Task<BikesAvailableResponse> GetBikesAvailableAsync(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>
|
||||
public async Task<BikesAvailableResponse> GetBikesAvailableAsync(
|
||||
Uri operatorUri = null,
|
||||
string stationId = null,
|
||||
string bikeId = null)
|
||||
{
|
||||
var bikesAvailableTask = new TaskCompletionSource<BikesAvailableResponse>();
|
||||
lock (monkeyLock)
|
||||
{
|
||||
bikesAvailableTask.SetResult(Barrel.Current.Get<BikesAvailableResponse>($"{operatorUri?.AbsoluteUri ?? string.Empty}{requestBuilder.GetBikesAvailable()}"));
|
||||
bikesAvailableTask.SetResult(Barrel.Current.Get<BikesAvailableResponse>($"{operatorUri?.AbsoluteUri ?? string.Empty}{requestBuilder.GetBikesAvailable(stationId, bikeId)}"));
|
||||
}
|
||||
return await bikesAvailableTask.Task;
|
||||
}
|
||||
|
@ -298,7 +304,7 @@ namespace TINK.Repository
|
|||
|
||||
/// <summary> Adds a stations all response to cache.</summary>
|
||||
/// <param name="stations">Stations to add.</param>
|
||||
/// <param name="expiresAfter">Time after which anser is considered to be expired.</param>
|
||||
/// <param name="expiresAfter">Time after which answer is considered to be expired.</param>
|
||||
private void AddToCache(StationsAvailableResponse stations, TimeSpan expiresAfter)
|
||||
{
|
||||
lock (monkeyLock)
|
||||
|
@ -323,21 +329,29 @@ namespace TINK.Repository
|
|||
}
|
||||
|
||||
/// <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>
|
||||
public void AddToCache(BikesAvailableResponse bikes, Uri operatorUri = null)
|
||||
=> AddToCache(bikes, ExpiresAfter, operatorUri);
|
||||
/// <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 was used for filtering bikes. Null if no filtering was applied.</param>
|
||||
/// <param name="bikeId"> Id of bike which was used for filtering bikes. Null if no filtering was applied.</param>
|
||||
public void AddToCache(BikesAvailableResponse bikes, Uri operatorUri = null, string stationId = null, string bikeId = null)
|
||||
=> AddToCache(bikes, ExpiresAfter, operatorUri, stationId, bikeId);
|
||||
|
||||
/// <summary> Adds a bikes response to cache.</summary>
|
||||
/// <param name="bikes">Bikes to add.</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="expiresAfter">Time after which answer is considered to be expired.</param>
|
||||
private void AddToCache(BikesAvailableResponse bikes, TimeSpan expiresAfter, 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>
|
||||
private void AddToCache(
|
||||
BikesAvailableResponse bikes,
|
||||
TimeSpan expiresAfter,
|
||||
Uri operatorUri = null,
|
||||
string stationId = null,
|
||||
string bikeId = null)
|
||||
{
|
||||
lock (monkeyLock)
|
||||
{
|
||||
Barrel.Current.Add(
|
||||
$"{operatorUri?.AbsoluteUri ?? string.Empty}{requestBuilder.GetBikesAvailable()}",
|
||||
$"{operatorUri?.AbsoluteUri ?? string.Empty}{requestBuilder.GetBikesAvailable(stationId, bikeId)}",
|
||||
JsonConvertRethrow.SerializeObject(bikes),
|
||||
expiresAfter);
|
||||
}
|
||||
|
@ -364,7 +378,7 @@ namespace TINK.Repository
|
|||
}
|
||||
/// <summary> Adds a bikes response to cache.</summary>
|
||||
/// <param name="bikes">Bikes to add.</param>
|
||||
/// <param name="expiresAfter">Time after which anser is considered to be expired.</param>
|
||||
/// <param name="expiresAfter">Time after which answer is considered to be expired.</param>
|
||||
private void AddToCache(BikesReservedOccupiedResponse bikes, TimeSpan expiresAfter)
|
||||
{
|
||||
lock (monkeyLock)
|
||||
|
|
|
@ -29,7 +29,7 @@ namespace TINK.Repository
|
|||
/// <returns>Response object.</returns>
|
||||
public static T DeserializeResponse<T>(this string response, Func<string, T> emptyResponseFactory) where T : class
|
||||
{
|
||||
// Get COPRI version from respone.
|
||||
// Get COPRI version from response.
|
||||
var bikeInfoBase = JsonConvertRethrow.DeserializeObject<VersionindependentResponse>(response)?.shareejson;
|
||||
|
||||
if (bikeInfoBase.GetCopriVersion() < UNSUPPORTEDFUTURECOPRIVERSIONLOWER
|
||||
|
@ -41,15 +41,17 @@ namespace TINK.Repository
|
|||
return JsonConvertRethrow.DeserializeObject<ResponseContainer<T>>(response)?.shareejson;
|
||||
}
|
||||
|
||||
/// <summary> Deserializes reponse JSON if response is of supported version or throws an exception. </summary>
|
||||
/// <summary> Deserializes response JSON if response is of supported version or throws an exception. </summary>
|
||||
/// <typeparam name="T">Type of response object.</typeparam>
|
||||
/// <param name="response">Response JSON.</param>
|
||||
/// <param name="unsupportedVersionExectpion">Exception to fire.</param>
|
||||
/// <returns>Response object.</returns>
|
||||
public static T DeserializeResponse<T>(this string response, Func<string, System.Exception> unsupportedVersionExectpion = null) where T : class
|
||||
public static T DeserializeResponse<T>(
|
||||
this string response,
|
||||
Func<string, System.Exception> unsupportedVersionExectpion = null) where T : class
|
||||
{
|
||||
|
||||
// Get COPRI version from respone.
|
||||
// Get COPRI version from response.
|
||||
var bikeInfoBase = JsonConvertRethrow.DeserializeObject<VersionindependentResponse>(response)?.shareejson;
|
||||
|
||||
if (bikeInfoBase.GetCopriVersion() < UNSUPPORTEDFUTURECOPRIVERSIONLOWER
|
||||
|
|
|
@ -160,8 +160,10 @@ namespace TINK.Repository
|
|||
|
||||
/// <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<BikesAvailableResponse> GetBikesAvailableAsync(Uri operatorUri = null);
|
||||
Task<BikesAvailableResponse> GetBikesAvailableAsync(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>
|
||||
|
|
|
@ -34,8 +34,10 @@ namespace TINK.Repository.Request
|
|||
string GetStations();
|
||||
|
||||
/// <summary>Gets bikes available.</summary>
|
||||
/// <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>
|
||||
/// <returns>Request to query list of bikes available.</returns>
|
||||
string GetBikesAvailable();
|
||||
string GetBikesAvailable(string stationId = null, string bikeId = null);
|
||||
|
||||
/// <summary> Gets a list of bikes reserved/ booked by active user from Copri.</summary>
|
||||
/// <returns>Request to query list of bikes occupied.</returns>
|
||||
|
|
|
@ -67,9 +67,13 @@ namespace TINK.Repository.Request
|
|||
=> throw new CallNotRequiredException();
|
||||
|
||||
/// <summary>Gets bikes available.</summary>
|
||||
/// <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>
|
||||
/// <returns>Request to query list of bikes available.</returns>
|
||||
public string GetBikesAvailable()
|
||||
public string GetBikesAvailable(string stationId = null, string bikeId = null)
|
||||
=> "request=bikes_available&system=all" +
|
||||
stationId.GetStationId() +
|
||||
bikeId.GetBikeId() +
|
||||
AuthCookieParameter +
|
||||
UiIsoLanguageNameParameter;
|
||||
|
||||
|
|
|
@ -65,5 +65,19 @@ namespace TINK.Repository.Request
|
|||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Gets the station id filter. </summary>
|
||||
/// <returns>Station id filter.</returns>
|
||||
public static string GetStationId(this string stationId)
|
||||
=> !string.IsNullOrEmpty(stationId)
|
||||
? $"&station={WebUtility.UrlEncode(stationId)}"
|
||||
: string.Empty;
|
||||
|
||||
/// <summary> Gets the bike id filter. </summary>
|
||||
/// <returns>Bike id filter.</returns>
|
||||
public static string GetBikeId(this string bikeId)
|
||||
=> !string.IsNullOrEmpty(bikeId)
|
||||
? $"&bike={WebUtility.UrlEncode(bikeId)}"
|
||||
: string.Empty;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -72,9 +72,13 @@ namespace TINK.Repository.Request
|
|||
UiIsoLanguageNameParameter;
|
||||
|
||||
/// <summary>Gets bikes available.</summary>
|
||||
/// <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>
|
||||
/// <returns>Request to query list of bikes available.</returns>
|
||||
public string GetBikesAvailable()
|
||||
public string GetBikesAvailable(string stationId = null, string bikeId = null)
|
||||
=> "request=bikes_available&system=all" +
|
||||
stationId.GetStationId() +
|
||||
bikeId.GetBikeId() +
|
||||
AuthCookieParameter +
|
||||
UiIsoLanguageNameParameter;
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ namespace TINK.Repository.Response
|
|||
/// <remarks>
|
||||
/// <table>
|
||||
/// <tr><th>Value </th><th>Type of bike </th><th>Member to extract info.</th></tr>
|
||||
/// <tr><td>LOCK </td><td>Bike with manual lock. </td><td>TextToTypeHelper.GetIsNonBikeComputerBike</td></tr>
|
||||
/// <tr><td>LOCK </td><td>Bike with manualHtml lock. </td><td>TextToTypeHelper.GetIsNonBikeComputerBike</td></tr>
|
||||
/// <tr><td>BC </td><td>Bike with a bord computer. </td><td></td></tr>
|
||||
/// <tr><td>Ilockit </td><td>Bike with a bluetooth lock.</td><td></td></tr>
|
||||
/// <tr><td>sigo </td><td>Sigo bike.</td><td></td></tr>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue