2021-05-13 20:03:07 +02:00
|
|
|
|
using System;
|
|
|
|
|
using System.Threading.Tasks;
|
2021-06-26 20:57:55 +02:00
|
|
|
|
using TINK.Model.Device;
|
|
|
|
|
using TINK.Repository;
|
|
|
|
|
using TINK.Repository.Request;
|
2021-05-13 20:03:07 +02:00
|
|
|
|
using TINK.Repository.Response;
|
|
|
|
|
|
|
|
|
|
namespace TINK.Model.Services.CopriApi
|
|
|
|
|
{
|
|
|
|
|
public class CopriProviderMonkeyStore : ICopriServer
|
|
|
|
|
{
|
|
|
|
|
/// <summary> Object which manages stored copri answers. </summary>
|
|
|
|
|
private readonly CopriCallsMonkeyStore monkeyStore;
|
|
|
|
|
|
|
|
|
|
/// <summary> True if connector has access to copri server, false if cached values are used. </summary>
|
|
|
|
|
public bool IsConnected => monkeyStore.IsConnected;
|
|
|
|
|
|
|
|
|
|
/// <summary> Gets the session cookie if user is logged in, an empty string otherwise. </summary>
|
|
|
|
|
public string SessionCookie => monkeyStore.SessionCookie;
|
|
|
|
|
|
|
|
|
|
/// <summary> Constructs object which Object which manages stored copri answers in a thread save way. </summary>
|
|
|
|
|
/// <param name="merchantId">Id of the merchant TINK-App.</param>
|
|
|
|
|
public CopriProviderMonkeyStore(
|
|
|
|
|
string merchantId,
|
|
|
|
|
string sessionCookie)
|
|
|
|
|
{
|
|
|
|
|
monkeyStore = new CopriCallsMonkeyStore(merchantId, sessionCookie);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary> Gets the merchant id.</summary>
|
|
|
|
|
public string MerchantId => monkeyStore.MerchantId;
|
|
|
|
|
|
2021-06-26 20:57:55 +02:00
|
|
|
|
public Task<ReservationBookingResponse> DoReserveAsync(string bikeId, Uri operatorUri)
|
2021-05-13 20:03:07 +02:00
|
|
|
|
=> throw new NotSupportedException($"{nameof(DoReserveAsync)} is not cachable.");
|
|
|
|
|
|
2021-06-26 20:57:55 +02:00
|
|
|
|
public Task<ReservationCancelReturnResponse> DoCancelReservationAsync(string bikeId, Uri operatorUri)
|
2021-05-13 20:03:07 +02:00
|
|
|
|
=> throw new NotSupportedException($"{nameof(DoCancelReservationAsync)} is not cachable.");
|
|
|
|
|
|
2021-06-26 20:57:55 +02:00
|
|
|
|
public Task<ReservationBookingResponse> CalculateAuthKeysAsync(string bikeId, Uri operatorUri)
|
2021-05-13 20:03:07 +02:00
|
|
|
|
=> throw new NotSupportedException($"{nameof(CalculateAuthKeysAsync)} is not cachable.");
|
|
|
|
|
|
|
|
|
|
public async Task<ReservationBookingResponse> UpdateLockingStateAsync(
|
2021-06-26 20:57:55 +02:00
|
|
|
|
string bikeId,
|
2021-05-13 20:03:07 +02:00
|
|
|
|
LocationDto geolocation,
|
|
|
|
|
lock_state state,
|
|
|
|
|
double batteryLevel,
|
|
|
|
|
Uri operatorUri)
|
|
|
|
|
=> await monkeyStore.UpdateLockingStateAsync(bikeId, geolocation, state, batteryLevel, operatorUri);
|
|
|
|
|
|
2021-06-26 20:57:55 +02:00
|
|
|
|
public async Task<ReservationBookingResponse> DoBookAsync(string bikeId, Guid guid, double batteryPercentage, Uri operatorUri)
|
2021-05-13 20:03:07 +02:00
|
|
|
|
{
|
|
|
|
|
return await monkeyStore.DoBookAsync(bikeId, guid, batteryPercentage, operatorUri);
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-26 20:57:55 +02:00
|
|
|
|
public async Task<ReservationCancelReturnResponse> DoReturn(
|
|
|
|
|
string bikeId,
|
|
|
|
|
LocationDto geolocation,
|
|
|
|
|
ISmartDevice smartDevice,
|
|
|
|
|
Uri operatorUri)
|
2021-05-13 20:03:07 +02:00
|
|
|
|
{
|
2021-06-26 20:57:55 +02:00
|
|
|
|
return await monkeyStore.DoReturn(bikeId, geolocation, smartDevice, operatorUri);
|
2021-05-13 20:03:07 +02:00
|
|
|
|
}
|
|
|
|
|
|
2021-06-26 20:57:55 +02:00
|
|
|
|
public Task<SubmitFeedbackResponse> DoSubmitFeedback(string bikeId, string messge, bool bIsBikeBroke, Uri operatorUri) => throw new NotImplementedException();
|
2021-05-13 20:03:07 +02:00
|
|
|
|
|
|
|
|
|
public async Task<AuthorizationResponse> DoAuthorizationAsync(string p_strMailAddress, string p_strPassword, string p_strDeviceId)
|
|
|
|
|
{
|
|
|
|
|
return await monkeyStore.DoAuthorizationAsync(p_strMailAddress, p_strPassword, p_strDeviceId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task<AuthorizationoutResponse> DoAuthoutAsync()
|
|
|
|
|
{
|
|
|
|
|
return await monkeyStore.DoAuthoutAsync();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task<BikesAvailableResponse> GetBikesAvailableAsync()
|
|
|
|
|
{
|
|
|
|
|
return await monkeyStore.GetBikesAvailableAsync();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task<BikesReservedOccupiedResponse> GetBikesOccupiedAsync()
|
|
|
|
|
{
|
|
|
|
|
return await monkeyStore.GetBikesOccupiedAsync();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task<StationsAllResponse> GetStationsAsync()
|
|
|
|
|
{
|
|
|
|
|
return await monkeyStore.GetStationsAsync();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|