Version 3.0.337

This commit is contained in:
Anja Müller-Meißner 2022-08-30 15:42:25 +02:00
parent fd0e63cf10
commit 573fe77e12
2336 changed files with 33688 additions and 86082 deletions

View file

@ -1,12 +1,13 @@
using Serilog;
using System;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Serilog;
using TINK.Model.Connector.Updater;
using TINK.Model.Device;
using TINK.Model.User.Account;
using TINK.Repository;
using TINK.Repository.Request;
using TINK.Repository.Response;
using TINK.Model.User.Account;
using TINK.Model.Device;
using System.Collections.Generic;
namespace TINK.Model.Connector
{
@ -84,7 +85,7 @@ namespace TINK.Model.Connector
/// </summary>
/// <param name="bike">Bike to book.</param>
public async Task DoReserve(
Bikes.Bike.BC.IBikeInfoMutable bike)
Bikes.BikeInfoNS.BC.IBikeInfoMutable bike)
{
Log.ForContext<Command>().Error("Unexpected booking request detected. No user logged in.");
await Task.CompletedTask;
@ -92,7 +93,7 @@ namespace TINK.Model.Connector
/// <summary> Request to cancel a reservation.</summary>
/// <param name="p_oBike">Bike to book.</param>
public async Task DoCancelReservation(Bikes.Bike.BC.IBikeInfoMutable bike)
public async Task DoCancelReservation(Bikes.BikeInfoNS.BC.IBikeInfoMutable bike)
{
Log.ForContext<Command>().Error("Unexpected cancel reservation request detected. No user logged in.");
await Task.CompletedTask;
@ -100,7 +101,7 @@ namespace TINK.Model.Connector
/// <summary> Get authentication keys.</summary>
/// <param name="bike">Bike to book.</param>
public async Task CalculateAuthKeys(Bikes.Bike.BluetoothLock.IBikeInfoMutable bike)
public async Task CalculateAuthKeys(Bikes.BikeInfoNS.BluetoothLock.IBikeInfoMutable bike)
{
Log.ForContext<Command>().Error("Unexpected request to get authenticatin keys detected. No user logged in.");
await Task.CompletedTask;
@ -110,7 +111,7 @@ namespace TINK.Model.Connector
/// <param name="bike">Bike to update locking state for.</param>
/// <param name="location">Location where lock was opened/ changed.</param>
/// <returns>Response on updating locking state.</returns>
public async Task StartReturningBike(Bikes.Bike.BC.IBikeInfoMutable bike)
public async Task StartReturningBike(Bikes.BikeInfoNS.BC.IBikeInfoMutable bike)
{
Log.ForContext<Command>().Error("Unexpected request to notify about start of returning bike. No user logged in.");
await Task.CompletedTask;
@ -120,26 +121,26 @@ namespace TINK.Model.Connector
/// <remarks> Operator specific call.</remarks>
/// <param name="bike">Bike to return.</param>
/// <returns>Response on notification about start of returning sequence.</returns>
public async Task UpdateLockingStateAsync(Bikes.Bike.BluetoothLock.IBikeInfoMutable bike, LocationDto location)
public async Task UpdateLockingStateAsync(Bikes.BikeInfoNS.BluetoothLock.IBikeInfoMutable bike, LocationDto location)
{
Log.ForContext<Command>().Error("Unexpected request to update locking state detected. No user logged in.");
await Task.CompletedTask;
}
public async Task DoBook(Bikes.Bike.BC.IBikeInfoMutable bike)
public async Task DoBook(Bikes.BikeInfoNS.BC.IBikeInfoMutable bike)
{
Log.ForContext<Command>().Error("Unexpected booking request detected. No user logged in.");
await Task.CompletedTask;
}
public async Task BookAndOpenAync(Bikes.Bike.CopriLock.IBikeInfoMutable bike)
public async Task BookAndOpenAync(Bikes.BikeInfoNS.CopriLock.IBikeInfoMutable bike)
{
Log.ForContext<Command>().Error("Unexpected request to book and open bike detected. No user logged in.");
await Task.CompletedTask;
}
public async Task<BookingFinishedModel> DoReturn(
Bikes.Bike.BC.IBikeInfoMutable bike,
Bikes.BikeInfoNS.BC.IBikeInfoMutable bike,
LocationDto location,
ISmartDevice smartDevice)
{
@ -148,7 +149,7 @@ namespace TINK.Model.Connector
}
public async Task<BookingFinishedModel> ReturnAndCloseAsync(
Bikes.Bike.CopriLock.IBikeInfoMutable bike,
Bikes.BikeInfoNS.CopriLock.IBikeInfoMutable bike,
ISmartDevice smartDevice)
{
Log.ForContext<Command>().Error("Unexpected close lock and return request detected. No user logged in.");
@ -177,10 +178,10 @@ namespace TINK.Model.Connector
await Task.CompletedTask;
}
public Task OpenLockAsync(Bikes.Bike.CopriLock.IBikeInfoMutable bike)
public Task OpenLockAsync(Bikes.BikeInfoNS.CopriLock.IBikeInfoMutable bike)
=> throw new NotImplementedException();
public Task CloseLockAsync(Bikes.Bike.CopriLock.IBikeInfoMutable bike)
public Task CloseLockAsync(Bikes.BikeInfoNS.CopriLock.IBikeInfoMutable bike)
=> throw new NotImplementedException();
}
}

View file

@ -1,13 +1,14 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using TINK.Model.Bike.BluetoothLock;
using TINK.Model.Bikes.BikeInfoNS.BluetoothLock;
using TINK.Model.Connector.Updater;
using TINK.Model.Device;
using TINK.Model.User.Account;
using TINK.Repository;
using TINK.Repository.Exception;
using TINK.Repository.Request;
using TINK.Repository.Response;
using TINK.Model.User.Account;
using TINK.Model.Device;
using System.Collections.Generic;
using TINK.Services.CopriApi;
namespace TINK.Model.Connector
@ -25,7 +26,7 @@ namespace TINK.Model.Connector
public CommandLoggedIn(ICopriServerBase p_oCopriServer,
string sessionCookie,
string mail,
Func<DateTime> dateTimeProvider) : base(p_oCopriServer, sessionCookie, mail, dateTimeProvider)
Func<DateTime> dateTimeProvider) : base(p_oCopriServer, sessionCookie, mail, dateTimeProvider)
{
}
@ -75,7 +76,7 @@ namespace TINK.Model.Connector
/// Request to reserve a bike.
/// </summary>
/// <param name="bike">Bike to book.</param>
public async Task DoReserve(Bikes.Bike.BC.IBikeInfoMutable bike)
public async Task DoReserve(Bikes.BikeInfoNS.BC.IBikeInfoMutable bike)
{
if (bike == null)
{
@ -93,13 +94,13 @@ namespace TINK.Model.Connector
throw;
}
bike.Load(response, Mail, Bikes.Bike.BC.NotifyPropertyChangedLevel.None);
bike.Load(response, Mail, Bikes.BikeInfoNS.BC.NotifyPropertyChangedLevel.None);
}
/// <summary> Request to cancel a reservation.</summary>
/// <param name="bike">Bike to cancel reservation.</param>
public async Task DoCancelReservation(
Bikes.Bike.BC.IBikeInfoMutable bike)
Bikes.BikeInfoNS.BC.IBikeInfoMutable bike)
{
if (bike == null)
{
@ -117,12 +118,12 @@ namespace TINK.Model.Connector
throw;
}
bike.Load(Bikes.Bike.BC.NotifyPropertyChangedLevel.None);
bike.Load(Bikes.BikeInfoNS.BC.NotifyPropertyChangedLevel.None);
}
/// <summary> Get authentication keys.</summary>
/// <param name="bike">Bike to get new keys for.</param>
public async Task CalculateAuthKeys(Bikes.Bike.BluetoothLock.IBikeInfoMutable bike)
public async Task CalculateAuthKeys(Bikes.BikeInfoNS.BluetoothLock.IBikeInfoMutable bike)
{
if (bike == null)
{
@ -152,17 +153,17 @@ namespace TINK.Model.Connector
}
UpdaterJSON.Load(
bike,
response,
Mail,
Bikes.Bike.BC.NotifyPropertyChangedLevel.None);
bike,
response,
Mail,
Bikes.BikeInfoNS.BC.NotifyPropertyChangedLevel.None);
}
/// <summary> Notifies COPRI about start of returning sequence. </summary>
/// <remarks> Operator specific call.</remarks>
/// <param name="bike">Bike to return.</param>
/// <returns>Response on notification about start of returning sequence.</returns>
public async Task StartReturningBike(Bikes.Bike.BC.IBikeInfoMutable bike)
public async Task StartReturningBike(Bikes.BikeInfoNS.BC.IBikeInfoMutable bike)
{
if (bike == null)
{
@ -188,7 +189,7 @@ namespace TINK.Model.Connector
/// <param name="location">Location of the bike.</param>
/// <returns>Response on updating locking state.</returns>
public async Task UpdateLockingStateAsync(
Bikes.Bike.BluetoothLock.IBikeInfoMutable bike,
IBikeInfoMutable bike,
LocationDto location)
{
if (bike == null)
@ -221,10 +222,10 @@ namespace TINK.Model.Connector
try
{
(await CopriServer.UpdateLockingStateAsync(
bike.Id,
bike.Id,
state.Value,
bike.OperatorUri,
location,
location,
bike.LockInfo.BatteryPercentage)).GetIsBookingResponseOk(bike.Id);
}
catch (Exception)
@ -236,7 +237,7 @@ namespace TINK.Model.Connector
/// <summary> Request to book a bike. </summary>
/// <param name="bike">Bike to book.</param>
public async Task DoBook(Bikes.Bike.BC.IBikeInfoMutable bike)
public async Task DoBook(Bikes.BikeInfoNS.BC.IBikeInfoMutable bike)
{
if (bike == null)
{
@ -249,22 +250,22 @@ namespace TINK.Model.Connector
double batteryPercentage = btBike != null ? btBike.LockInfo.BatteryPercentage : double.NaN;
response = (await CopriServer.DoBookAsync(
bike.Id,
guid,
bike.Id,
guid,
batteryPercentage,
bike.OperatorUri)).GetIsBookingResponseOk(bike.Id);
bike.Load(
response,
response,
Mail,
Bikes.Bike.BC.NotifyPropertyChangedLevel.None);
Bikes.BikeInfoNS.BC.NotifyPropertyChangedLevel.None);
}
/// <summary>
/// Books a bike and opens the lock.
/// </summary>
/// <param name="bike">Bike to book and open.</param>
public async Task BookAndOpenAync(Bikes.Bike.CopriLock.IBikeInfoMutable bike)
public async Task BookAndOpenAync(Bikes.BikeInfoNS.CopriLock.IBikeInfoMutable bike)
=> await Polling.BookAndOpenAync(CopriServer, bike, Mail);
/// <summary> Request to return a bike.</summary>
@ -272,7 +273,7 @@ namespace TINK.Model.Connector
/// <param name="locaton">Position of the bike for bluetooth locks.</param>
/// <param name="smartDevice">Provides info about hard and software.</param>
public async Task<BookingFinishedModel> DoReturn(
Bikes.Bike.BC.IBikeInfoMutable bike,
Bikes.BikeInfoNS.BC.IBikeInfoMutable bike,
LocationDto location = null,
ISmartDevice smartDevice = null)
{
@ -282,16 +283,16 @@ namespace TINK.Model.Connector
}
DoReturnResponse response
= (await CopriServer.DoReturn(bike.Id, location, smartDevice, bike.OperatorUri)).GetIsReturnBikeResponseOk(bike.Id);
= (await CopriServer.DoReturn(bike.Id, location, smartDevice, bike.OperatorUri)).GetIsReturnBikeResponseOk(bike.Id);
bike.Load(Bikes.Bike.BC.NotifyPropertyChangedLevel.None);
bike.Load(Bikes.BikeInfoNS.BC.NotifyPropertyChangedLevel.None);
return response?.Create() ?? new BookingFinishedModel();
}
/// <summary> Request to return bike and close the lock.</summary>
/// <param name="bike">Bike to return.</param>
/// <param name="smartDevice">Provides info about hard and software.</param>
public async Task<BookingFinishedModel> ReturnAndCloseAsync(Bikes.Bike.CopriLock.IBikeInfoMutable bike, ISmartDevice smartDevice = null)
public async Task<BookingFinishedModel> ReturnAndCloseAsync(Bikes.BikeInfoNS.CopriLock.IBikeInfoMutable bike, ISmartDevice smartDevice = null)
=> await Polling.ReturnAndCloseAync(CopriServer, smartDevice, bike);
/// <summary>
@ -302,8 +303,11 @@ namespace TINK.Model.Connector
public async Task DoSubmitFeedback(ICommand.IUserFeedback userFeedback, Uri opertorUri)
=> await CopriServer.DoSubmitFeedback(userFeedback.BikeId, userFeedback.Message, userFeedback.IsBikeBroken, opertorUri);
#else
public async Task DoSubmitFeedback(IUserFeedback userFeedback, Uri opertorUri)
=> await CopriServer.DoSubmitFeedback(userFeedback.BikeId, userFeedback.Message, userFeedback.IsBikeBroken, opertorUri);
/// <summary> Submits feedback for a renting operation.</summary>
public async Task DoSubmitFeedback(
IUserFeedback userFeedback,
Uri opertorUri)
=> await CopriServer.DoSubmitFeedback(userFeedback.BikeId, userFeedback.CurrentChargeBars, userFeedback.Message, userFeedback.IsBikeBroken, opertorUri);
#endif
/// <summary> Submits mini survey to copri server. </summary>
@ -311,9 +315,9 @@ namespace TINK.Model.Connector
public async Task DoSubmitMiniSurvey(IDictionary<string, string> answers)
=> await CopriServer.DoSubmitMiniSurvey(answers);
public async Task OpenLockAsync(Bikes.Bike.CopriLock.IBikeInfoMutable bike)
public async Task OpenLockAsync(Bikes.BikeInfoNS.CopriLock.IBikeInfoMutable bike)
=> await CopriServer.OpenAync(bike);
public async Task CloseLockAsync(Bikes.Bike.CopriLock.IBikeInfoMutable bike)
public async Task CloseLockAsync(Bikes.BikeInfoNS.CopriLock.IBikeInfoMutable bike)
=> await CopriServer.CloseAync(bike);
}
}

View file

@ -1,9 +1,9 @@
using System;
using System.Threading.Tasks;
using TINK.Repository.Request;
using TINK.Model.User.Account;
using TINK.Model.Device;
using System.Collections.Generic;
using System.Threading.Tasks;
using TINK.Model.Device;
using TINK.Model.User.Account;
using TINK.Repository.Request;
namespace TINK.Model.Connector
{
@ -25,54 +25,54 @@ namespace TINK.Model.Connector
/// <summary> Request to reserve a bike.</summary>
/// <param name="bike">Bike to book.</param>
Task DoReserve(Bikes.Bike.BC.IBikeInfoMutable bike);
Task DoReserve(Bikes.BikeInfoNS.BC.IBikeInfoMutable bike);
/// <summary> Request to cancel a reservation.</summary>
/// <param name="bike">Bike to book.</param>
Task DoCancelReservation(Bikes.Bike.BC.IBikeInfoMutable bike);
Task DoCancelReservation(Bikes.BikeInfoNS.BC.IBikeInfoMutable bike);
/// <summary> Get authentication keys to connect to lock.</summary>
/// <param name="bike">Bike to book.</param>
Task CalculateAuthKeys(Bikes.Bike.BluetoothLock.IBikeInfoMutable bike);
Task CalculateAuthKeys(Bikes.BikeInfoNS.BluetoothLock.IBikeInfoMutable bike);
/// <summary> Notifies COPRI about start of returning sequence. </summary>
/// <remarks> Operator specific call.</remarks>
/// <param name="bike">Bike to return.</param>
/// <returns>Response on notification about start of returning sequence.</returns>
Task StartReturningBike(Bikes.Bike.BC.IBikeInfoMutable bike);
Task StartReturningBike(Bikes.BikeInfoNS.BC.IBikeInfoMutable bike);
/// <summary> Updates COPRI lock state for a booked bike. </summary>
/// <param name="bike">Bike to update locking state for.</param>
/// <param name="location">Geolocation of lock when returning bike.</param>
/// <returns>Response on updating locking state.</returns>
Task UpdateLockingStateAsync(Bikes.Bike.BluetoothLock.IBikeInfoMutable bike, LocationDto location = null);
Task UpdateLockingStateAsync(Bikes.BikeInfoNS.BluetoothLock.IBikeInfoMutable bike, LocationDto location = null);
/// <summary> Request to book a bike.</summary>
/// <param name="bike">Bike to book.</param>
Task DoBook(Bikes.Bike.BC.IBikeInfoMutable bike);
Task DoBook(Bikes.BikeInfoNS.BC.IBikeInfoMutable bike);
/// <summary> Request to book a bike and open its lock.</summary>
/// <param name="bike">Bike to book and to open lock for.</param>
Task BookAndOpenAync(Bikes.Bike.CopriLock.IBikeInfoMutable bike);
Task BookAndOpenAync(Bikes.BikeInfoNS.CopriLock.IBikeInfoMutable bike);
/// <summary> Request to open lock.</summary>
/// <param name="bike">Bike for which lock has to be opened.</param>
Task OpenLockAsync(Bikes.Bike.CopriLock.IBikeInfoMutable bike);
Task OpenLockAsync(Bikes.BikeInfoNS.CopriLock.IBikeInfoMutable bike);
/// <summary> Request to close lock.</summary>
/// <param name="bike">Bike for which lock has to be closed.</param>
Task CloseLockAsync(Bikes.Bike.CopriLock.IBikeInfoMutable bike);
Task CloseLockAsync(Bikes.BikeInfoNS.CopriLock.IBikeInfoMutable bike);
/// <summary> Request to return a bike.</summary>
/// <param name="bike">Bike to return.</param>
/// <param name="location">Geolocation of lock when returning bike.</param>
/// <param name="smartDevice">Provides info about hard and software.</param>
Task<BookingFinishedModel> DoReturn(Bikes.Bike.BC.IBikeInfoMutable bike, LocationDto geolocation = null, ISmartDevice smartDevice = null);
Task<BookingFinishedModel> DoReturn(Bikes.BikeInfoNS.BC.IBikeInfoMutable bike, LocationDto geolocation = null, ISmartDevice smartDevice = null);
/// <summary> Request to return bike and close the lock.</summary>
/// <param name="bike">Bike to return.</param>
/// <param name="smartDevice">Provides info about hard and software.</param>
Task<BookingFinishedModel> ReturnAndCloseAsync(Bikes.Bike.CopriLock.IBikeInfoMutable bike, ISmartDevice smartDevice = null);
Task<BookingFinishedModel> ReturnAndCloseAsync(Bikes.BikeInfoNS.CopriLock.IBikeInfoMutable bike, ISmartDevice smartDevice = null);
/// <summary> True if connector has access to copri server, false if cached values are used. </summary>
bool IsConnected { get; }
@ -80,7 +80,10 @@ namespace TINK.Model.Connector
/// <summary> True if user is logged in false if not. </summary>
string SessionCookie { get; }
Task DoSubmitFeedback(IUserFeedback userFeedback, Uri opertorUri);
/// <summary> Submits feedback for a renting operation.</summary>
Task DoSubmitFeedback(
IUserFeedback userFeedback,
Uri opertorUri);
/// <summary> Submits mini survey to copri server. </summary>
/// <param name="answers">Collection of answers.</param>
@ -124,6 +127,11 @@ namespace TINK.Model.Connector
/// <summary> Id of the bike to which the feedback is related to.</summary>
string BikeId { get; }
/// <summary>
/// Holds the current chargeing level of the battery in bars, null if unkonwn.
/// </summary>
int? CurrentChargeBars { get; set; }
/// <summary>
/// Holds whether bike is broken or not.
/// </summary>

View file

@ -17,9 +17,16 @@ namespace TINK.Model.Connector
{
public string BikeId { get; set; }
/// <summary>
/// Holds the current chargeing level of the battery in bars, null if unkonwn.
/// </summary>
public int? CurrentChargeBars { get; set; }
public bool IsBikeBroken { get; set; }
public string Message { get; set; }
}
#endif
}