sharee.bike-App/TINKLib/Services/CopriApi/CopriProviderMonkeyStore.cs

127 lines
5.2 KiB
C#
Raw Normal View History

2021-05-13 20:03:07 +02:00
using System;
2021-08-01 17:24:15 +02:00
using System.Collections.Generic;
2021-05-13 20:03:07 +02:00
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>
2022-08-30 15:42:25 +02:00
/// <param name="uiIsoLangugageName">Two letter ISO language name.</param>
2021-05-13 20:03:07 +02:00
public CopriProviderMonkeyStore(
string merchantId,
2022-08-30 15:42:25 +02:00
string uiIsoLangugageName,
2021-05-13 20:03:07 +02:00
string sessionCookie)
{
2022-08-30 15:42:25 +02:00
monkeyStore = new CopriCallsMonkeyStore(merchantId, uiIsoLangugageName, sessionCookie);
2021-05-13 20:03:07 +02:00
}
2022-08-30 15:42:25 +02:00
/// <summary> Gets the merchant id.</summary>
2021-05-13 20:03:07 +02:00
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.");
2022-04-10 17:38:34 +02:00
public async Task<ResponseBase> StartReturningBike(
string bikeId,
Uri operatorUri)
=> await monkeyStore.StartReturningBike(bikeId, operatorUri);
2021-05-13 20:03:07 +02:00
public async Task<ReservationBookingResponse> UpdateLockingStateAsync(
2022-08-30 15:42:25 +02:00
string bikeId,
2021-05-13 20:03:07 +02:00
lock_state state,
2022-04-25 22:15:15 +02:00
Uri operatorUri,
2022-08-30 15:42:25 +02:00
LocationDto geolocation,
2022-04-25 22:15:15 +02:00
double batteryLevel)
=> await monkeyStore.UpdateLockingStateAsync(
2022-08-30 15:42:25 +02:00
bikeId,
2022-04-25 22:15:15 +02:00
state,
operatorUri,
2022-08-30 15:42:25 +02:00
geolocation,
2022-04-25 22:15:15 +02:00
batteryLevel);
2021-05-13 20:03:07 +02:00
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);
}
2022-08-30 15:42:25 +02:00
public async Task<ReservationBookingResponse> BookAvailableAndStartOpeningAsync(
string bikeId,
Uri operatorUri)
=> await monkeyStore.BookAvailableAndStartOpeningAsync(bikeId, operatorUri);
public async Task<ReservationBookingResponse> BookReservedAndStartOpeningAsync(
2022-04-25 22:15:15 +02:00
string bikeId,
Uri operatorUri)
2022-08-30 15:42:25 +02:00
=> await monkeyStore.BookReservedAndStartOpeningAsync(bikeId, operatorUri);
2022-04-25 22:15:15 +02:00
2021-12-08 17:57:30 +01:00
public async Task<DoReturnResponse> DoReturn(
2022-08-30 15:42:25 +02:00
string bikeId,
2021-06-26 20:57:55 +02:00
LocationDto geolocation,
ISmartDevice smartDevice,
Uri operatorUri)
2022-08-30 15:42:25 +02:00
=> await monkeyStore.DoReturn(bikeId, geolocation, smartDevice, operatorUri);
2021-05-13 20:03:07 +02:00
2022-04-25 22:15:15 +02:00
public async Task<DoReturnResponse> ReturnAndStartClosingAsync(
string bikeId,
ISmartDevice smartDevice,
Uri operatorUri)
=> await monkeyStore.ReturnAndStartClosingAsync(bikeId, smartDevice, operatorUri);
2022-08-30 15:42:25 +02:00
public Task<SubmitFeedbackResponse> DoSubmitFeedback(string bikeId, int? currentChargeBars, string messge, bool bIsBikeBroke, Uri operatorUri)
2021-08-01 17:24:15 +02:00
=> throw new NotImplementedException();
/// <summary> Submits mini survey to copri server. </summary>
/// <param name="answers">Collection of answers.</param>
public Task<ResponseBase> DoSubmitMiniSurvey(IDictionary<string, string> answers)
=> throw new NotSupportedException();
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<StationsAvailableResponse> GetStationsAsync()
2021-05-13 20:03:07 +02:00
{
return await monkeyStore.GetStationsAsync();
}
}
}