Version 3.0.360

This commit is contained in:
Anja 2023-02-22 14:03:35 +01:00
parent 5c0b2e70c9
commit faf68061f4
160 changed files with 2114 additions and 1932 deletions

View file

@ -2,7 +2,6 @@ using System;
using System.Collections.Generic;
using TINK.Model.Bikes.BikeInfoNS.BluetoothLock;
using TINK.Model.Connector;
using TINK.Model.Device;
namespace TINK.Repository.Request
{
@ -26,7 +25,7 @@ namespace TINK.Repository.Request
string deviceId);
/// <summary> Logs user out. </summary>
/// <param name="p_strMerchantId">Id of the merchant.</param>
/// <param name="merchantId">Id of the merchant.</param>
/// <param name="p_strSessionCookie"> Cookie which identifies user.</param>
string DoAuthout();
@ -98,13 +97,13 @@ namespace TINK.Repository.Request
/// <param name="bikeId">Id of the bike to return.</param>
/// <param name="location">Geolocation of lock when returning bike.</param>
/// <returns>Requst on returning request.</returns>
string DoReturn(string bikeId, LocationDto location, ISmartDevice smartDevice);
string DoReturn(string bikeId, LocationDto location);
/// <summary> Returns a bike and starts closing. </summary>
/// <param name="bikeId">Id of the bike to return.</param>
/// <param name="smartDevice">Provides info about hard and software.</param>
/// <returns>Response to send to corpi.</returns>
string ReturnAndStartClosing(string bikeId, ISmartDevice smartDevice);
string ReturnAndStartClosing(string bikeId);
/// <summary>
/// Gets request for submiting feedback to copri server.

View file

@ -14,9 +14,11 @@ namespace TINK.Repository.Request
/// <summary> Constructs a object for building requests. </summary>
/// <param name="merchantId">Holds the id denoting the merchant.</param>
/// <param name="uiIsoLangugageName">Two letter ISO language name.</param>
/// <param name="smartDevice">Holds info about smart device.</param>
public RequestBuilder(
string merchantId,
string uiIsoLangugageName)
string uiIsoLangugageName,
ISmartDevice smartDevice = null)
{
MerchantId = !string.IsNullOrEmpty(merchantId)
? merchantId
@ -25,6 +27,8 @@ namespace TINK.Repository.Request
UiIsoLanguageNameParameter = RequestBuilderHelper.GetLanguageParameter(WebUtility.UrlEncode(uiIsoLangugageName));
AuthCookieParameter = $"&authcookie={WebUtility.UrlEncode(MerchantId)}";
SmartDevice = smartDevice;
}
/// <summary>Holds the id denoting the merchant.</summary>
@ -39,6 +43,9 @@ namespace TINK.Repository.Request
/// <summary> Auth cookie parameter. </summary>
private string AuthCookieParameter { get; }
/// <summary>Holds info about smart device.</summary>
private ISmartDevice SmartDevice { get; }
/// <summary> Gets request to log user in. </summary>
/// <param name="mailAddress">Mailaddress of user to log in.</param>
/// <param name="password">Password to log in.</param>
@ -71,6 +78,7 @@ namespace TINK.Repository.Request
public string GetStations()
=> "request=stations_available" +
AuthCookieParameter +
SmartDevice.GetSmartDeviceParameters() +
UiIsoLanguageNameParameter;
/// <summary> Gets a list of bikes reserved/ booked by acctive user from Copri.</summary>
@ -125,14 +133,14 @@ namespace TINK.Repository.Request
public string BookReservedAndStartOpening(string bikeId)
=> throw new NotSupportedException();
public string DoReturn(string bikeId, LocationDto geolocation, ISmartDevice smartDevice)
public string DoReturn(string bikeId, LocationDto geolocation)
=> throw new NotSupportedException();
/// <summary> Returns a bike and starts closing. </summary>
/// <param name="bikeId">Id of the bike to return.</param>
/// <param name="smartDevice">Provides info about hard and software.</param>
/// <returns>Response to send to corpi.</returns>
public string ReturnAndStartClosing(string bikeId, ISmartDevice smartDevice)
public string ReturnAndStartClosing(string bikeId)
=> throw new NotSupportedException();
/// <summary> Gets submit feedback request. </summary>

View file

@ -1,5 +1,7 @@
using System.Net;
using TINK.Model.Connector;
using TINK.Model.Device;
namespace TINK.Repository.Request
{
@ -29,5 +31,16 @@ namespace TINK.Repository.Request
return null;
}
}
/// <summary> Gets the smart device parameters. </summary>
/// <returns>in a format which is urlencode invariant.</returns>
public static string GetSmartDeviceParameters(this ISmartDevice smartDevice)
=> smartDevice != null
? $"{(!string.IsNullOrEmpty(smartDevice.Manufacturer) ? $"&user_device_manufacturer={WebUtility.UrlEncode(smartDevice.Manufacturer)}" : string.Empty)}" +
$"{(!string.IsNullOrEmpty(smartDevice.Model) ? $"&user_device_model={WebUtility.UrlEncode(smartDevice.Model)}" : string.Empty)}" +
$"{(!string.IsNullOrEmpty(smartDevice.Platform.ToString()) ? $"&user_device_platform={WebUtility.UrlEncode(smartDevice.Platform.ToString())}" : string.Empty)}" +
$"{(!string.IsNullOrEmpty(smartDevice.VersionText) ? $"&user_device_version={WebUtility.UrlEncode(smartDevice.VersionText)}" : string.Empty)}" +
$"{(!string.IsNullOrEmpty(smartDevice.Identifier) ? $"&user_device_id={WebUtility.UrlEncode(smartDevice.Identifier)}" : string.Empty)}"
: string.Empty;
}
}

View file

@ -17,10 +17,12 @@ namespace TINK.Repository.Request
/// <summary> Constructs a object for building requests. </summary>
/// <param name="merchantId">Holds the id denoting the merchant.</param>
/// <param name="uiIsoLangugageName">Two letter ISO language name.</param>
/// <param name="smartDevice">Holds info about smart device.</param>
public RequestBuilderLoggedIn(
string merchantId,
string uiIsoLangugageName,
string sessionCookie)
string sessionCookie,
ISmartDevice smartDevice = null)
{
MerchantId = !string.IsNullOrEmpty(merchantId)
? merchantId
@ -33,6 +35,8 @@ namespace TINK.Repository.Request
UiIsoLanguageNameParameter = RequestBuilderHelper.GetLanguageParameter(WebUtility.UrlEncode(uiIsoLangugageName));
AuthCookieParameter = $"&authcookie={WebUtility.UrlEncode(SessionCookie)}{WebUtility.UrlEncode(MerchantId)}";
SmartDevice = smartDevice;
}
/// <summary> Holds the id denoting the merchant. </summary>
@ -47,6 +51,9 @@ namespace TINK.Repository.Request
/// <summary> Auth cookie parameter. </summary>
private string AuthCookieParameter { get; }
/// <summary>Holds info about smart device.</summary>
private ISmartDevice SmartDevice { get; }
/// <summary> Gets request to log user in. </summary>
/// <param name="mailAddress">Mailaddress of user to log in.</param>
/// <param name="password">Password to log in.</param>
@ -83,6 +90,7 @@ namespace TINK.Repository.Request
public string GetStations()
=> "request=stations_available" +
AuthCookieParameter +
SmartDevice.GetSmartDeviceParameters() +
UiIsoLanguageNameParameter;
/// <summary> Gets reservation request (synonym: reservation == request == reservieren). </summary>
@ -93,6 +101,7 @@ namespace TINK.Repository.Request
=> "request=booking_request" +
GetBikeIdParameter(bikeId) +
AuthCookieParameter +
SmartDevice.GetSmartDeviceParameters() +
UiIsoLanguageNameParameter;
/// <summary> Gets request to cancel reservation. </summary>
@ -175,6 +184,7 @@ namespace TINK.Repository.Request
AuthCookieParameter +
"&state=occupied" +
GetLockStateParameter(lock_state.unlocking) +
SmartDevice.GetSmartDeviceParameters() +
UiIsoLanguageNameParameter;
/// <summary> Gets the request to book and start opening the bike (synonym: booking == renting == mieten). </summary>
@ -193,14 +203,14 @@ namespace TINK.Repository.Request
/// <param name="bikeId">Id of bike to return.</param>
/// <param name="geolocation">Geolocation of lock when returning bike.</param>
/// <returns>Requst on returning request.</returns>
public string DoReturn(string bikeId, LocationDto geolocation, ISmartDevice smartDevice)
public string DoReturn(string bikeId, LocationDto geolocation)
=> "request=booking_update" +
GetBikeIdParameter(bikeId) +
AuthCookieParameter +
"&state=available" +
GetLocationParameters(geolocation) +
GetLockStateParameter(lock_state.locked) +
GetSmartDeviceParameters(smartDevice) +
SmartDevice.GetSmartDeviceParameters() +
GetLog() +
UiIsoLanguageNameParameter;
@ -209,13 +219,13 @@ namespace TINK.Repository.Request
/// <param name="bikeId">Id of the bike to return.</param>
/// <param name="smartDevice">Provides info about hard and software.</param>
/// <returns>Response to send to corpi.</returns>
public string ReturnAndStartClosing(string bikeId, ISmartDevice smartDevice)
public string ReturnAndStartClosing(string bikeId)
=> "request=booking_update" +
GetBikeIdParameter(bikeId) +
AuthCookieParameter +
"&state=available" +
GetLockStateParameter(lock_state.locking) +
GetSmartDeviceParameters(smartDevice) +
SmartDevice.GetSmartDeviceParameters() +
UiIsoLanguageNameParameter;
/// <summary> Gets submit feedback request. </summary>
@ -315,17 +325,6 @@ namespace TINK.Repository.Request
return $"&gps={geolocation.Latitude.ToString(CultureInfo.InvariantCulture)},{geolocation.Longitude.ToString(CultureInfo.InvariantCulture)}&gps_accuracy={geolocation.Accuracy.Value.ToString(CultureInfo.InvariantCulture)}&gps_age={geolocation.Age.TotalSeconds}";
}
/// <summary> Gets the geolocation parameter. </summary>
/// <returns>in a format which is urlencode invariant.</returns>
private static string GetSmartDeviceParameters(ISmartDevice smartDevice)
=> smartDevice != null
? $"{(!string.IsNullOrEmpty(smartDevice.Manufacturer) ? $"&user_device_manufaturer={WebUtility.UrlEncode(smartDevice.Manufacturer)})" : string.Empty)}" +
$"{(!string.IsNullOrEmpty(smartDevice.Model) ? $"&user_device_model={WebUtility.UrlEncode(smartDevice.Model)}" : string.Empty)}" +
$"{(!string.IsNullOrEmpty(smartDevice.Platform.ToString()) ? $"&user_device_platform={WebUtility.UrlEncode(smartDevice.Platform.ToString())}" : string.Empty)}" +
$"{(!string.IsNullOrEmpty(smartDevice.VersionText) ? $"&user_device_version={WebUtility.UrlEncode(smartDevice.VersionText)}" : string.Empty)}" +
$"{(!string.IsNullOrEmpty(smartDevice.Identifier) ? $"&user_device_id={WebUtility.UrlEncode(smartDevice.Identifier)}" : string.Empty)}"
: string.Empty;
/// <summary>
/// Gets logging entries from serilog.
/// </summary>