Code updated to 3.0.238

This commit is contained in:
Oliver Hauff 2021-06-26 20:57:55 +02:00
parent 3302d80678
commit 9c6a1fa92b
257 changed files with 7763 additions and 2861 deletions

View file

@ -1,6 +1,6 @@
using System.Runtime.Serialization;
namespace TINK.Model.Repository.Response
namespace TINK.Repository.Response
{
[DataContract]
public class AuthorizationResponse : ResponseBase
@ -10,6 +10,6 @@ namespace TINK.Model.Repository.Response
/// <summary> Holds the group of the bike (TINK, Konrad, ...).</summary>
[DataMember]
public string user_group { get; private set; }
public string[] user_group { get; private set; }
}
}

View file

@ -1,6 +1,6 @@
using System.Runtime.Serialization;
namespace TINK.Model.Repository.Response
namespace TINK.Repository.Response
{
[DataContract]
public class AuthorizationoutResponse : ResponseBase

View file

@ -1,6 +1,6 @@
using System.Runtime.Serialization;
namespace TINK.Model.Repository.Response
namespace TINK.Repository.Response
{
[DataContract]
public class BikeInfoAvailable : BikeInfoBase
@ -9,7 +9,7 @@ namespace TINK.Model.Repository.Response
/// Position of the bike.
/// </summary>
[DataMember]
public string gps { get; private set; }
public GpsInfo gps { get; private set; }
[DataMember]
/// <summary> Full advertisement name.</summary>

View file

@ -1,7 +1,6 @@
using System.Runtime.Serialization;
using TINK.Repository.Response;
namespace TINK.Model.Repository.Response
namespace TINK.Repository.Response
{
/// <summary>
/// Holds info about a single bike.
@ -13,13 +12,13 @@ namespace TINK.Model.Repository.Response
/// Id of the bike.
/// </summary>
[DataMember]
public int bike { get; private set; }
public string bike { get; private set; }
/// <summary>
/// Id of the station.
/// </summary>
[DataMember]
public int? station { get; private set; }
public string station { get; private set; }
/// <summary>
/// Holds the localized (german) description of the bike.
@ -32,7 +31,7 @@ namespace TINK.Model.Repository.Response
/// Copri returns values "TINK", "Konrad".
/// </remarks>
[DataMember]
public string bike_group { get; private set; }
public string[] bike_group { get; private set; }
/// <summary>
/// Rental state.

View file

@ -1,6 +1,6 @@
using System.Runtime.Serialization;
namespace TINK.Model.Repository.Response
namespace TINK.Repository.Response
{
[DataContract]
public class BikeInfoReservedOrBooked : BikeInfoAvailable

View file

@ -1,7 +1,7 @@
using System.Collections.Generic;
using System.Runtime.Serialization;
namespace TINK.Model.Repository.Response
namespace TINK.Repository.Response
{
/// <summary>
/// Holds the information about all bikes and is used for deserialization of copri answer.
@ -13,6 +13,6 @@ namespace TINK.Model.Repository.Response
/// Dictionary of bikes.
/// </summary>
[DataMember]
public Dictionary<int, BikeInfoAvailable> bikes { get; private set; }
public Dictionary<string, BikeInfoAvailable> bikes { get; private set; }
}
}

View file

@ -1,7 +1,7 @@
using System.Collections.Generic;
using System.Runtime.Serialization;
namespace TINK.Model.Repository.Response
namespace TINK.Repository.Response
{
public class BikesReservedOccupiedResponse : ResponseBase
{
@ -9,6 +9,6 @@ namespace TINK.Model.Repository.Response
/// Dictionary of bikes.
/// </summary>
[DataMember]
public Dictionary<int, BikeInfoReservedOrBooked> bikes_occupied { get; private set; }
public Dictionary<string, BikeInfoReservedOrBooked> bikes_occupied { get; private set; }
}
}

View file

@ -0,0 +1,11 @@
using System.Runtime.Serialization;
namespace TINK.Repository.Response
{
[DataContract]
public class CopriVersion
{
[DataMember]
public string copri_version { get; private set; }
}
}

View file

@ -0,0 +1,23 @@
using System.Runtime.Serialization;
namespace TINK.Repository.Response
{
/// <summary>
/// Holds info about a single bike.
/// </summary>
[DataContract]
public class GpsInfo
{
/// <summary>
/// Latitude position of the bike.
/// </summary>
[DataMember]
public string latitude { get; private set; }
/// <summary>
/// Longitude position of the bike.
/// </summary>
[DataMember]
public string longitude { get; private set; }
}
}

View file

@ -2,7 +2,7 @@
namespace TINK.Repository.Response
{
public static class JsonConvert
public static class JsonConvertRethrow
{
/// <summary>
/// Deserializes COPRI responses in a consitent way for entire app.

View file

@ -1,6 +1,6 @@
using System.Runtime.Serialization;
namespace TINK.Model.Repository.Response
namespace TINK.Repository.Response
{
/// <summary>
/// Holds the information about a booking request and is used for deserialization of copri answer.

View file

@ -1,5 +1,5 @@

namespace TINK.Model.Repository.Response
namespace TINK.Repository.Response
{
/// <summary>
/// Holds the information about a cancel booking request and is used for deserialization of copri answer.

View file

@ -1,9 +1,9 @@
using System.Runtime.Serialization;
namespace TINK.Model.Repository.Response
namespace TINK.Repository.Response
{
[DataContract]
public class ResponseBase
public class ResponseBase : CopriVersion
{
[DataMember]
public string response_state { get; private set; }
@ -17,9 +17,6 @@ namespace TINK.Model.Repository.Response
[DataMember]
public string authcookie { get; private set; }
[DataMember]
public string copri_version { get; private set; }
/// <summary> Textual description of response. </summary>
public new string ToString()
{

View file

@ -1,12 +1,12 @@
using System.Runtime.Serialization;
namespace TINK.Model.Repository.Response
namespace TINK.Repository.Response
{
[DataContract]
public class ResponseContainer<T>
{
[DataMember]
public T tinkjson { get; private set; }
public T shareejson { get; private set; }
/// <summary>
/// Serializes object to string.
@ -14,12 +14,12 @@ namespace TINK.Model.Repository.Response
/// <returns></returns>
public override string ToString()
{
if (tinkjson == null)
if (shareejson == null)
{
return "Response container does not hold no entry.";
}
return tinkjson.ToString();
return shareejson.ToString();
}
}
}

View file

@ -1,9 +1,8 @@
using System.Linq;
using TINK.Model.Repository.Exception;
using TINK.MultilingualResources;
using TINK.Repository.Exception;
using TINK.MultilingualResources;
namespace TINK.Model.Repository.Response
namespace TINK.Repository.Response
{
public static class ResponseHelper
{
@ -83,7 +82,7 @@ namespace TINK.Model.Repository.Response
/// <returns></returns>
public static BikeInfoReservedOrBooked GetIsReserveResponseOk(
this ReservationBookingResponse bookingResponse,
int bikeId)
string bikeId)
{
GetIsResponseOk(bookingResponse, string.Format(AppResources.ExceptionTextReservationBikeFailedGeneral, bikeId));
@ -111,7 +110,7 @@ namespace TINK.Model.Repository.Response
/// <returns></returns>
public static BikeInfoReservedOrBooked GetIsBookingResponseOk(
this ReservationBookingResponse bookingResponse,
int bikeId)
string bikeId)
{
GetIsResponseOk(bookingResponse, string.Format(AppResources.ExceptionTextRentingBikeFailedGeneral, bikeId));
@ -134,7 +133,7 @@ namespace TINK.Model.Repository.Response
/// <returns>Verified response.</returns>
public static T GetIsResponseOk<T>(this T response, string textOfAction) where T : ResponseBase
{
if (response == null)
if (response == null || response.response_state == null)
{
throw new InvalidResponseException<T>(textOfAction, null);
}
@ -161,7 +160,7 @@ namespace TINK.Model.Repository.Response
/// <returns>Verified response.</returns>
public static ReservationCancelReturnResponse GetIsCancelReservationResponseOk(
this ReservationCancelReturnResponse cancelBookingResponse,
int bikeId)
string bikeId)
{
GetIsResponseOk<ResponseBase>(cancelBookingResponse, BIKES_CANCELREQUEST_ACTIONTEXT);
@ -184,7 +183,7 @@ namespace TINK.Model.Repository.Response
/// <returns>Verified response.</returns>
public static ReservationCancelReturnResponse GetIsReturnBikeResponseOk(
this ReservationCancelReturnResponse returnBikeResponse,
int bikeId)
string bikeId)
{
// Check if bike is at station.
if (NotAtStationException.IsNotAtStation(returnBikeResponse.response_state.ToUpper(), out NotAtStationException notAtStationException))
@ -219,22 +218,8 @@ namespace TINK.Model.Repository.Response
/// <returns></returns>
public static BikesReservedOccupiedResponse GetBikesOccupiedNone(string p_strSesstionCookie = null)
{
var l_oJson = BIKES_OCCUPIED_REQUEST_NONE_FILE.Replace(@"""authcookie"": """"", @"""authcookie"": """ + (p_strSesstionCookie ?? string.Empty) + @"""");
return CopriCallsStatic.DeserializeBikesOccupiedResponse(l_oJson);
var l_oJson = CopriCallsMonkeyStore.BIKESOCCUPIED.Replace(@"""authcookie"": """"", @"""authcookie"": """ + (p_strSesstionCookie ?? string.Empty) + @"""");
return CopriCallsStatic.DeserializeResponse(@"{ ""shareejson"" : " + l_oJson + "}", (version) => new BikesReservedOccupiedResponse());
}
/// <summary>
/// Holds an empty bikes occupied response.
/// </summary>
private const string BIKES_OCCUPIED_REQUEST_NONE_FILE = @"
{
""tinkjson"": {
""response_state"": ""OK"",
""bikes_occupied"": { },
""authcookie"": """",
""response"": ""user_bikes_occupied"",
""apiserver"": ""https://tinkwwp.copri-bike.de""
}
}";
}
}

View file

@ -1,7 +1,7 @@
using System.Collections.Generic;
using System.Runtime.Serialization;
namespace TINK.Model.Repository.Response
namespace TINK.Repository.Response
{
/// <summary>
/// Holds the information about all stations and is used for deserialization of copri answer.
@ -19,10 +19,10 @@ namespace TINK.Model.Repository.Response
/// Unique id of the station.
/// </summary>
[DataMember]
public int station { get; private set; }
public string station { get; private set; }
[DataMember]
public string station_group { get; private set; }
public string[] station_group { get; private set; }
[DataMember]
public string description { get; private set; }
@ -31,13 +31,13 @@ namespace TINK.Model.Repository.Response
/// Position of the station.
/// </summary>
[DataMember]
public string gps { get; private set; }
public GpsInfo gps { get; private set; }
}
/// <summary>
/// Dictionary of bikes.
/// </summary>
[DataMember]
public Dictionary<int, StationInfo> stations { get; private set; }
public Dictionary<string, StationInfo> stations { get; private set; }
}
}

View file

@ -1,6 +1,4 @@
using TINK.Model.Repository.Response;
namespace TINK.Repository.Response
namespace TINK.Repository.Response
{
public class SubmitFeedbackResponse : ResponseBase
{

View file

@ -6,7 +6,11 @@ namespace TINK.Repository.Response
/// Holds tariff info for a single bike.
/// </summary>
[DataContract]
#if USCSHARP9
public record TariffDescription
#else
public class TariffDescription
#endif
{
/// <summary>
/// Name of the tariff.

View file

@ -0,0 +1,22 @@
using System.Runtime.Serialization;
namespace TINK.Repository.Response
{
[DataContract]
public class VersionindependentResponse
{
private CopriVersion _shareejson;
/// <summary> Root element for versions 4.0 and older. </summary>
[DataMember]
public CopriVersion tinkjson { get; private set; }
/// <summary> Root element from 4.1 and later. </summary>
[DataMember]
public CopriVersion shareejson
{
get => _shareejson ?? tinkjson;
private set { _shareejson = value; }
}
}
}