Fix call to Rates via bitpay API

This commit is contained in:
nicolas.dorier
2018-05-06 22:41:38 +09:00
parent cdc0b0d628
commit efe666b284
2 changed files with 16 additions and 5 deletions

View File

@@ -2,7 +2,7 @@
<PropertyGroup> <PropertyGroup>
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.0</TargetFramework> <TargetFramework>netcoreapp2.0</TargetFramework>
<Version>1.0.2.8</Version> <Version>1.0.2.9</Version>
<NoWarn>NU1701,CA1816,CA1308,CA1810,CA2208</NoWarn> <NoWarn>NU1701,CA1816,CA1308,CA1810,CA2208</NoWarn>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

View File

@@ -36,11 +36,12 @@ namespace BTCPayServer.Controllers
[BitpayAPIConstraint] [BitpayAPIConstraint]
public async Task<IActionResult> GetRates(string currencyPairs, string storeId) public async Task<IActionResult> GetRates(string currencyPairs, string storeId)
{ {
storeId = storeId ?? this.HttpContext.GetStoreData()?.Id;
var result = await GetRates2(currencyPairs, storeId); var result = await GetRates2(currencyPairs, storeId);
var rates = (result as JsonResult)?.Value as NBitpayClient.Rate[]; var rates = (result as JsonResult)?.Value as Rate[];
if (rates == null) if (rates == null)
return result; return result;
return Json(new DataWrapper<NBitpayClient.Rate[]>(rates)); return Json(new DataWrapper<Rate[]>(rates));
} }
[Route("api/rates")] [Route("api/rates")]
@@ -54,8 +55,9 @@ namespace BTCPayServer.Controllers
return result; return result;
} }
var store = this.HttpContext.GetStoreData();
var store = await _StoreRepo.FindStore(storeId); if(store == null || store.Id != storeId)
store = await _StoreRepo.FindStore(storeId);
if (store == null) if (store == null)
{ {
var result = Json(new BitpayErrorsModel() { Error = "Store not found" }); var result = Json(new BitpayErrorsModel() { Error = "Store not found" });
@@ -86,6 +88,7 @@ namespace BTCPayServer.Controllers
{ {
CryptoCode = r.Pair.Left, CryptoCode = r.Pair.Left,
Code = r.Pair.Right, Code = r.Pair.Right,
CurrencyPair = r.Pair.ToString(),
Name = _CurrencyNameTable.GetCurrencyData(r.Pair.Right)?.Name, Name = _CurrencyNameTable.GetCurrencyData(r.Pair.Right)?.Name,
Value = r.Value.Value Value = r.Value.Value
}).Where(n => n.Name != null).ToArray()); }).Where(n => n.Name != null).ToArray());
@@ -106,6 +109,14 @@ namespace BTCPayServer.Controllers
get; get;
set; set;
} }
[JsonProperty(PropertyName = "currencyPair")]
public string CurrencyPair
{
get;
set;
}
[JsonProperty(PropertyName = "code")] [JsonProperty(PropertyName = "code")]
public string Code public string Code
{ {