btcpayserver/BTCPayServer.Rating/Providers/IRateProvider.cs

42 lines
1.5 KiB
C#
Raw Normal View History

#nullable enable
using System;
using System.Threading;
2017-09-13 15:47:34 +09:00
using System.Threading.Tasks;
2018-05-03 03:32:42 +09:00
using BTCPayServer.Rating;
2017-09-13 15:47:34 +09:00
namespace BTCPayServer.Services.Rates
2017-09-13 15:47:34 +09:00
{
public interface IRateProvider
{
RateSourceInfo RateSourceInfo { get; }
/// <summary>
/// Returns rates of the provider
/// </summary>
/// <param name="cancellationToken"></param>
/// <returns></returns>
/// <exception cref="NotSupportedException">If using this provider isn't supported (For example if a <see cref="IContextualRateProvider"/> requires a context)</exception>
Task<PairRate[]> GetRatesAsync(CancellationToken cancellationToken);
}
public interface IRateContext { }
public interface IHasStoreIdRateContext : IRateContext
{
string StoreId { get; }
}
public record StoreIdRateContext(string StoreId) : IHasStoreIdRateContext;
/// <summary>
/// A rate provider which know additional context about the rate query.
/// </summary>
public interface IContextualRateProvider : IRateProvider
{
/// <summary>
/// Returns rates of the provider when a context is available
/// </summary>
/// <param name="cancellationToken"></param>
/// <returns></returns>
/// <exception cref="NotSupportedException">If using this provider isn't getting an expected context</exception>
Task<PairRate[]> GetRatesAsync(IRateContext context, CancellationToken cancellationToken);
}
2017-09-13 15:47:34 +09:00
}