2021-05-13 20:03:07 +02:00
|
|
|
|
using System;
|
2022-01-04 18:54:03 +01:00
|
|
|
|
using TINK.Services.CopriApi;
|
2021-05-13 20:03:07 +02:00
|
|
|
|
|
|
|
|
|
namespace TINK.Model.Services.CopriApi
|
|
|
|
|
{
|
|
|
|
|
public class Result<T> where T : class
|
|
|
|
|
{
|
2022-01-04 18:54:03 +01:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Constructs a result object.
|
|
|
|
|
/// </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>
|
|
|
|
|
public Result(
|
2022-08-30 15:42:25 +02:00
|
|
|
|
Type source,
|
|
|
|
|
T response,
|
2022-01-04 18:54:03 +01:00
|
|
|
|
GeneralData generalData,
|
2022-08-30 15:42:25 +02:00
|
|
|
|
Exception exception = null)
|
2021-05-13 20:03:07 +02:00
|
|
|
|
{
|
|
|
|
|
Source = source ?? throw new ArgumentException(nameof(source));
|
|
|
|
|
Response = response ?? throw new ArgumentException(nameof(response));
|
2022-01-04 18:54:03 +01:00
|
|
|
|
GeneralData = generalData ?? new GeneralData();
|
2021-05-13 20:03:07 +02:00
|
|
|
|
Exception = exception;
|
|
|
|
|
}
|
|
|
|
|
|
2022-01-04 18:54:03 +01:00
|
|
|
|
/// <summary> Holds the requested data (bikes, stations and bikes).</summary>
|
2021-05-13 20:03:07 +02:00
|
|
|
|
public T Response { get; }
|
|
|
|
|
|
2022-01-04 18:54:03 +01:00
|
|
|
|
/// <summary> Holds the general purpose data (common to all responses).</summary>
|
2022-08-30 15:42:25 +02:00
|
|
|
|
public GeneralData GeneralData { get; }
|
2022-01-04 18:54:03 +01:00
|
|
|
|
|
|
|
|
|
/// <summary> Specifies the source (type of provider) of the copri response.</summary>
|
2021-05-13 20:03:07 +02:00
|
|
|
|
public Type Source { get; }
|
|
|
|
|
|
|
|
|
|
/// <summary> Holds the exception if a communication error occurred.</summary>
|
2022-01-04 18:54:03 +01:00
|
|
|
|
public Exception Exception { get; private set; }
|
2021-05-13 20:03:07 +02:00
|
|
|
|
}
|
|
|
|
|
}
|