Version 3.0.363

This commit is contained in:
Anja 2023-04-19 12:14:14 +02:00
parent 4ff3307997
commit 91d42552c7
212 changed files with 1799 additions and 1318 deletions

View file

@ -13,6 +13,7 @@ using TINK.Model.Logging;
using TINK.Repository.Exception;
using TINK.Repository.Request;
using TINK.Repository.Response;
using TINK.Repository.Response.Stations;
namespace TINK.Repository
{
@ -24,7 +25,7 @@ namespace TINK.Repository
/// <summary> Initializes a instance of the copri calls https object. </summary>
/// <param name="copriHost">Host to connect to. </param>
/// <param name="appContextInfo">Provides app related info (app name and version, merchantid) to pass to COPRI.</param>
/// <param name="appContextInfo">Provides app related info (app name and version, merchant id) to pass to COPRI.</param>
/// <param name="uiIsoLangugageName">Two letter ISO language name.</param>
/// <param name="smartDevice">Holds info about smart device.</param>
/// <param name="sessionCookie">Session cookie if user is logged in, null otherwise.</param>
@ -50,7 +51,7 @@ namespace TINK.Repository
/// <summary> Holds the URL for rest calls.</summary>
private Uri m_oCopriHost;
/// <summary> Spacifies name and version of app. </summary>
/// <summary> Specifies name and version of app. </summary>
private string UserAgent { get; }
/// <summary> Returns true because value requested form copri server are returned. </summary>
@ -63,7 +64,7 @@ namespace TINK.Repository
public string SessionCookie => requestBuilder.SessionCookie;
/// <summary> Logs user in. </summary>
/// <param name="mailAddress">Mailaddress of user to log in.</param>
/// <param name="mailAddress">Mail address of user to log in.</param>
/// <param name="password">Password to log in.</param>
/// <param name="deviceId">Id specifying user and hardware.</param>
/// <remarks>Response which holds auth cookie <see cref="ResponseBase.authcookie"/></remarks>
@ -87,7 +88,7 @@ namespace TINK.Repository
public async Task<BikesAvailableResponse> GetBikesAvailableAsync()
=> await GetBikesAvailableAsync(m_oCopriHost.AbsoluteUri, requestBuilder.GetBikesAvailable(), UserAgent);
/// <summary> Gets a list of bikes reserved/ booked by acctive user. </summary>
/// <summary> Gets a list of bikes reserved/ booked by active user. </summary>
/// <returns>Response holding list of bikes.</returns>
public async Task<BikesReservedOccupiedResponse> GetBikesOccupiedAsync()
{
@ -127,7 +128,7 @@ namespace TINK.Repository
requestBuilder.DoReserve(bikeId),
UserAgent);
/// <summary> Gets canel booking request response.</summary>
/// <summary> Gets cancel booking request response.</summary>
/// <param name="bikeId">Id of the bike to book.</param>
/// <param name="operatorUri">Holds the uri of the operator or null, in case of single operator setup.</param>
/// <returns>Response on cancel booking request.</returns>
@ -183,13 +184,13 @@ namespace TINK.Repository
requestBuilder.UpateLockingState(bikeId, state, location, batteryLevel, versionInfo),
UserAgent);
/// <summary> Gets booking request request. </summary>
/// <summary> Gets booking request. </summary>
/// <param name="operatorUri">Holds the uri of the operator or null, in case of single operator setup.</param>
/// <param name="bikeId">Id of the bike to book.</param>
/// <param name="guid">Used to publish GUID from app to copri. Used for initial setup of bike in copri.</param>
/// <param name="batteryPercentage">Holds the filling level percentage of the battery.</param>
/// <param name="nextAction">If not null next locking action which is performed after booking.</param>
/// <returns>Requst on booking request.</returns>
/// <returns>Request on booking request.</returns>
public async Task<ReservationBookingResponse> DoBookAsync(
Uri operatorUri,
string bikeId,
@ -296,7 +297,7 @@ namespace TINK.Repository
copriHost,
command,
userAgent,
displayCommand); // Do not include password into exception output when an error occurres.
displayCommand); // Do not include password into exception output when an error occurs.
}
catch (System.Exception l_oException)
{
@ -437,7 +438,7 @@ namespace TINK.Repository
#endif
}
/// <summary> Gets a list of bikes reserved/ booked by acctive user from Copri.</summary>
/// <summary> Gets a list of bikes reserved/ booked by active user from Copri.</summary>
/// <param name="copriHost">URL of the copri host to connect to.</param>
/// <param name="command">Command to post.</param>
/// <returns>Response holding list of bikes.</returns>
@ -785,8 +786,8 @@ namespace TINK.Repository
#endif
}
/// <summary> http get- request.</summary>
/// <param name="Url">Ulr to get info from.</param>
/// <summary> Https get- request.</summary>
/// <param name="Url">Url to get info from.</param>
/// <returns>response from server</returns>
public static async Task<string> Get(string Url)
{
@ -804,7 +805,7 @@ namespace TINK.Repository
return result;
}
/// <summary> http- post request.</summary>
/// <summary> Https- post request.</summary>
/// <param name="command">Command to send.</param>
/// <param name="displayCommand">Command to display/ log used for error handling.</param>
/// <param name="uRL">Address of server to communicate with.</param>
@ -838,7 +839,7 @@ namespace TINK.Repository
#if !WINDOWS_UWP
var l_strHost = uRL;
// Returns a http request.
// Returns a https request.
var request = WebRequest.CreateHttp(l_strHost);
request.Method = "POST";

View file

@ -5,12 +5,13 @@ using TINK.Model.Bikes.BikeInfoNS.BluetoothLock;
using TINK.Model.Connector;
using TINK.Repository.Request;
using TINK.Repository.Response;
using TINK.Repository.Response.Stations;
namespace TINK.Repository
{
public class CopriCallsMemory : ICopriServer
public class CopriCallsMemory : ICopriServer
{
/// <summary> Part in file specifying apiserver.</summary>
/// <summary> Part in file specifying api server.</summary>
private static string CopriDevelHostUri = @"https://tinkwwp.copri-bike.de/APIjsonserver";
public const string DO_AUTH_Unknown_User_FILE = @"
@ -1335,7 +1336,7 @@ namespace TINK.Repository
}
/// <summary>
/// Gets a list of bikes reserved/ booked by acctive user from Copri.
/// Gets a list of bikes reserved/ booked by active user from Copri.
/// </summary>
/// <param name="p_strSessionCookie">Cookie to authenticate user.</param>
/// <returns>Response holding list of bikes.</returns>
@ -1343,7 +1344,7 @@ namespace TINK.Repository
{
try
{
requestBuilder.GetBikesOccupied(); // Non mock implementation if ICopriServer call this member as well. To ensure comparable behaviour this member is called here as well.
requestBuilder.GetBikesOccupied(); // Non mock implementation if ICopriServer call this member as well. To ensure comparable behavior this member is called here as well.
}
catch (NotSupportedException)
{
@ -1673,7 +1674,7 @@ namespace TINK.Repository
=> null;
/// <summary>
/// Gets a list of bikes reserved/ booked by acctive user from Copri.
/// Gets a list of bikes reserved/ booked by active user from Copri.
/// </summary>
/// <param name="sessionCookie">Cookie to authenticate user.</param>
/// <param name="SampleSet">Sample set to use.</param>

View file

@ -8,6 +8,7 @@ using TINK.Model.Device;
using TINK.Model.Services.CopriApi;
using TINK.Repository.Request;
using TINK.Repository.Response;
using TINK.Repository.Response.Stations;
namespace TINK.Repository
{

View file

@ -3,9 +3,9 @@ using System.Collections.Generic;
using System.Threading.Tasks;
using TINK.Model.Bikes.BikeInfoNS.BluetoothLock;
using TINK.Model.Connector;
using TINK.Model.Device;
using TINK.Repository.Request;
using TINK.Repository.Response;
using TINK.Repository.Response.Stations;
namespace TINK.Repository
{
@ -13,7 +13,7 @@ namespace TINK.Repository
public interface ICopriServerBase
{
/// <summary> Logs user in. </summary>
/// <param name="mailAddress">Mailaddress of user to log in.</param>
/// <param name="mailAddress">Mail address of user to log in.</param>
/// <param name="password">Password to log in.</param>
/// <param name="deviceId">Id specifying user and hardware.</param>
/// <remarks>Response which holds auth cookie <see cref="ResponseBase.authcookie"/></remarks>
@ -34,7 +34,7 @@ namespace TINK.Repository
string bikeId,
Uri operatorUri);
/// <summary> Cancels reservation of bik. </summary>
/// <summary> Cancels reservation of bike. </summary>
/// <param name="bikeId">Id of the bike to reserve.</param>
/// <param name="operatorUri">Holds the uri of the operator or null, in case of single operator setup.</param>
/// <returns>Response on cancel reservation request.</returns>
@ -162,7 +162,7 @@ namespace TINK.Repository
/// <returns>Response holding list of bikes.</returns>
Task<BikesAvailableResponse> GetBikesAvailableAsync();
/// <summary> Gets a list of bikes reserved/ booked by acctive user from Copri.</summary>
/// <summary> Gets a list of bikes reserved/ booked by active user from Copri.</summary>
/// <returns>Response holding list of bikes.</returns>
Task<BikesReservedOccupiedResponse> GetBikesOccupiedAsync();
}

View file

@ -15,10 +15,10 @@ namespace TINK.Repository.Request
string SessionCookie { get; }
/// <summary> Gets request to log user in. </summary>
/// <param name="mailAddress">Mailaddress of user to log in.</param>
/// <param name="mailAddress">Mail address of user to log in.</param>
/// <param name="password">Password to log in.</param>
/// <param name="deviceId">Id specifying user and hardware.</param>
/// <remarks>Requst which holds auth cookie <see cref="RequstBase.authcookie"/></remarks>
/// <remarks>Request which holds auth cookie <see cref="RequstBase.authcookie"/></remarks>
string DoAuthorization(
string mailAddress,
string password,
@ -37,7 +37,7 @@ namespace TINK.Repository.Request
/// <returns>Request to query list of bikes available.</returns>
string GetBikesAvailable();
/// <summary> Gets a list of bikes reserved/ booked by acctive user from Copri.</summary>
/// <summary> Gets a list of bikes reserved/ booked by active user from Copri.</summary>
/// <returns>Request to query list of bikes occupied.</returns>
string GetBikesOccupied();

View file

@ -81,7 +81,7 @@ namespace TINK.Repository.Request
SmartDevice.GetSmartDeviceParameters() +
UiIsoLanguageNameParameter;
/// <summary> Gets a list of bikes reserved/ booked by acctive user from Copri.</summary>
/// <summary> Gets a list of bikes reserved/ booked by active user from Copri.</summary>
/// <returns>Request to query list of bikes occupied.</returns>
public string GetBikesOccupied()
=> throw new NotSupportedException();

View file

@ -78,7 +78,7 @@ namespace TINK.Repository.Request
AuthCookieParameter +
UiIsoLanguageNameParameter;
/// <summary> Gets a list of bikes reserved/ booked by acctive user from Copri.</summary>
/// <summary> Gets a list of bikes reserved/ booked by active user from Copri.</summary>
/// <returns>Request to query list of bikes occupied.</returns>
public string GetBikesOccupied()
=> "request=user_bikes_occupied&system=all&genkey=1" +

View file

@ -1,4 +1,4 @@
using System.Runtime.Serialization;
using System.Runtime.Serialization;
namespace TINK.Repository.Response
{
@ -27,7 +27,7 @@ namespace TINK.Repository.Response
public string station { get; private set; }
/// <summary>
/// Holds the localized (german) description of the bike.
/// Holds the localized (German) description of the bike.
/// </summary>
[DataMember]
public string description { get; private set; }
@ -78,6 +78,12 @@ namespace TINK.Repository.Response
/// <summary> Describes type of the bike.</summary>
public BikeType bike_type { get; private set; }
/// <summary>
/// Holds whether bike is a AA bike (bike must be always returned a the same station) or AB bike (start and end stations can be different stations).
/// </summary>
[DataMember]
public string aa_ride { get; private set; }
/// <summary> Loading state of motor battery in % ]0..100[. </summary>
[DataMember]
public string bike_charge { get; private set; }

View file

@ -1,4 +1,4 @@
using System.Runtime.Serialization;
using System.Runtime.Serialization;
namespace TINK.Repository.Response
{
@ -40,7 +40,7 @@ namespace TINK.Repository.Response
public string charge_current_percent { get; private set; }
/// <summary>
/// Holds the maximum chargeing level of the battery in bars.
/// Holds the maximum charging level of the battery in bars.
/// </summary>
[DataMember]
public string charge_max_bars { get; private set; }

View file

@ -1,4 +1,4 @@
using System.Linq;
using System.Linq;
using TINK.MultilingualResources;
using TINK.Repository.Exception;
@ -80,7 +80,7 @@ namespace TINK.Repository.Response
/// <summary>Gets if a call to reserve bike succeeded or not by checking a booking response.</summary>
/// <param name="bikeId">Id of bike which should be booked.</param>
/// <param name="sessionCookie">Sessiong cookie of logged in user.</param>
/// <param name="sessionCookie">Session cookie of logged in user.</param>
/// <param name="bookingResponse">Response to check.</param>
/// <returns></returns>
public static BikeInfoReservedOrBooked GetIsReserveResponseOk(

View file

@ -0,0 +1,27 @@
using System.Runtime.Serialization;
namespace TINK.Repository.Response.Stations.Station
{
/// <summary>
/// Holds info about operator data.
/// </summary>
[DataContract]
public class OperatorData
{
[DataMember]
public string operator_name { get; private set; }
[DataMember]
public string operator_phone { get; private set; }
[DataMember]
public string operator_hours { get; private set; }
[DataMember]
public string operator_email { get; private set; }
[DataMember]
public string operator_color { get; private set; }
}
}

View file

@ -0,0 +1,32 @@
using System.Runtime.Serialization;
namespace TINK.Repository.Response.Stations.Station
{
/// <summary>
/// Holds info about a single station.
/// </summary>
[DataContract]
public class StationInfo
{
/// <summary>
/// Unique id of the station.
/// </summary>
[DataMember]
public string station { get; private set; }
[DataMember]
public string[] station_group { get; private set; }
[DataMember]
public string description { get; private set; }
/// <summary>
/// Position of the station.
/// </summary>
[DataMember]
public Position gps { get; private set; }
[DataMember]
public OperatorData operator_data { get; private set; }
}
}

View file

@ -0,0 +1,19 @@
using System.Collections.Generic;
using System.Runtime.Serialization;
using TINK.Repository.Response.Stations.Station;
namespace TINK.Repository.Response.Stations
{
/// <summary>
/// Holds the information about all stations and is used for deserialization of copri answer.
/// </summary>
[DataContract]
public class StationsAvailableResponse : ResponseBase
{
/// <summary>
/// Dictionary of bikes.
/// </summary>
[DataMember]
public Dictionary<string, StationInfo> stations { get; private set; }
}
}

View file

@ -1,69 +0,0 @@
using System.Collections.Generic;
using System.Runtime.Serialization;
namespace TINK.Repository.Response
{
/// <summary>
/// Holds the information about all stations and is used for deserialization of copri answer.
/// </summary>
[DataContract]
public class StationsAvailableResponse : ResponseBase
{
/// <summary>
/// Holds info about a single station.
/// </summary>
[DataContract]
public class StationInfo
{
/// <summary>
/// Holds info about opertor data.
/// </summary>
[DataContract]
public class OperatorData
{
[DataMember]
public string operator_name { get; private set; }
[DataMember]
public string operator_phone { get; private set; }
[DataMember]
public string operator_hours { get; private set; }
[DataMember]
public string operator_email { get; private set; }
[DataMember]
public string operator_color { get; private set; }
}
/// <summary>
/// Unique id of the station.
/// </summary>
[DataMember]
public string station { get; private set; }
[DataMember]
public string[] station_group { get; private set; }
[DataMember]
public string description { get; private set; }
/// <summary>
/// Position of the station.
/// </summary>
[DataMember]
public Position gps { get; private set; }
[DataMember]
public OperatorData operator_data { get; private set; }
}
/// <summary>
/// Dictionary of bikes.
/// </summary>
[DataMember]
public Dictionary<string, StationInfo> stations { get; private set; }
}
}