mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2024-11-12 13:36:26 +01:00
120 lines
4.8 KiB
C#
120 lines
4.8 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Threading.Tasks;
|
|
using TINK.Model.Bikes.BikeInfoNS.BluetoothLock;
|
|
using TINK.Model.Connector;
|
|
using TINK.Model.Device;
|
|
using TINK.Repository;
|
|
using TINK.Repository.Request;
|
|
using TINK.Repository.Response;
|
|
using TINK.Repository.Response.Stations;
|
|
using TINK.Services.CopriApi.Exception;
|
|
|
|
namespace TINK.Model.Services.CopriApi
|
|
{
|
|
/// <summary> Object which manages calls to cache. </summary>
|
|
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>
|
|
/// <param name="uiIsoLangugageName">Two letter ISO language name.</param>
|
|
/// <param name="smartDevice">Holds info about smart device.</param>
|
|
public CopriProviderMonkeyStore(
|
|
string merchantId,
|
|
string uiIsoLangugageName,
|
|
string sessionCookie,
|
|
ISmartDevice smartDevice = null)
|
|
{
|
|
monkeyStore = new CopriCallsMonkeyStore(merchantId, uiIsoLangugageName, sessionCookie, smartDevice);
|
|
}
|
|
|
|
/// <summary> Gets the merchant id.</summary>
|
|
public string MerchantId => monkeyStore.MerchantId;
|
|
|
|
public Task<ReservationBookingResponse> DoReserveAsync(string bikeId, Uri operatorUri)
|
|
=> throw new RequestNotCachableException(nameof(DoReserveAsync));
|
|
|
|
public Task<ReservationCancelReturnResponse> DoCancelReservationAsync(string bikeId, Uri operatorUri)
|
|
=> throw new RequestNotCachableException(nameof(DoCancelReservationAsync));
|
|
|
|
public Task<ReservationBookingResponse> CalculateAuthKeysAsync(string bikeId, Uri operatorUri)
|
|
=> throw new RequestNotCachableException(nameof(CalculateAuthKeysAsync));
|
|
|
|
public async Task<ResponseBase> StartReturningBike(
|
|
string bikeId,
|
|
Uri operatorUri)
|
|
=> await monkeyStore.StartReturningBike(bikeId, operatorUri);
|
|
|
|
|
|
public async Task<ReservationBookingResponse> UpdateLockingStateAsync(
|
|
string bikeId,
|
|
lock_state state,
|
|
Uri operatorUri,
|
|
LocationDto geolocation,
|
|
double batteryLevel,
|
|
IVersionInfo versionInfo)
|
|
=> await monkeyStore.UpdateLockingStateAsync(
|
|
bikeId,
|
|
state,
|
|
operatorUri,
|
|
geolocation,
|
|
batteryLevel,
|
|
versionInfo);
|
|
|
|
public async Task<ReservationBookingResponse> DoBookAsync(Uri operatorUri, string bikeId, Guid guid, double batteryPercentage, LockingAction? nextAction = null)
|
|
=> await monkeyStore.DoBookAsync(operatorUri, bikeId, guid, batteryPercentage, nextAction);
|
|
|
|
public async Task<ReservationBookingResponse> BookAvailableAndStartOpeningAsync(
|
|
string bikeId,
|
|
Uri operatorUri)
|
|
=> await monkeyStore.BookAvailableAndStartOpeningAsync(bikeId, operatorUri);
|
|
|
|
public async Task<ReservationBookingResponse> BookReservedAndStartOpeningAsync(
|
|
string bikeId,
|
|
Uri operatorUri)
|
|
=> await monkeyStore.BookReservedAndStartOpeningAsync(bikeId, operatorUri);
|
|
|
|
public async Task<DoReturnResponse> DoReturn(
|
|
string bikeId,
|
|
LocationDto geolocation,
|
|
Uri operatorUri)
|
|
=> await monkeyStore.DoReturn(bikeId, geolocation, operatorUri);
|
|
|
|
public async Task<DoReturnResponse> ReturnAndStartClosingAsync(
|
|
string bikeId,
|
|
Uri operatorUri)
|
|
=> await monkeyStore.ReturnAndStartClosingAsync(bikeId, operatorUri);
|
|
|
|
public Task<SubmitFeedbackResponse> DoSubmitFeedback(string bikeId, int? currentChargeBars, string messge, bool bIsBikeBroke, Uri operatorUri)
|
|
=> throw new RequestNotCachableException(nameof(DoSubmitFeedback));
|
|
|
|
/// <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 RequestNotCachableException(nameof(DoSubmitMiniSurvey));
|
|
|
|
public async Task<AuthorizationResponse> DoAuthorizationAsync(string p_strMailAddress, string p_strPassword, string p_strDeviceId)
|
|
=> await monkeyStore.DoAuthorizationAsync(p_strMailAddress, p_strPassword, p_strDeviceId);
|
|
|
|
public async Task<AuthorizationoutResponse> DoAuthoutAsync()
|
|
=> await monkeyStore.DoAuthoutAsync();
|
|
|
|
public async Task<BikesAvailableResponse> GetBikesAvailableAsync()
|
|
=> await monkeyStore.GetBikesAvailableAsync();
|
|
|
|
public async Task<BikesReservedOccupiedResponse> GetBikesOccupiedAsync()
|
|
=> await monkeyStore.GetBikesOccupiedAsync();
|
|
|
|
public async Task<StationsAvailableResponse> GetStationsAsync()
|
|
=> await monkeyStore.GetStationsAsync();
|
|
}
|
|
}
|