2024-04-30 11:31:15 +02:00
#nullable enable
using System ;
2019-03-05 17:09:17 +09:00
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
2017-09-15 16:06:57 +09:00
namespace BTCPayServer.Services.Rates
2017-09-13 15:47:34 +09:00
{
public interface IRateProvider
{
2023-01-30 09:46:12 +09:00
RateSourceInfo RateSourceInfo { get ; }
2024-04-30 11:31:15 +02:00
/// <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>
2020-01-17 18:11:05 +09:00
Task < PairRate [ ] > GetRatesAsync ( CancellationToken cancellationToken ) ;
2017-10-27 17:53:04 +09:00
}
2024-04-30 11:31:15 +02:00
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
}