Version 3.0.312.

This commit is contained in:
Oliver Hauff 2022-06-17 14:17:58 +02:00
parent 310ea37085
commit fd0e63cf10
94 changed files with 3189 additions and 6352 deletions

View file

@ -30,7 +30,7 @@ namespace TINK.Model.Bike.BC
string description = null,
string stationId = null,
Uri operatorUri = null,
TariffDescription tariffDescription = null)
RentalDescription tariffDescription = null)
{
Bike = new Bike(id, lockModel, wheelType, typeOfBike, description);
@ -69,7 +69,7 @@ namespace TINK.Model.Bike.BC
LockModel lockModel,
string stationId,
Uri operatorUri = null,
TariffDescription tariffDescription = null,
RentalDescription tariffDescription = null,
bool? isDemo = DEFAULTVALUEISDEMO,
IEnumerable<string> group = null,
WheelType? wheelType = null,
@ -111,7 +111,7 @@ namespace TINK.Model.Bike.BC
string description,
string stationId,
Uri operatorUri,
TariffDescription tariffDescription,
RentalDescription tariffDescription,
DateTime requestedAt,
string mailAddress,
string code,
@ -157,7 +157,7 @@ namespace TINK.Model.Bike.BC
string description,
string currentStationId,
Uri operatorUri,
TariffDescription tariffDescription,
RentalDescription tariffDescription,
DateTime bookedAt,
string mailAddress,
string code) : this(
@ -190,7 +190,7 @@ namespace TINK.Model.Bike.BC
public string StationId { get; }
/// <summary> Holds description about the tarif. </summary>
public TariffDescription TariffDescription { get; }
public RentalDescription TariffDescription { get; }
/// Holds the rent state of the bike.

View file

@ -39,7 +39,7 @@ namespace TINK.Model.Bike.BC
string stationId = null,
string stationName = null,
Uri operatorUri = null,
TariffDescription tariffDescription = null,
RentalDescription tariffDescription = null,
Func<DateTime> dateTimeProvider = null,
IStateInfo stateInfo = null)
{
@ -82,7 +82,7 @@ namespace TINK.Model.Bike.BC
/// <summary> Holds description about the tarif. </summary>
[DataMember]
public TariffDescription TariffDescription { get; private set; }
public RentalDescription TariffDescription { get; private set; }
/// <summary>
/// Holds the rent state of the bike.

View file

@ -48,7 +48,7 @@ namespace TINK.Model.Bike.BC
Uri OperatorUri { get; }
/// <summary> Holds description about the tarif. </summary>
TariffDescription TariffDescription { get; }
RentalDescription TariffDescription { get; }
/// <summary>
/// Holds the rent state of the bike.

View file

@ -23,7 +23,7 @@ namespace TINK.Model.Bike.BluetoothLock
Guid lockGuid,
string currentStationId,
Uri operatorUri = null,
TariffDescription tariffDescription = null,
RentalDescription tariffDescription = null,
bool? isDemo = DEFAULTVALUEISDEMO,
IEnumerable<string> group = null,
WheelType? wheelType = null,
@ -69,7 +69,7 @@ namespace TINK.Model.Bike.BluetoothLock
string mailAddress,
string currentStationId,
Uri operatorUri,
TariffDescription tariffDescription,
RentalDescription tariffDescription,
Func<DateTime> dateTimeProvider,
bool? isDemo = DEFAULTVALUEISDEMO,
IEnumerable<string> group = null,
@ -118,7 +118,7 @@ namespace TINK.Model.Bike.BluetoothLock
string mailAddress,
string currentStationId,
Uri operatorUri,
TariffDescription tariffDescription = null,
RentalDescription tariffDescription = null,
bool? isDemo = DEFAULTVALUEISDEMO,
IEnumerable<string> group = null,
WheelType? wheelType = null,

View file

@ -22,7 +22,7 @@ namespace TINK.Model.Bike.CopriLock
string currentStationId,
LockInfo lockInfo,
Uri operatorUri = null,
TariffDescription tariffDescription = null,
RentalDescription tariffDescription = null,
bool? isDemo = DEFAULTVALUEISDEMO,
IEnumerable<string> group = null,
WheelType? wheelType = null,
@ -62,7 +62,7 @@ namespace TINK.Model.Bike.CopriLock
string currentStationId,
LockInfo lockInfo,
Uri operatorUri,
TariffDescription tariffDescription,
RentalDescription tariffDescription,
Func<DateTime> dateTimeProvider,
bool? isDemo = DEFAULTVALUEISDEMO,
IEnumerable<string> group = null,
@ -105,7 +105,7 @@ namespace TINK.Model.Bike.CopriLock
string currentStationId,
LockInfo lockInfo,
Uri operatorUri,
TariffDescription tariffDescription = null,
RentalDescription tariffDescription = null,
bool? isDemo = DEFAULTVALUEISDEMO,
IEnumerable<string> group = null,
WheelType? wheelType = null,

View file

@ -0,0 +1,47 @@
using System.Collections.Generic;
namespace TINK.Model.Bikes.Bike
{
/// <summary>
/// Successor of TarifDescription- object.
/// Manages tariff- and rental info.
/// </summary>
public class RentalDescription
{
/// <summary>
/// The different elements of a tariff (example: "Max Gebühr", )
/// </summary>
public class TariffElement
{
/// <summary>
/// Describes the tariff element. To be displayed to user (example of elements: "Gratis Mietzeit", "Mietgebühr", "Max Gebühr").
/// </summary>
public string Description { get; set; } = string.Empty;
/// <summary>
/// Holds the tariff element value. To be displayed to user (example: "9.00 € / Tag").
/// </summary>
public string Value { get; set; } = string.Empty;
}
public class InfoElement
{
public string Key { get; set; }
public string Value { get; set; }
}
/// <summary>
/// Name of the tariff.
/// </summary>
public string Name { get; set; } = string.Empty;
/// <summary>
/// Number of the tariff.
/// </summary>
public int? Id { get; set; }
public Dictionary<string, TariffElement> TariffEntries { get; set; } = new Dictionary<string, TariffElement>();
public Dictionary<string, InfoElement> InfoEntries { get; set; } = new Dictionary<string, InfoElement>();
}
}

View file

@ -18,6 +18,7 @@ using Xamarin.Forms;
using System.Linq;
using TINK.Model.MiniSurvey;
using TINK.Services.CopriApi;
using TINK.MultilingualResources;
namespace TINK.Model.Connector
{
@ -347,7 +348,7 @@ namespace TINK.Model.Connector
new Bikes.Bike.CopriLock.LockInfo.Builder { State = bikeInfo.GetCopriLockingState()}.Build(),
bikeInfo.GetOperatorUri(),
#if !NOTARIFFDESCRIPTION
Create(bikeInfo.tariff_description),
bikeInfo.rental_description != null ? Create(bikeInfo.rental_description) : Create(bikeInfo.tariff_description),
#else
Create((TINK.Repository.Response.TariffDescription) null),
#endif
@ -365,7 +366,7 @@ namespace TINK.Model.Connector
bikeInfo.station,
bikeInfo.GetOperatorUri(),
#if !NOTARIFFDESCRIPTION
Create(bikeInfo.tariff_description),
bikeInfo.rental_description != null ? Create(bikeInfo.rental_description) : Create(bikeInfo.tariff_description),
#else
Create((TINK.Repository.Response.TariffDescription)null),
#endif
@ -438,9 +439,9 @@ namespace TINK.Model.Connector
bikeInfo.station,
bikeInfo.GetOperatorUri(),
#if !NOTARIFFDESCRIPTION
Create(bikeInfo.tariff_description),
bikeInfo.rental_description != null ? Create(bikeInfo.rental_description) : Create(bikeInfo.tariff_description),
#else
Create((TINK.Repository.Response.TariffDescription)null),
Create((TINK.Repository.Response.TariffDescription)null),
#endif
dateTimeProvider,
bikeInfo.GetIsDemo(),
@ -458,7 +459,7 @@ namespace TINK.Model.Connector
new Bikes.Bike.CopriLock.LockInfo.Builder { State = bikeInfo.GetCopriLockingState() }.Build(),
bikeInfo.GetOperatorUri(),
#if !NOTARIFFDESCRIPTION
Create(bikeInfo.tariff_description),
bikeInfo.rental_description != null ? Create(bikeInfo.rental_description) : Create(bikeInfo.tariff_description),
#else
Create((TINK.Repository.Response.TariffDescription)null),
#endif
@ -497,11 +498,11 @@ namespace TINK.Model.Connector
bikeInfo.station,
bikeInfo.GetOperatorUri(),
#if !NOTARIFFDESCRIPTION
Create(bikeInfo.tariff_description),
bikeInfo.rental_description != null ? Create(bikeInfo.rental_description) : Create(bikeInfo.tariff_description),
#else
Create((TINK.Repository.Response.TariffDescription)null),
Create((TINK.Repository.Response.TariffDescription)null),
#endif
bikeInfo.GetIsDemo(),
bikeInfo.GetIsDemo(),
bikeInfo.GetGroup(),
bikeInfo.GetWheelType(),
bikeInfo.GetTypeOfBike(),
@ -519,11 +520,11 @@ namespace TINK.Model.Connector
bikeInfo.station,
bikeInfo.GetOperatorUri(),
#if !NOTARIFFDESCRIPTION
Create(bikeInfo.tariff_description),
bikeInfo.rental_description != null ? Create(bikeInfo.rental_description) : Create(bikeInfo.tariff_description),
#else
Create((TINK.Repository.Response.TariffDescription)null),
Create((TINK.Repository.Response.TariffDescription)null),
#endif
bikeInfo.GetFrom(),
bikeInfo.GetFrom(),
mailAddress,
bikeInfo.timeCode);
default:
@ -535,9 +536,9 @@ namespace TINK.Model.Connector
new Bikes.Bike.CopriLock.LockInfo.Builder { State = bikeInfo.GetCopriLockingState() }.Build(),
bikeInfo.GetOperatorUri(),
#if !NOTARIFFDESCRIPTION
Create(bikeInfo.tariff_description),
bikeInfo.rental_description != null ? Create(bikeInfo.rental_description) : Create(bikeInfo.tariff_description),
#else
Create((TINK.Repository.Response.TariffDescription)null),
Create((TINK.Repository.Response.TariffDescription)null),
#endif
bikeInfo.GetIsDemo(),
bikeInfo.GetGroup(),
@ -559,28 +560,130 @@ namespace TINK.Model.Connector
}
}
public static Bikes.Bike.TariffDescription Create(this TariffDescription tariffDesciption)
/// <summary>
/// Creates rental description object from JSON- tarif description object.
/// </summary>
/// <param name="tariffDesciption">Source JSON object.</param>
/// <returns>Tariff description object.</returns>
public static Bikes.Bike.RentalDescription Create(this TariffDescription tariffDesciption)
{
return new Bikes.Bike.TariffDescription
var bike = new Bikes.Bike.RentalDescription
{
Name = tariffDesciption?.name,
#if USCSHARP9
Number = int.TryParse(tariffDesciption?.number, out int number) ? number : null,
#else
Number = int.TryParse(tariffDesciption?.number, out int number) ? number : (int?)null,
Id = int.TryParse(tariffDesciption?.number, out int number) ? number : (int?)null,
#endif
FreeTimePerSession = double.TryParse(tariffDesciption?.free_hours, NumberStyles.Any, CultureInfo.InvariantCulture, out double freeHours) ? TimeSpan.FromHours(freeHours) : TimeSpan.Zero,
FeeEuroPerHour = double.TryParse(tariffDesciption?.eur_per_hour, NumberStyles.Any, CultureInfo.InvariantCulture, out double euroPerHour) ? euroPerHour : double.NaN,
AboEuroPerMonth = double.TryParse(tariffDesciption?.abo_eur_per_month, NumberStyles.Any, CultureInfo.InvariantCulture, out double aboEuroPerMonth) ? aboEuroPerMonth : double.NaN,
MaxFeeEuroPerDay = double.TryParse(tariffDesciption?.max_eur_per_day, NumberStyles.Any, CultureInfo.InvariantCulture, out double maxEuroPerDay) ? maxEuroPerDay : double.NaN,
OperatorAgb = tariffDesciption?.operator_agb,
TrackingInfo = tariffDesciption?.track_info
};
if (!string.IsNullOrEmpty(tariffDesciption?.free_hours)
&& double.TryParse(tariffDesciption?.free_hours, NumberStyles.Any, CultureInfo.InvariantCulture, out double freeHours))
{
// Free time. Unit hours,format floating point number.
bike.TariffEntries.Add("1", new Bikes.Bike.RentalDescription.TariffElement {
Description = AppResources.MessageBikesManagementTariffDescriptionFreeTimePerSession,
Value =string.Format("{0} {1}", freeHours.ToString("0.00"), AppResources.MessageBikesManagementTariffDescriptionHour)
});
}
if (!string.IsNullOrEmpty(tariffDesciption?.eur_per_hour)
&& double.TryParse(tariffDesciption?.eur_per_hour, NumberStyles.Any, CultureInfo.InvariantCulture, out double euroPerHour))
{
// Euro per hour. Format floating point.
bike.TariffEntries.Add("2", new Bikes.Bike.RentalDescription.TariffElement {
Description = AppResources.MessageBikesManagementTariffDescriptionFeeEuroPerHour,
Value = string.Format("{0} {1}", euroPerHour.ToString("0.00"), AppResources.MessageBikesManagementTariffDescriptionEuroPerHour)
});
}
if (!string.IsNullOrEmpty(tariffDesciption?.max_eur_per_day)
&& double.TryParse(tariffDesciption.max_eur_per_day, NumberStyles.Any, CultureInfo.InvariantCulture, out double maxEuroPerDay))
{
// Max euro per day. Format floating point.
bike.TariffEntries.Add("3", new Bikes.Bike.RentalDescription.TariffElement {
Description = AppResources.MessageBikesManagementTariffDescriptionMaxFeeEuroPerDay,
Value = string.Format("{0} {1}", maxEuroPerDay.ToString("0.00"), AppResources.MessageBikesManagementMaxFeeEuroPerDay)
});
}
if (!string.IsNullOrEmpty(tariffDesciption?.abo_eur_per_month)
&& double.TryParse(tariffDesciption.abo_eur_per_month, NumberStyles.Any, CultureInfo.InvariantCulture, out double aboEuroPerMonth))
{
// Abo per month
bike.TariffEntries.Add("4", new Bikes.Bike.RentalDescription.TariffElement {
Description = AppResources.MessageBikesManagementTariffDescriptionAboEuroPerMonth,
Value = string.Format("{0} {1}", aboEuroPerMonth.ToString("0.00"), AppResources.MessageBikesManagementTariffDescriptionEuroPerMonth)
});
}
if (!string.IsNullOrEmpty(tariffDesciption?.operator_agb ?? string.Empty))
{
bike.InfoEntries.Add("1", new Bikes.Bike.RentalDescription.InfoElement { Key = "AGB", Value = tariffDesciption.operator_agb });
}
return bike;
}
/// <summary>
/// Creates rental description object from JSON- tarif description object.
/// </summary>
/// <param name="rentalDesciption">Source JSON object.</param>
/// <returns>Tariff description object.</returns>
public static Bikes.Bike.RentalDescription Create(this RentalDescription rentalDesciption)
{
Bikes.Bike.RentalDescription.TariffElement CreateTarifEntry(string[] elementValue)
{
return new Bikes.Bike.RentalDescription.TariffElement
{
Description = elementValue != null && elementValue.Length > 0 ? elementValue[0] : string.Empty,
Value = elementValue != null && elementValue.Length > 1 ? elementValue[1] : string.Empty,
};
}
Bikes.Bike.RentalDescription.InfoElement CreateInfoElement(string[] elementValue)
{
return new Bikes.Bike.RentalDescription.InfoElement
{
Key = elementValue != null && elementValue.Length > 0 ? elementValue[0] : string.Empty,
Value = elementValue != null && elementValue.Length > 1 ? elementValue[1] : string.Empty,
};
}
// Read tariff elements.
var tarifEntries = rentalDesciption?.tarif_elements != null
? rentalDesciption.tarif_elements.Select(x => new
{
Key = x.Key,
Value = CreateTarifEntry(x.Value)
}).ToLookup(x => x.Key, x => x.Value).ToDictionary(x => x.Key, x => x.First())
: new Dictionary<string, Bikes.Bike.RentalDescription.TariffElement>();
// Read info elements.
var InfoEntries = rentalDesciption?.rental_info != null
? rentalDesciption.rental_info.Select(x => new
{
Key = x.Key,
Value = CreateInfoElement(x.Value)
}).ToLookup(x => x.Key, x => x.Value).ToDictionary(x => x.Key, x => x.First())
: new Dictionary<string, Bikes.Bike.RentalDescription.InfoElement>();
var bike = new Bikes.Bike.RentalDescription
{
Name = rentalDesciption?.name ?? string.Empty,
Id = int.TryParse(rentalDesciption?.id ?? string.Empty, out int number) ? number : (int?)null,
TariffEntries = tarifEntries,
InfoEntries = InfoEntries
};
return bike;
}
/// <summary> Creates a booking finished object from response.</summary>
/// <param name="response">Response to create survey object from.</param>
public static BookingFinishedModel Create(this DoReturnResponse response)
public static BookingFinishedModel Create(this DoReturnResponse response)
{
var bookingFinished = new BookingFinishedModel
{

View file

@ -526,7 +526,19 @@ namespace TINK.Model
{
new Version(3, 0, 299),
AppResources.ChangeLog3_0_299
}
},
{
new Version(3, 0, 300),
AppResources.ChangeLog3_0_231 // Minor improvements.
},
{
new Version(3, 0, 311),
AppResources.ChangeLog3_0_301
},
{
new Version(3, 0, 312),
AppResources.ChangeLog3_0_312
},
};
/// <summary> Manges the whats new information.</summary>