bitvavo / java-bitvavo-api

Java wrapper for the Bitvavo API
ISC License
9 stars 13 forks source link

Fixed error when getting single price ticker with market filter #1

Closed PretentiousPotatoPeeler closed 4 years ago

PretentiousPotatoPeeler commented 4 years ago

I ran in to an error where I wanted to only get the Bitcoin price. The initial code did not work:

JSONArray response = bitvavo.tickerPrice(new JSONObject("{ market: BTC-EUR }"));

This resulted in the following error:

A JSONArray text must start with '[' at 1 [character 2 line 1]

This was caused by trying to parse the single returned JSON object to a String.

I propose a new method to get a single price ticker that returns a JSONObject. The original method can be altered to not need a JSONObject parameter.

Please see my proposed solution, I'd love to hear your thoughts on it!

joeri-vv commented 4 years ago

You were right, some endpoints would return a jsonObject when specifying certain parameters. The functions mapping to these endpoints have been changed to allways return a JSONArray, containing exactly one item when the parameters are used.