using System;
using System.Collections.Generic;
using TINK.Model.Bikes.BikeInfoNS.BC;
using TINK.Model.Bikes.BikeInfoNS.BikeNS;
using TINK.Model.Bikes.BikeInfoNS.DriveNS;
using TINK.Model.MiniSurvey;
using TINK.Model.State;
namespace TINK.Model.Bikes.BikeInfoNS.CopriLock
{
public class BikeInfo : BC.BikeInfo
{
///
/// Constructs a bike info object for a available bike or bike for which feed back is pending.
///
/// Bike object.
/// Specified the source of the data.
/// Id of station where bike is located.
/// Lock info.
/// If true user has not yet given feedback after returning bike.
/// Holds the uri of the operator or null, in case of single operator setup.
/// Hold tariff description of bike.
public BikeInfo(
Bike bike,
Drive drive,
DataSource dataSource,
string currentStationId,
LockInfo lockInfo,
bool isFeedbackPending = false,
Uri operatorUri = null,
RentalDescription tariffDescription = null,
bool? isDemo = DEFAULTVALUEISDEMO,
IEnumerable group = null,
IMiniSurveyModel miniSurvey = null,
string co2Saving = null) : base(
new StateInfo(isFeedbackPending),
bike != null
? new Bike(
bike.Id,
LockModel.Sigo,
bike.WheelType /* Ensure consistent lock model value */,
bike.TypeOfBike,
bike.AaRideType,
bike.Description)
: throw new ArgumentNullException(nameof(bike)),
drive,
dataSource,
isDemo,
group,
currentStationId,
operatorUri,
tariffDescription)
{
LockInfo = lockInfo;
MiniSurvey = miniSurvey;
Co2Saving = co2Saving;
}
///
/// Constructs a bike info object for a requested bike.
///
/// Bike object.
/// Specified the source of the data.
/// 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.
/// Lock info.
/// Holds the uri of the operator or null, in case of single operator setup.
/// Hold tariff description of bike.
/// Provider for current date time to calculate remaining time on demand for state of type reserved.
public BikeInfo(
Bike bike,
Drive drive,
DataSource dataSource,
DateTime requestedAt,
string mailAddress,
string currentStationId,
LockInfo lockInfo,
Uri operatorUri,
RentalDescription tariffDescription,
Func dateTimeProvider,
bool? isDemo = DEFAULTVALUEISDEMO,
IEnumerable group = null) : base(
new StateInfo(
dateTimeProvider,
requestedAt,
tariffDescription?.MaxReservationTimeSpan ?? StateRequestedInfo.UNKNOWNMAXRESERVATIONTIMESPAN,
mailAddress,
""), // BC code
bike != null
? new Bike(
bike.Id,
LockModel.Sigo /* Ensure consistent lock model value */,
bike.WheelType,
bike.TypeOfBike,
bike.AaRideType,
bike.Description)
: throw new ArgumentNullException(nameof(bike)),
drive,
dataSource,
isDemo,
group,
currentStationId,
operatorUri,
tariffDescription)
{
LockInfo = lockInfo;
MiniSurvey = new MiniSurveyModel();
Co2Saving = string.Empty;
}
///
/// Constructs a bike info object for a booked bike.
///
/// Bike object.
/// Specified the source of the data.
/// 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.
/// Lock info.
/// Holds the uri of the operator or null, in case of single operator setup.
/// Hold tariff description of bike.
public BikeInfo(
Bike bike,
Drive drive,
DataSource dataSource,
DateTime bookedAt,
string mailAddress,
string currentStationId,
LockInfo lockInfo,
Uri operatorUri,
RentalDescription tariffDescription = null,
bool? isDemo = DEFAULTVALUEISDEMO,
IEnumerable group = null) : base(
new StateInfo(
bookedAt,
mailAddress,
""),
bike != null
? new Bike(
bike.Id,
LockModel.Sigo /* Ensure consistent lock model value */,
bike.WheelType,
bike.TypeOfBike,
bike.AaRideType,
bike.Description)
: throw new ArgumentNullException(nameof(bike)),
drive,
dataSource,
isDemo,
group,
currentStationId,
operatorUri,
tariffDescription)
{
LockInfo = lockInfo;
MiniSurvey = new MiniSurveyModel();
Co2Saving = string.Empty;
}
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.");
}
/// Holds the lock info.
public LockInfo LockInfo { get; private set; }
public IMiniSurveyModel MiniSurvey { get; private set; }
public string Co2Saving { get; private set; }
}
}