public async Task <IBitcoinPrice> GetPriceAsync(HarvestTask task) { if (task.Origin != Origin.Bitstamp) { this._logger.LogError("Task exchange service differs"); return(null); } String method = this.APICurrencyId[task.Pair] + '/'; this._logger.LogInformation("Fetch new price"); HttpResponseMessage response = await _bitstampClient.GetAsync(method); if (!response.IsSuccessStatusCode) { this._logger.LogError("Error response from exchange API"); return(null); } String json = await response.Content.ReadAsStringAsync(); BitstampBitcoinPrice price = JsonConvert.DeserializeObject <BitstampBitcoinPrice>(json, this._serializer); price.Currency = task.Pair; return(price); }
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { JObject jsonObject = JObject.Load(reader); BitcoinPriceBase configuration = new BitstampBitcoinPrice(); configuration.Timestamp = (long)jsonObject["timestamp"]; configuration.Value = (decimal)jsonObject["last"]; return(configuration); }