using System;
using System.Threading.Tasks;
using TINK.Model.Repository;
using TINK.Model.Repository.Request;
using TINK.Model.Repository.Response;
using TINK.Repository.Response;
namespace TINK.Model.Services.CopriApi
{
public class CopriProviderMonkeyStore : ICopriServer
{
/// Object which manages stored copri answers.
private readonly CopriCallsMonkeyStore monkeyStore;
/// True if connector has access to copri server, false if cached values are used.
public bool IsConnected => monkeyStore.IsConnected;
/// Gets the session cookie if user is logged in, an empty string otherwise.
public string SessionCookie => monkeyStore.SessionCookie;
/// Constructs object which Object which manages stored copri answers in a thread save way.
/// Id of the merchant TINK-App.
public CopriProviderMonkeyStore(
string merchantId,
string sessionCookie)
{
monkeyStore = new CopriCallsMonkeyStore(merchantId, sessionCookie);
}
/// Gets the merchant id.
public string MerchantId => monkeyStore.MerchantId;
public Task DoReserveAsync(int p_iBikeId, Uri operatorUri)
=> throw new NotSupportedException($"{nameof(DoReserveAsync)} is not cachable.");
public Task DoCancelReservationAsync(int p_iBikeId, Uri operatorUri)
=> throw new NotSupportedException($"{nameof(DoCancelReservationAsync)} is not cachable.");
public Task CalculateAuthKeysAsync(int bikeId, Uri operatorUri)
=> throw new NotSupportedException($"{nameof(CalculateAuthKeysAsync)} is not cachable.");
public async Task UpdateLockingStateAsync(
int bikeId,
LocationDto geolocation,
lock_state state,
double batteryLevel,
Uri operatorUri)
=> await monkeyStore.UpdateLockingStateAsync(bikeId, geolocation, state, batteryLevel, operatorUri);
public async Task DoBookAsync(int bikeId, Guid guid, double batteryPercentage, Uri operatorUri)
{
return await monkeyStore.DoBookAsync(bikeId, guid, batteryPercentage, operatorUri);
}
public async Task DoReturn(int bikeId, LocationDto geolocation, Uri operatorUri)
{
return await monkeyStore.DoReturn(bikeId, geolocation, operatorUri);
}
public Task DoSubmitFeedback(string messge, bool bIsBikeBroke, Uri operatorUri) => throw new NotImplementedException();
public async Task DoAuthorizationAsync(string p_strMailAddress, string p_strPassword, string p_strDeviceId)
{
return await monkeyStore.DoAuthorizationAsync(p_strMailAddress, p_strPassword, p_strDeviceId);
}
public async Task DoAuthoutAsync()
{
return await monkeyStore.DoAuthoutAsync();
}
public async Task GetBikesAvailableAsync()
{
return await monkeyStore.GetBikesAvailableAsync();
}
public async Task GetBikesOccupiedAsync()
{
return await monkeyStore.GetBikesOccupiedAsync();
}
public async Task GetStationsAsync()
{
return await monkeyStore.GetStationsAsync();
}
}
}