/// <summary> /// Make a call to a public (non-authenticated) API /// </summary> /// <param name="method">The method to call on the Prelude API</param> /// <param name="quoteCurrency">A quote currency code to append to the method URL</param> /// <returns>The raw JSON returned from Prelude</returns> private async Task <T> CallPublic <T>(Method method, PreludeQuoteCurrency quoteCurrencyCode) where T : JToken { string url = BuildPublicUrl(method, quoteCurrencyCode); return((T)JToken.Parse(await CallPublic(url))); }
public static List<MarketId> ParsePairs(JObject pairsJson, PreludeQuoteCurrency quoteCurrency) { // TODO: Verify the quote currency matches the "from" currency in the JSON return pairsJson.Value<JArray>("pairings").Select( trade => (MarketId)ParseSingle((JObject)trade, quoteCurrency) ).ToList(); }
public static List <MarketId> ParsePairs(JObject pairsJson, PreludeQuoteCurrency quoteCurrency) { // TODO: Verify the quote currency matches the "from" currency in the JSON return(pairsJson.Value <JArray>("pairings").Select( trade => (MarketId)ParseSingle((JObject)trade, quoteCurrency) ).ToList()); }
/// <summary> /// Return the (unescaped) path element to be inserted between the method, /// and quote currency, in the URL. This is required because Prelude has /// inconsistent URL naming depending on base currency. /// </summary> static string GetQuoteCurrencyMethodPostfix(PreludeQuoteCurrency quoteCurrency) { switch (quoteCurrency) { case PreludeQuoteCurrency.BTC: return(""); default: return("-" + Enum.GetName(typeof(PreludeQuoteCurrency), quoteCurrency).ToLower()); } }
public static string BuildPublicUrl(Method method, PreludeQuoteCurrency quoteCurrency) { switch (method) { case Method.pairings: return(BASE_URL + Enum.GetName(typeof(Method), method) + "/" + Uri.EscapeUriString(Enum.GetName(typeof(PreludeQuoteCurrency), quoteCurrency).ToLower())); break; default: return(BASE_URL + Enum.GetName(typeof(Method), method) + Uri.EscapeUriString(GetQuoteCurrencyMethodPostfix(quoteCurrency)) + "/"); } }
private static PreludeMarketId ParseSingle(JObject pairJson, PreludeQuoteCurrency quoteCurrency) { return new PreludeMarketId(pairJson.Value<string>("pair"), quoteCurrency); }
public PreludeMarketId(string baseCode, PreludeQuoteCurrency quoteCode) : base(baseCode + "_" + quoteCode) { this.BaseCurrencyCode = baseCode; this.QuoteCurrencyCode = quoteCode; }
private static PreludeMarketId ParseSingle(JObject pairJson, PreludeQuoteCurrency quoteCurrency) { return(new PreludeMarketId(pairJson.Value <string>("pair"), quoteCurrency)); }
public PreludeMarketId(string baseCode, PreludeQuoteCurrency quoteCode) : base(baseCode + "_" + quoteCode) { this.BaseCurrencyCode = baseCode; this.QuoteCurrencyCode = quoteCode; }