using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using TINK.Model.Device;
using TINK.Repository;
using TINK.Repository.Request;
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.
/// Two letter ISO language name.
public CopriProviderMonkeyStore(
string merchantId,
string uiIsoLangugageName,
string sessionCookie)
{
monkeyStore = new CopriCallsMonkeyStore(merchantId, uiIsoLangugageName, sessionCookie);
}
/// Gets the merchant id.
public string MerchantId => monkeyStore.MerchantId;
public Task DoReserveAsync(string bikeId, Uri operatorUri)
=> throw new NotSupportedException($"{nameof(DoReserveAsync)} is not cachable.");
public Task DoCancelReservationAsync(string bikeId, Uri operatorUri)
=> throw new NotSupportedException($"{nameof(DoCancelReservationAsync)} is not cachable.");
public Task CalculateAuthKeysAsync(string bikeId, Uri operatorUri)
=> throw new NotSupportedException($"{nameof(CalculateAuthKeysAsync)} is not cachable.");
public async Task StartReturningBike(
string bikeId,
Uri operatorUri)
=> await monkeyStore.StartReturningBike(bikeId, operatorUri);
public async Task UpdateLockingStateAsync(
string bikeId,
lock_state state,
Uri operatorUri,
LocationDto geolocation,
double batteryLevel)
=> await monkeyStore.UpdateLockingStateAsync(
bikeId,
state,
operatorUri,
geolocation,
batteryLevel);
public async Task DoBookAsync(string bikeId, Guid guid, double batteryPercentage, Uri operatorUri)
{
return await monkeyStore.DoBookAsync(bikeId, guid, batteryPercentage, operatorUri);
}
public async Task BookAvailableAndStartOpeningAsync(
string bikeId,
Uri operatorUri)
=> await monkeyStore.BookAvailableAndStartOpeningAsync(bikeId, operatorUri);
public async Task BookReservedAndStartOpeningAsync(
string bikeId,
Uri operatorUri)
=> await monkeyStore.BookReservedAndStartOpeningAsync(bikeId, operatorUri);
public async Task DoReturn(
string bikeId,
LocationDto geolocation,
ISmartDevice smartDevice,
Uri operatorUri)
=> await monkeyStore.DoReturn(bikeId, geolocation, smartDevice, operatorUri);
public async Task ReturnAndStartClosingAsync(
string bikeId,
ISmartDevice smartDevice,
Uri operatorUri)
=> await monkeyStore.ReturnAndStartClosingAsync(bikeId, smartDevice, operatorUri);
public Task DoSubmitFeedback(string bikeId, int? currentChargeBars, string messge, bool bIsBikeBroke, Uri operatorUri)
=> throw new NotImplementedException();
/// Submits mini survey to copri server.
/// Collection of answers.
public Task DoSubmitMiniSurvey(IDictionary answers)
=> throw new NotSupportedException();
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();
}
}
}