Version 3.0.363

This commit is contained in:
Anja 2023-04-19 12:14:14 +02:00
parent 4ff3307997
commit 91d42552c7
212 changed files with 1799 additions and 1318 deletions

View file

@ -9,6 +9,7 @@ using TINK.Model.Device;
using TINK.Repository;
using TINK.Repository.Request;
using TINK.Repository.Response;
using TINK.Repository.Response.Stations;
namespace TINK.Model.Services.CopriApi
{
@ -18,7 +19,7 @@ namespace TINK.Model.Services.CopriApi
/// <summary> Object which manages stored copri answers. </summary>
private ICopriCache CacheServer { get; }
/// <summary> Communicates whith copri server. </summary>
/// <summary> Communicates with copri server. </summary>
private ICopriServer HttpsServer { get; }
/// <summary> True if connector has access to copri server, false if cached values are used. </summary>
@ -30,9 +31,9 @@ namespace TINK.Model.Services.CopriApi
/// <summary> Gets the merchant id.</summary>
public string MerchantId => HttpsServer.MerchantId;
/// <summary> Constructs copri provider object to connet to https using a cache objet. </summary>
/// <summary> Constructs copri provider object to connect to https using a cache object. </summary>
/// <param name="copriHost"></param>
/// <param name="appContextInfo">Provides app related info (app name and version, merchantid) to pass to COPRI.</param>
/// <param name="appContextInfo">Provides app related info (app name and version, merchant id) to pass to COPRI.</param>
/// <param name="uiIsoLangugageName">Two letter ISO language name.</param>
/// <param name="smartDevice">Holds info about smart device.</param>
/// <param name="sessionCookie">Cookie of user if a user is logged in, false otherwise.</param>
@ -68,7 +69,7 @@ namespace TINK.Model.Services.CopriApi
try
{
Log.ForContext<CopriProviderHttps>().Debug($"Querrying bikes available from copri.");
Log.ForContext<CopriProviderHttps>().Debug($"Querying bikes available from copri.");
var bikesAvailableResponse = await HttpsServer.GetBikesAvailableAsync();
return new Result<BikesAvailableResponse>(
typeof(CopriCallsHttps),
@ -78,13 +79,13 @@ namespace TINK.Model.Services.CopriApi
catch (Exception exception)
{
// Return response from cache.
Log.ForContext<CopriProviderHttps>().Debug("An error occurred querrying bikes available. {Exception}.", exception);
Log.ForContext<CopriProviderHttps>().Debug("An error occurred querying bikes available. {Exception}.", exception);
var bikesAvailableResponse = await CacheServer.GetBikesAvailableAsync();
return new Result<BikesAvailableResponse>(typeof(CopriCallsMonkeyStore), bikesAvailableResponse, bikesAvailableResponse.GetGeneralData(), exception);
}
}
/// <summary> Gets a list of bikes reserved/ booked by acctive user. </summary>
/// <summary> Gets a list of bikes reserved/ booked by active user. </summary>
/// <param name="sessionCookie">Cookie to authenticate user.</param>
/// <returns>Response holding list of bikes.</returns>
public async Task<Result<BikesReservedOccupiedResponse>> GetBikesOccupied(bool fromCache = false)
@ -101,7 +102,7 @@ namespace TINK.Model.Services.CopriApi
try
{
Log.ForContext<CopriProviderHttps>().Debug($"Querrying bikes occupied from copri.");
Log.ForContext<CopriProviderHttps>().Debug($"Querying bikes occupied from copri.");
var bikesOccupiedResponse = await HttpsServer.GetBikesOccupiedAsync();
return new Result<BikesReservedOccupiedResponse>(
typeof(CopriCallsHttps),
@ -112,7 +113,7 @@ namespace TINK.Model.Services.CopriApi
catch (Exception exception)
{
// Return response from cache.
Log.ForContext<CopriProviderHttps>().Debug("An error occurred querrying bikes occupied. {Exception}.", exception);
Log.ForContext<CopriProviderHttps>().Debug("An error occurred querying bikes occupied. {Exception}.", exception);
var bikesOccupiedResponse = await CacheServer.GetBikesOccupiedAsync();
return new Result<BikesReservedOccupiedResponse>(typeof(CopriCallsMonkeyStore), bikesOccupiedResponse, bikesOccupiedResponse.GetGeneralData(), exception);
}
@ -134,7 +135,7 @@ namespace TINK.Model.Services.CopriApi
try
{
Log.ForContext<CopriProviderHttps>().Debug($"Querrying stations from copri.");
Log.ForContext<CopriProviderHttps>().Debug($"Querying stations from copri.");
var stations = await HttpsServer.GetStationsAsync();
@ -146,7 +147,7 @@ namespace TINK.Model.Services.CopriApi
catch (Exception exception)
{
// Return response from cache.
Log.ForContext<CopriProviderHttps>().Debug("An error occurred querrying stations. {Exception}.", exception);
Log.ForContext<CopriProviderHttps>().Debug("An error occurred querying stations. {Exception}.", exception);
var stationsResponse = await CacheServer.GetStationsAsync();
return new Result<StationsAvailableResponse>(typeof(CopriCallsMonkeyStore), stationsResponse, stationsResponse.GetGeneralData(), exception);
}

View file

@ -7,6 +7,7 @@ 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

View file

@ -1,7 +1,8 @@

using System.Threading.Tasks;
using TINK.Repository;
using TINK.Repository.Response;
using TINK.Repository.Response.Stations;
namespace TINK.Model.Services.CopriApi
{
@ -16,7 +17,7 @@ namespace TINK.Model.Services.CopriApi
/// <returns>Response holding list of bikes.</returns>
Task<Result<BikesAvailableResponse>> GetBikesAvailable(bool fromCache = false);
/// <summary> Gets a list of bikes reserved/ booked by acctive user from Copri.</summary>
/// <summary> Gets a list of bikes reserved/ booked by active user from Copri.</summary>
/// <returns>Response holding list of bikes.</returns>
Task<Result<BikesReservedOccupiedResponse>> GetBikesOccupied(bool fromCache = false);

View file

@ -1,5 +1,6 @@
using TINK.Repository;
using TINK.Repository.Response;
using TINK.Repository.Response.Stations;
namespace TINK.Model.Services.CopriApi
{

View file

@ -112,7 +112,7 @@ namespace TINK.Services.CopriApi
if (lockingState == null)
{
// User did not take bike out of the station
throw new BikeStillInStationException("Booking was cancelled because bike is still in station.");
throw new BikeStillInStationException("Booking was canceled because bike is still in station.");
}
// Upate booking state.

View file

@ -1,4 +1,4 @@
using System;
using System;
using TINK.Services.CopriApi;
namespace TINK.Model.Services.CopriApi
@ -10,7 +10,7 @@ namespace TINK.Model.Services.CopriApi
/// </summary>
/// <param name="source">Type of source (data provider).</param>
/// <param name="response">Requested data (bikes, station).</param>
/// <param name="generalData">General data (common to all respones).</param>
/// <param name="generalData">General data (common to all responses).</param>
public Result(
Type source,
T response,

View file

@ -1,5 +1,5 @@
using TINK.Model.Bikes;
using TINK.Model.Station;
using TINK.Model.Bikes;
using TINK.Model.Stations;
namespace TINK.Model.Services.CopriApi
{