using System; using System.Collections.Generic; using TINK.Model.Bikes.Bike; using TINK.Model.State; namespace TINK.Model.Bike.BluetoothLock { public class BikeInfo : BC.BikeInfo, IBikeInfo { /// /// Constructs a bike info object for a available bike. /// /// Unique id of bike. /// Id of the lock. /// GUID specifying the lock. /// Id of station where bike is located. /// Holds the uri of the operator or null, in case of single operator setup. /// Hold tariff description of bike. /// Trike, two wheels, mono, .... public BikeInfo( string bikeId, int lockId, Guid lockGuid, string currentStationId, Uri operatorUri = null, RentalDescription tariffDescription = null, bool? isDemo = DEFAULTVALUEISDEMO, IEnumerable group = null, WheelType? wheelType = null, TypeOfBike? typeOfBike = null, string description = null) : base( new StateInfo(), bikeId, LockModel.ILockIt, isDemo, group, wheelType, typeOfBike, description, currentStationId, operatorUri, tariffDescription) { LockInfo = new LockInfo.Builder { Id = lockId, Guid = lockGuid }.Build(); } /// /// Constructs a bike info object for a requested bike. /// /// Provider for current date time to calculate remainig time on demand for state of type reserved. /// Unique id of bike. /// Id of the lock. /// GUID specifying the lock. /// Date time when bike was requested /// Mail address of user which requested bike. /// Name of station where bike is located, null if bike is on the road. /// Holds the uri of the operator or null, in case of single operator setup. /// Hold tariff description of bike. /// Date time provider to calculate reaining time. /// public BikeInfo( string id, int lockId, Guid lockGuid, byte[] userKey, byte[] adminKey, byte[] seed, DateTime requestedAt, string mailAddress, string currentStationId, Uri operatorUri, RentalDescription tariffDescription, Func dateTimeProvider, bool? isDemo = DEFAULTVALUEISDEMO, IEnumerable group = null, WheelType? wheelType = null, TypeOfBike? typeOfBike = null, string description = null) : base( new StateInfo( dateTimeProvider, requestedAt, mailAddress, ""), id, LockModel.ILockIt, isDemo, group, wheelType, typeOfBike, description, currentStationId, operatorUri, tariffDescription) { LockInfo = new LockInfo.Builder { Id = lockId, Guid = lockGuid, UserKey = userKey, AdminKey = adminKey, Seed = seed }.Build(); } /// /// Constructs a bike info object for a booked bike. /// /// Unique id of bike. /// Id of the lock. /// GUID specifying the lock. /// Date time when bike was booked /// Mail address of user which booked bike. /// Name of station where bike is located, null if bike is on the road. /// Holds the uri of the operator or null, in case of single operator setup. /// Hold tariff description of bike. /// public BikeInfo( string id, int lockId, Guid lockGuid, byte[] userKey, byte[] adminKey, byte[] seed, DateTime bookedAt, string mailAddress, string currentStationId, Uri operatorUri, RentalDescription tariffDescription = null, bool? isDemo = DEFAULTVALUEISDEMO, IEnumerable group = null, WheelType? wheelType = null, TypeOfBike? typeOfBike = null, string description = null) : base( new StateInfo( bookedAt, mailAddress, ""), id, LockModel.ILockIt, isDemo, group, wheelType, typeOfBike, description, currentStationId, operatorUri, tariffDescription) { LockInfo = new LockInfo.Builder { Id = lockId, Guid = lockGuid, UserKey = userKey, AdminKey = adminKey, Seed = seed }.Build(); } public BikeInfo(BC.BikeInfo bikeInfo, LockInfo lockInfo) : base( bikeInfo ?? throw new ArgumentException($"Can not copy-construct {typeof(BikeInfo).Name}-object. Source bike info must not be null.")) { LockInfo = lockInfo ?? throw new ArgumentException($"Can not copy-construct {typeof(BikeInfo).Name}-object. Source lock object must not be null."); } public LockInfo LockInfo { get; private set; } } }