sharee.bike-App/TINKLib/Services/CopriApi/Result.cs
2023-04-19 12:14:14 +02:00

38 lines
1.2 KiB
C#

using System;
using TINK.Services.CopriApi;
namespace TINK.Model.Services.CopriApi
{
public class Result<T> where T : class
{
/// <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 responses).</param>
public Result(
Type source,
T response,
GeneralData generalData,
Exception exception = null)
{
Source = source ?? throw new ArgumentException(nameof(source));
Response = response ?? throw new ArgumentException(nameof(response));
GeneralData = generalData ?? new GeneralData();
Exception = exception;
}
/// <summary> Holds the requested data (bikes, stations and bikes).</summary>
public T Response { get; }
/// <summary> Holds the general purpose data (common to all responses).</summary>
public GeneralData GeneralData { get; }
/// <summary> Specifies the source (type of provider) of the copri response.</summary>
public Type Source { get; }
/// <summary> Holds the exception if a communication error occurred.</summary>
public Exception Exception { get; private set; }
}
}