Version 3.0.294

This commit is contained in:
Oliver Hauff 2022-04-25 22:15:15 +02:00
parent d92fb4a40f
commit 8f40f2c208
133 changed files with 17890 additions and 14246 deletions

View file

@ -180,13 +180,13 @@ namespace TINK.Repository
/// <returns>Response on updating locking state.</returns>
public async Task<ReservationBookingResponse> UpdateLockingStateAsync(
string bikeId,
LocationDto location,
lock_state state,
double batteryLevel,
Uri operatorUri)=>
Uri operatorUri,
LocationDto location,
double batteryLevel) =>
await DoUpdateLockingStateAsync(
operatorUri?.AbsoluteUri ?? m_oCopriHost.AbsoluteUri,
requestBuilder.UpateLockingState(bikeId, location, state, batteryLevel),
requestBuilder.UpateLockingState(bikeId, state, location, batteryLevel),
UserAgent);
/// <summary> Gets booking request request. </summary>
@ -200,12 +200,22 @@ namespace TINK.Repository
Guid guid,
double batteryPercentage,
Uri operatorUri)
{
return await DoBookAsync(
=> await DoBookAsync(
operatorUri?.AbsoluteUri ?? m_oCopriHost.AbsoluteUri,
requestBuilder.DoBook(bikeId, guid, batteryPercentage),
UserAgent);
}
/// <summary> Books a bike and starts opening bike. </summary>
/// <param name="bikeId">Id of the bike to book.</param>
/// <param name="operatorUri">Holds the uri of the operator or null, in case of single operator setup.</param>
/// <returns>Response on booking request.</returns>
public async Task<ReservationBookingResponse> BookAndStartOpeningAsync(
string bikeId,
Uri operatorUri)
=> await DoBookAsync(
operatorUri?.AbsoluteUri ?? m_oCopriHost.AbsoluteUri,
requestBuilder.BookAndStartOpening(bikeId),
UserAgent);
/// <summary> Returns a bike. </summary>
/// <param name="bikeId">Id of the bike to return.</param>
@ -218,12 +228,24 @@ namespace TINK.Repository
LocationDto location,
ISmartDevice smartDevice,
Uri operatorUri)
{
return await DoReturn(
=> await DoReturn(
operatorUri?.AbsoluteUri ?? m_oCopriHost.AbsoluteUri,
requestBuilder.DoReturn(bikeId, location, smartDevice),
UserAgent);
}
/// <summary> Returns a bike and starts closing. </summary>
/// <param name="bikeId">Id of the bike to return.</param>
/// <param name="smartDevice">Provides info about hard and software.</param>
/// <param name="operatorUri">Holds the uri of the operator or null, in case of single operator setup.</param>
/// <returns>Response on returning request.</returns>
public async Task<DoReturnResponse> ReturnAndStartClosingAsync(
string bikeId,
ISmartDevice smartDevice,
Uri operatorUri)
=> await DoReturn(
operatorUri?.AbsoluteUri ?? m_oCopriHost.AbsoluteUri,
requestBuilder.ReturnAndStartClosing(bikeId, smartDevice),
UserAgent);
/// <summary> Submits feedback to copri server. </summary>
/// <param name="bikeId">Id of the bike to which the feedback is related to.</param>
@ -630,10 +652,10 @@ namespace TINK.Repository
string agent = null)
{
#if !WINDOWS_UWP
string l_oBikesAvaialbeResponse;
string bikesAvaialbeResponse;
try
{
l_oBikesAvaialbeResponse = await PostAsync(copriHost, command, agent);
bikesAvaialbeResponse = await PostAsync(copriHost, command, agent);
}
catch (System.Exception exception)
{
@ -651,7 +673,7 @@ namespace TINK.Repository
}
// Extract bikes from response.
return JsonConvertRethrow.DeserializeObject<ResponseContainer<ReservationBookingResponse>>(l_oBikesAvaialbeResponse)?.shareejson;
return JsonConvertRethrow.DeserializeObject<ResponseContainer<ReservationBookingResponse>>(bikesAvaialbeResponse)?.shareejson;
#else
return null;
#endif

View file

@ -1380,7 +1380,7 @@ namespace TINK.Repository
get
{
var l_iCount = 1;
while (GetBikesAvailable(CopriDevelHostUri, MerchantId, p_eSampleSet: ActiveSampleSet, p_lStageIndex: l_iCount) != null)
while (GetBikesAvailable(CopriDevelHostUri, MerchantId, sampleSet: ActiveSampleSet, stageIndex: l_iCount) != null)
{
l_iCount++;
}
@ -1474,21 +1474,21 @@ namespace TINK.Repository
/// <summary>
/// Gets list of bikes from memory.
/// </summary>
/// <param name="p_strMerchantId">Id of the merchant.</param>
/// <param name="p_strSessionCookie">Auto cookie of user if user is logged in.</param>
/// <param name="p_eSampleSet">Set of samples.</param>
/// <param name="p_lStageIndex">Index of the stage.</param>
/// <param name="merchantId">Id of the merchant.</param>
/// <param name="sessionCookie">Auto cookie of user if user is logged in.</param>
/// <param name="sampleSet">Set of samples.</param>
/// <param name="stageIndex">Index of the stage.</param>
/// <returns></returns>
public static BikesAvailableResponse GetBikesAvailable(
string p_strMerchantId,
string p_strSessionCookie = null,
SampleSets p_eSampleSet = DEFAULT_SAMPLE_SET,
long p_lStageIndex = DEFAULT_STAGE_INDEX)
string merchantId,
string sessionCookie = null,
SampleSets sampleSet = DEFAULT_SAMPLE_SET,
long stageIndex = DEFAULT_STAGE_INDEX)
{
switch (p_eSampleSet)
switch (sampleSet)
{
case SampleSets.Set1:
switch (p_lStageIndex)
switch (stageIndex)
{
case 1:
return CopriCallsStatic.DeserializeResponse<BikesAvailableResponse>(BIKES_AVAILABLE_SET01_001_FILE);
@ -1497,7 +1497,7 @@ namespace TINK.Repository
return null;
}
case SampleSets.Set2:
switch (p_lStageIndex)
switch (stageIndex)
{
case 1:
return CopriCallsStatic.DeserializeResponse<BikesAvailableResponse>(BIKES_AVAILABLE_SET02_001_FILE);
@ -1513,7 +1513,7 @@ namespace TINK.Repository
}
case SampleSets.ShareeFr01_Set1:
switch (p_lStageIndex)
switch (stageIndex)
{
case 1:
return CopriCallsStatic.DeserializeResponse<BikesAvailableResponse>(BIKES_AVAILABLE_REQUEST_SHAREEFR01_SET1_FILE);
@ -1619,15 +1619,18 @@ namespace TINK.Repository
public Task<ReservationBookingResponse> UpdateLockingStateAsync(
string bikeId,
LocationDto geolocation,
lock_state state,
double batteryLevel,
Uri operatorUri) => null;
Uri operatorUri,
LocationDto geolocation,
double batteryLevel) => null;
public Task<ReservationBookingResponse> DoBookAsync(string bikeId, Guid guid, double batteryPercentage, Uri operatorUri)
{
return null;
}
=> null;
public Task<ReservationBookingResponse> BookAndStartOpeningAsync(
string bikeId,
Uri operatorUri)
=> null;
public Task<DoReturnResponse> DoReturn(
string bikeId,
@ -1636,6 +1639,12 @@ namespace TINK.Repository
Uri operatorUri)
=> null;
public Task<DoReturnResponse> ReturnAndStartClosingAsync(
string bikeId,
ISmartDevice smartDevice,
Uri operatorUri)
=> throw new NotImplementedException();
public Task<SubmitFeedbackResponse> DoSubmitFeedback(string bikeId, string message, bool isBikeBroken, Uri operatorUri)
=> null;

View file

@ -166,16 +166,23 @@ namespace TINK.Repository
public Task<ReservationBookingResponse> UpdateLockingStateAsync(
string bikeId,
LocationDto geolocation,
lock_state state,
double batteryLevel,
Uri operatorUri)
Uri operatorUri,
LocationDto geolocation,
double batteryLevel)
=> throw new System.Exception("Aktualisierung des Schlossstatuses im Offlinemodus nicht möglich!");
public Task<ReservationBookingResponse> DoBookAsync(string bikeId, Guid guid, double batteryPercentage, Uri operatorUri)
{
throw new System.Exception("Buchung im Offlinemodus nicht möglich!");
}
=> throw new System.Exception("Buchung im Offlinemodus nicht möglich!");
/// <summary> Books a bike and starts opening bike. </summary>
/// <param name="bikeId">Id of the bike to book.</param>
/// <param name="operatorUri">Holds the uri of the operator or null, in case of single operator setup.</param>
/// <returns>Response on booking request.</returns>
public Task<ReservationBookingResponse> BookAndStartOpeningAsync(
string bikeId,
Uri operatorUri)
=> throw new System.Exception("Buchung mit Start von Schlossöffnen ist im Offlinemodus nicht möglich!");
public Task<DoReturnResponse> DoReturn(
string bikeId,
@ -184,6 +191,17 @@ namespace TINK.Repository
Uri operatorUri)
=> throw new System.Exception("Rückgabe im Offlinemodus nicht möglich!");
/// <summary> Returns a bike and starts closing. </summary>
/// <param name="bikeId">Id of the bike to return.</param>
/// <param name="smartDevice">Provides info about hard and software.</param>
/// <param name="operatorUri">Holds the uri of the operator or null, in case of single operator setup.</param>
/// <returns>Response on returning request.</returns>
public Task<DoReturnResponse> ReturnAndStartClosingAsync(
string bikeId,
ISmartDevice smartDevice,
Uri operatorUri)
=> throw new System.Exception("Rückgabe mit Schloss schließen Befehl im Offlinemodus nicht möglich!");
public Task<SubmitFeedbackResponse> DoSubmitFeedback(string bikeId, string message, bool isBikeBroken, Uri operatorUri) =>
throw new System.Exception("Übermittlung von Feedback im Offlinemodus nicht möglich!");

View file

@ -66,12 +66,12 @@ namespace TINK.Repository
/// <returns>Response on updating locking state.</returns>
Task<ReservationBookingResponse> UpdateLockingStateAsync(
string bikeId,
LocationDto location,
lock_state state,
double batteryPercentage,
Uri operatorUri);
Uri operatorUri,
LocationDto location = null,
double batteryPercentage = double.NaN);
/// <summary> Books a bike. </summary>
/// <summary> Books a bluetooth bike. </summary>
/// <param name="bikeId">Id of the bike to book.</param>
/// <param name="guid">Used to publish GUID from app to copri. Used for initial setup of bike in copri.</param>
/// <param name="batteryPercentage">Holds the filling level percentage of the battery.</param>
@ -83,6 +83,14 @@ namespace TINK.Repository
double batteryPercentage,
Uri operatorUri);
/// <summary> Books a bike and starts opening bike. </summary>
/// <param name="bikeId">Id of the bike to book.</param>
/// <param name="operatorUri">Holds the uri of the operator or null, in case of single operator setup.</param>
/// <returns>Response on booking request.</returns>
Task<ReservationBookingResponse> BookAndStartOpeningAsync(
string bikeId,
Uri operatorUri);
/// <summary> Returns a bike. </summary>
/// <param name="bikeId">Id of the bike to return.</param>
/// <param name="location">Geolocation of lock.</param>
@ -95,6 +103,16 @@ namespace TINK.Repository
ISmartDevice smartDevice,
Uri operatorUri);
/// <summary> Returns a bike and starts closing. </summary>
/// <param name="bikeId">Id of the bike to return.</param>
/// <param name="smartDevice">Provides info about hard and software.</param>
/// <param name="operatorUri">Holds the uri of the operator or null, in case of single operator setup.</param>
/// <returns>Response on returning request.</returns>
Task<DoReturnResponse> ReturnAndStartClosingAsync(
string bikeId,
ISmartDevice smartDevice,
Uri operatorUri);
/// <summary>
/// Submits feedback to copri server.
/// </summary>

View file

@ -68,23 +68,34 @@ namespace TINK.Repository.Request
/// <returns>Request to update locking state.</returns>
string UpateLockingState(
string bikeId,
LocationDto location,
lock_state state,
double batteryPercentage);
LocationDto location = null,
double batteryPercentage = double.NaN);
/// <summary> Gets booking request request (synonym: booking == renting == mieten). </summary>
/// <summary> Gets the booking request (synonym: booking == renting == mieten). </summary>
/// <param name="bikeId">Id of the bike to book.</param>
/// <param name="guid">Used to publish GUID from app to copri. Used for initial setup of bike in copri.</param>
/// <param name="batteryPercentage">Holds the filling level percentage of the battery.</param>
/// <returns>Request to booking bike.</returns>
string DoBook(string bikeId, Guid guid, double batteryPercentage);
/// <summary> Gets the request to book and start opening the bike (synonym: booking == renting == mieten). </summary>
/// <param name="bikeId">Id of the bike to book.</param>
/// <returns>Request to booking bike.</returns>
string BookAndStartOpening(string bikeId);
/// <summary> Gets request for returning the bike. </summary>
/// <param name="bikeId">Id of the bike to return.</param>
/// <param name="location">Geolocation of lock when returning bike.</param>
/// <returns>Requst on returning request.</returns>
string DoReturn(string bikeId, LocationDto location, ISmartDevice smartDevice);
/// <summary> Returns a bike and starts closing. </summary>
/// <param name="bikeId">Id of the bike to return.</param>
/// <param name="smartDevice">Provides info about hard and software.</param>
/// <returns>Response to send to corpi.</returns>
string ReturnAndStartClosing(string bikeId, ISmartDevice smartDevice);
/// <summary>
/// Gets request for submiting feedback to copri server.
/// </summary>
@ -103,8 +114,10 @@ namespace TINK.Repository.Request
/// <summary> Copri locking states</summary>
public enum lock_state
{
locking,
locked,
unlocked
unlocking,
unlocked,
}
/// <summary> Holds lockation info.</summary>

View file

@ -103,13 +103,24 @@ namespace TINK.Repository.Request
public string StartReturningBike(string bikeId)
=> throw new NotSupportedException();
public string UpateLockingState(string bikeId, LocationDto geolocation, lock_state state, double batteryPercentage)
public string UpateLockingState(string bikeId, lock_state state, LocationDto geolocation, double batteryPercentage)
=> throw new NotSupportedException();
public string DoBook(string bikeId, Guid guid, double batteryPercentage) => throw new NotSupportedException();
/// <summary> Gets the request to book and start opening the bike (synonym: booking == renting == mieten). </summary>
/// <param name="bikeId">Id of the bike to book.</param>
/// <returns>Request to booking bike.</returns>
public string BookAndStartOpening(string bikeId) => throw new NotSupportedException();
public string DoReturn(string bikeId, LocationDto geolocation, ISmartDevice smartDevice) => throw new NotSupportedException();
/// <summary> Returns a bike and starts closing. </summary>
/// <param name="bikeId">Id of the bike to return.</param>
/// <param name="smartDevice">Provides info about hard and software.</param>
/// <returns>Response to send to corpi.</returns>
public string ReturnAndStartClosing(string bikeId, ISmartDevice smartDevice) => throw new NotSupportedException();
/// <summary> Gets submit feedback request. </summary>
/// <param name="bikeId">Id of the bike to which the feedback is related to.</param>
/// <param name="message">General purpose message or error description.</param>

View file

@ -107,7 +107,11 @@ namespace TINK.Repository.Request
/// <param name="bikeId">Id of the bike to update locking state for.</param>
/// <param name="state">New locking state.</param>
/// <returns>Request to update locking state.</returns>
public string UpateLockingState(string bikeId, LocationDto geolocation, lock_state state, double batteryPercentage)
public string UpateLockingState(
string bikeId,
lock_state state,
LocationDto geolocation,
double batteryPercentage)
=> $"request=booking_update&bike={bikeId}{GetLocationParameters(geolocation)}&lock_state={state}{GetBatteryPercentageParameters(batteryPercentage)}&authcookie={SessionCookie}{MerchantId}";
/// <summary> Gets booking request request (synonym: booking == renting == mieten). </summary>
@ -119,21 +123,37 @@ namespace TINK.Repository.Request
public string DoBook(string bikeId, Guid guid, double batteryPercentage)
=> $"request=booking_update&bike={bikeId}&authcookie={SessionCookie}{MerchantId}&Ilockit_GUID={guid}&state=occupied&lock_state=unlocked{GetBatteryPercentageParameters(batteryPercentage)}";
/// <summary> Gets the request to book and start opening the bike (synonym: booking == renting == mieten). </summary>
/// <param name="bikeId">Id of the bike to book.</param>
/// <returns>Request to booking bike.</returns>
public string BookAndStartOpening(string bikeId)
=> $"request=booking_request&bike={bikeId}&authcookie={SessionCookie}{MerchantId}&state=occupied&lock_state={lock_state.unlocking}";
/// <summary> Gets request for returning the bike. </summary>
/// <remarks> Operator specific call.</remarks>
/// <param name="bikeId">Id of bike to return.</param>
/// <param name="geolocation">Geolocation of lock when returning bike.</param>
/// <returns>Requst on returning request.</returns>
public string DoReturn(string bikeId, LocationDto geolocation, ISmartDevice smartDevice)
{
return $"request=booking_update" +
=> $"request=booking_update" +
$"&bike={bikeId}" +
$"&authcookie={SessionCookie}{MerchantId}" +
$"&state=available" +
$"{GetLocationParameters(geolocation)}" +
$"&lock_state=locked" +
$"{GetSmartDeviceParameters(smartDevice)}";
}
/// <summary> Returns a bike and starts closing. </summary>
/// <param name="bikeId">Id of the bike to return.</param>
/// <param name="smartDevice">Provides info about hard and software.</param>
/// <returns>Response to send to corpi.</returns>
public string ReturnAndStartClosing(string bikeId, ISmartDevice smartDevice)
=> $"request=booking_update" +
$"&bike={bikeId}" +
$"&authcookie={SessionCookie}{MerchantId}" +
$"&state=available" +
$"&lock_state={lock_state.locking}" +
$"{GetSmartDeviceParameters(smartDevice)}";
/// <summary> Gets submit feedback request. </summary>
/// <param name="bikeId">Id of the bike to return.</param>

View file

@ -1,4 +1,4 @@
using System.Runtime.Serialization;
 using System.Runtime.Serialization;
namespace TINK.Repository.Response
{
@ -50,8 +50,9 @@ namespace TINK.Repository.Response
/// <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> </td><td>Bike with a bord computer. </td><td></td></tr>
/// <tr><td>? </td><td>Bike with a bluetooth lock.</td><td></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>
/// </table>
/// </remarks>
[DataMember]
@ -66,6 +67,10 @@ namespace TINK.Repository.Response
[DataMember]
public string bike_charge { get; private set; }
/// <summary> Locking state of the bike. </summary>
[DataMember]
public string lock_state { get; private set; }
/// <summary>
/// Textual description of response.
/// </summary>