mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2024-11-15 22:56:37 +01:00
97 lines
4 KiB
C#
97 lines
4 KiB
C#
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
|
|
{
|
|
/// <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;
|
|
|
|
public Task<ReservationBookingResponse> DoReserveAsync(string bikeId, Uri operatorUri)
|
|
=> throw new NotSupportedException($"{nameof(DoReserveAsync)} is not cachable.");
|
|
|
|
public Task<ReservationCancelReturnResponse> DoCancelReservationAsync(string bikeId, Uri operatorUri)
|
|
=> throw new NotSupportedException($"{nameof(DoCancelReservationAsync)} is not cachable.");
|
|
|
|
public Task<ReservationBookingResponse> CalculateAuthKeysAsync(string bikeId, Uri operatorUri)
|
|
=> throw new NotSupportedException($"{nameof(CalculateAuthKeysAsync)} is not cachable.");
|
|
|
|
public async Task<ReservationBookingResponse> UpdateLockingStateAsync(
|
|
string bikeId,
|
|
LocationDto geolocation,
|
|
lock_state state,
|
|
double batteryLevel,
|
|
Uri operatorUri)
|
|
=> await monkeyStore.UpdateLockingStateAsync(bikeId, geolocation, state, batteryLevel, operatorUri);
|
|
|
|
public async Task<ReservationBookingResponse> DoBookAsync(string bikeId, Guid guid, double batteryPercentage, Uri operatorUri)
|
|
{
|
|
return await monkeyStore.DoBookAsync(bikeId, guid, batteryPercentage, operatorUri);
|
|
}
|
|
|
|
public async Task<DoReturnResponse> DoReturn(
|
|
string bikeId,
|
|
LocationDto geolocation,
|
|
ISmartDevice smartDevice,
|
|
Uri operatorUri)
|
|
=> await monkeyStore.DoReturn(bikeId, geolocation, smartDevice, operatorUri);
|
|
|
|
public Task<SubmitFeedbackResponse> DoSubmitFeedback(string bikeId, string messge, bool bIsBikeBroke, Uri operatorUri)
|
|
=> 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();
|
|
|
|
|
|
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()
|
|
{
|
|
return await monkeyStore.GetStationsAsync();
|
|
}
|
|
}
|
|
}
|