mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-02-23 14:40:36 +01:00
31 lines
924 B
C#
31 lines
924 B
C#
using NBitpayClient;
|
|
using System.Linq;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using NBitcoin;
|
|
using BTCPayServer.Rating;
|
|
|
|
namespace BTCPayServer.Services.Rates
|
|
{
|
|
public class BitpayRateProvider : IRateProvider
|
|
{
|
|
public const string BitpayName = "bitpay";
|
|
Bitpay _Bitpay;
|
|
public BitpayRateProvider(Bitpay bitpay)
|
|
{
|
|
if (bitpay == null)
|
|
throw new ArgumentNullException(nameof(bitpay));
|
|
_Bitpay = bitpay;
|
|
}
|
|
|
|
public async Task<ExchangeRates> GetRatesAsync()
|
|
{
|
|
return new ExchangeRates((await _Bitpay.GetRatesAsync().ConfigureAwait(false))
|
|
.AllRates
|
|
.Select(r => new ExchangeRate() { Exchange = BitpayName, CurrencyPair = new CurrencyPair("BTC", r.Code), Value = r.Value })
|
|
.ToList());
|
|
}
|
|
}
|
|
}
|