This commit is contained in:
Oliver Hauff 2022-01-22 18:16:10 +01:00
parent e0c75d5b37
commit f38b516d25
57 changed files with 12835 additions and 9925 deletions

View file

@ -74,7 +74,7 @@ namespace TINK.Model.Connector
Log.ForContext<CachedQuery>().Error("Unexpected call to get be bikes occpied detected. No user is logged in.");
return new Result<BikeCollection>(
typeof(CopriCallsMonkeyStore),
await Task.Run(() => new BikeCollection(new Dictionary<string, BikeInfo>())),
await Task.FromResult(new BikeCollection(new Dictionary<string, BikeInfo>())),
new GeneralData(),
new Exception("Abfrage der reservierten/ gebuchten Räder nicht möglich. Kein Benutzer angemeldet."));
}

View file

@ -46,7 +46,7 @@ namespace TINK.Model.Connector
Log.ForContext<Query>().Error("Unexpected call to get be bikes occpied detected. No user is logged in.");
return new Result<BikeCollection>(
typeof(CopriCallsMonkeyStore),
await Task.Run(() => new BikeCollection(new Dictionary<string, BikeInfo>())),
await Task.FromResult(new BikeCollection(new Dictionary<string, BikeInfo>())),
new GeneralData(),
new Exception("Abfrage der reservierten/ gebuchten Räder fehlgeschlagen. Kein Benutzer angemeldet."));
}

View file

@ -28,11 +28,9 @@ namespace TINK.Model.Connector
/// </summary>
/// <param name="stationInfo">Object to get information from.</param>
/// <returns>Position information.</returns>
public static Station.Position GetPosition(this StationsAvailableResponse.StationInfo stationInfo)
{
return GetPosition(stationInfo.gps);
}
public static IPosition GetPosition(this StationsAvailableResponse.StationInfo stationInfo)
=> GetPosition(stationInfo.gps);
/// <summary> Gets the position from StationInfo object. </summary>
/// <param name="authorizationResponse">Object to get information from.</param>
/// <returns>Position information.</returns>
@ -160,9 +158,9 @@ namespace TINK.Model.Connector
{
return bikeInfo?.bike_group?.GetGroup()?.ToList() ?? new List<string>();
}
catch (System.Exception l_oException)
catch (Exception l_oException)
{
throw new System.Exception($"Can not get group of user from text \"{bikeInfo.bike_group}\".", l_oException);
throw new Exception($"Can not get group of user from text \"{bikeInfo.bike_group}\".", l_oException);
}
}
@ -304,33 +302,27 @@ namespace TINK.Model.Connector
return null;
}
/// <summary>
/// Get position from a ,- separated string.
/// </summary>
/// <param name="p_strGps">Text to extract positon from.</param>
/// <summary> Get position from a ,- separated string. </summary>
/// <param name="gps">Text to extract positon from.</param>
/// <returns>Position object.</returns>
public static Station.Position GetPosition(GpsInfo gps)
{
if (gps == null)
{
return null;
}
public static IPosition GetPosition(Repository.Response.Position gps)
=> PositionFactory.Create(
double.TryParse(gps?.latitude, NumberStyles.Float, CultureInfo.InvariantCulture, out double latitude) ? latitude : double.NaN,
double.TryParse(gps?.longitude, NumberStyles.Float, CultureInfo.InvariantCulture, out double longitude) ? longitude : double.NaN);
double l_oLatitude;
if (!double.TryParse(gps.latitude, NumberStyles.Float, CultureInfo.InvariantCulture, out l_oLatitude))
return null;
/// <summary> Get position from a ,- separated string. </summary>
/// <param name="gps">Text to extract positon from.</param>
/// <returns>Position object.</returns>
public static Map.IMapSpan GetMapSpan(this MapSpan mapSpan)
=> Map.MapSpanFactory.Create(
GetPosition(mapSpan?.center),
double.TryParse(mapSpan?.radius, NumberStyles.Float, CultureInfo.InvariantCulture, out double radius) ? radius: double.NaN);
double l_oLongitude;
if (!double.TryParse(gps.longitude, NumberStyles.Float, CultureInfo.InvariantCulture, out l_oLongitude))
return null;
return new Station.Position(l_oLatitude, l_oLongitude);
}
/// <summary> Gets text of bike from. </summary>
/// <param name="p_eType">Type to get text for.</param>
/// <returns></returns>
public static string GetCopriText(this TypeOfBike p_eType)
/// <summary> Gets text of bike from. </summary>
/// <param name="p_eType">Type to get text for.</param>
/// <returns></returns>
public static string GetCopriText(this TypeOfBike p_eType)
{
switch (p_eType)
{

View file

@ -85,9 +85,12 @@ namespace TINK.Model.Connector
/// <param name="response">Response to get data from.</param>
/// <returns>General data object initialized form COPRI response.</returns>
public static GeneralData GetGeneralData(this ResponseBase response)
=> new GeneralData(response.merchant_message, response.TryGetCopriVersion(out Version copriVersion)
? new Version(0,0)
: copriVersion);
=> new GeneralData(
response.init_map.GetMapSpan(),
response.merchant_message,
response.TryGetCopriVersion(out Version copriVersion)
? new Version(0,0)
: copriVersion);
/// <summary> Gets account object from login response.</summary>
/// <param name="merchantId">Needed to extract cookie from autorization response.</param>