mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2025-04-21 04:26:29 +02:00
Mini survey added.
Minor fiexes.
This commit is contained in:
parent
ddfea49ea6
commit
e321764119
73 changed files with 1628 additions and 185 deletions
|
@ -1,5 +1,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using TINK.Model.Device;
|
||||
using TINK.Repository.Exception;
|
||||
|
@ -76,21 +78,21 @@ namespace TINK.Repository.Request
|
|||
/// <remarks> Operator specific call.</remarks>
|
||||
/// <param name="bikeId">Id of the bike to reserve.</param>
|
||||
/// <returns>Requst to reserve bike.</returns>
|
||||
public string DoReserve(string bikeId)
|
||||
public string DoReserve(string bikeId)
|
||||
=> $"request=booking_request&bike={bikeId}&authcookie={SessionCookie}{MerchantId}";
|
||||
|
||||
/// <summary> Gets request to cancel reservation. </summary>
|
||||
/// <remarks> Operator specific call.</remarks>
|
||||
/// <param name="bikeId">Id of the bike to cancel reservation for.</param>
|
||||
/// <returns>Requst on cancel booking request.</returns>
|
||||
public string DoCancelReservation(string p_iBikeId)
|
||||
public string DoCancelReservation(string p_iBikeId)
|
||||
=> $"request=booking_cancel&bike={p_iBikeId}&authcookie={SessionCookie}{MerchantId}";
|
||||
|
||||
/// <summary> Request to get keys. </summary>
|
||||
/// <remarks> Operator specific call.</remarks>
|
||||
/// <param name="bikeId">Id of the bike to get keys for.</param>
|
||||
/// <returns>Request to get keys.</returns>
|
||||
public string CalculateAuthParameters(string bikeId)
|
||||
public string CalculateAuthParameters(string bikeId)
|
||||
=> $"request=booking_update&bike={bikeId}&authcookie={SessionCookie}{MerchantId}&genkey=1";
|
||||
|
||||
/// <summary> Gets the request for updating lock state for a booked bike. </summary>
|
||||
|
@ -99,7 +101,7 @@ namespace TINK.Repository.Request
|
|||
/// <param name="state">New locking state.</param>
|
||||
/// <returns>Request to update locking state.</returns>
|
||||
public string UpateLockingState(string bikeId, LocationDto geolocation, lock_state state, double batteryPercentage)
|
||||
{
|
||||
{
|
||||
return $"request=booking_update&bike={bikeId}{GetLocationParameters(geolocation)}&lock_state={state}{GetBatteryPercentageParameters(batteryPercentage)}&authcookie={SessionCookie}{MerchantId}";
|
||||
}
|
||||
|
||||
|
@ -109,7 +111,7 @@ namespace TINK.Repository.Request
|
|||
/// <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>
|
||||
/// <returns>Request to booking bike.</returns>
|
||||
public string DoBook(string bikeId, Guid guid, double batteryPercentage)
|
||||
public string DoBook(string bikeId, Guid guid, double batteryPercentage)
|
||||
=> $"request=booking_update&bike={bikeId}&authcookie={SessionCookie}{MerchantId}&Ilockit_GUID={guid}&state=occupied&lock_state=unlocked{GetBatteryPercentageParameters(batteryPercentage)}";
|
||||
|
||||
/// <summary> Gets request for returning the bike. </summary>
|
||||
|
@ -118,7 +120,7 @@ namespace TINK.Repository.Request
|
|||
/// <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)
|
||||
{
|
||||
{
|
||||
return $"request=booking_update" +
|
||||
$"&bike={bikeId}" +
|
||||
$"&authcookie={SessionCookie}{MerchantId}" +
|
||||
|
@ -133,10 +135,10 @@ namespace TINK.Repository.Request
|
|||
/// <param name="message">General purpose message or error description.</param>
|
||||
/// <param name="isBikeBroken">True if bike is broken.</param>
|
||||
/// <returns>Submit feedback request.</returns>
|
||||
public string DoSubmitFeedback(
|
||||
public string DoSubmitFeedback(
|
||||
string bikeId,
|
||||
string message = null,
|
||||
bool isBikeBroken = false)
|
||||
string message = null,
|
||||
bool isBikeBroken = false)
|
||||
{
|
||||
if (string.IsNullOrEmpty(message) && !isBikeBroken)
|
||||
{
|
||||
|
@ -161,7 +163,7 @@ namespace TINK.Repository.Request
|
|||
return $"request=user_feedback&bike={bikeId}&bike_broken=1&message={WebUtility.UrlEncode(message)}&authcookie={SessionCookie}{MerchantId}";
|
||||
}
|
||||
|
||||
private string GetBatteryPercentageParameters(double batteryPercentage) => !double.IsNaN(batteryPercentage)
|
||||
private string GetBatteryPercentageParameters(double batteryPercentage) => !double.IsNaN(batteryPercentage)
|
||||
? $"&voltage={batteryPercentage.ToString(CultureInfo.InvariantCulture)}"
|
||||
: string.Empty;
|
||||
|
||||
|
@ -169,7 +171,7 @@ namespace TINK.Repository.Request
|
|||
/// <param name="geolocation">Geolocation or null.</param>
|
||||
private string GetLocationParameters(LocationDto geolocation)
|
||||
{
|
||||
if (geolocation == null)
|
||||
if (geolocation == null)
|
||||
return string.Empty;
|
||||
|
||||
if (geolocation.Accuracy == null)
|
||||
|
@ -188,5 +190,21 @@ namespace TINK.Repository.Request
|
|||
$"{(!string.IsNullOrEmpty(smartDevice.VersionText) ? $"&user_device_version={smartDevice.VersionText}" : string.Empty)}" +
|
||||
$"{(!string.IsNullOrEmpty(smartDevice.Identifier) ? $"&user_device_id={smartDevice.Identifier}" : string.Empty)}"
|
||||
: string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Gets request for submiting mini survey to copri server.
|
||||
/// </summary>
|
||||
/// <param name="answers">Collection of answers.</param>
|
||||
public string DoSubmitMiniSurvey(IDictionary<string, string> answers)
|
||||
{
|
||||
// Remove entires which invalid keys or values.
|
||||
var validAnsers = answers?.Where(x => !string.IsNullOrEmpty(x.Key?.Trim()) && !string.IsNullOrEmpty(x.Value?.Trim()));
|
||||
// Create quersy
|
||||
return validAnsers != null && validAnsers.Count() > 0
|
||||
? $"request=user_minianswer&{string.Join("&", validAnsers.Select(x => $"{x.Key}={WebUtility.UrlEncode(x.Value)}"))}&authcookie={SessionCookie}{MerchantId}"
|
||||
: $"request=user_minianswer&authcookie={SessionCookie}{MerchantId}";
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue