bitvavo / java-bitvavo-api

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

Channels parameter required from Kotlin #10

Closed Entreco closed 3 years ago

Entreco commented 3 years ago

Hi, I'm using Bitvavo api 1.2.0 from kotlin/android. I cloned the project, and build a jar-with-dependencies using maven.

When I try to get subscriptionTicker like so:

    ws.subscriptionTicker("BTC-EUR") { response ->
            System.out.println(response.toString());
        }

I get the following error:

DEBUG: We registered authenticated as true
DEBUG: Resetting rate limit to 1000.
DEBUG: Sending message {"action":"subscribe","channels":"[Lorg.json.JSONObject;@49e71a2"}
DEBUG: FULLRESPONSE: {"action":"subscribe","errorCode":203,"error":"channels parameter is required."}
Error: {"action":"subscribe","errorCode":203,"error":"channels parameter is required."}

While debugging inside subscriptionTicker, I can see what goes wrong:

when using exported jar with kotlin:

options = {JSONObject@12086} "{"action":"subscribe","channels":"[Lorg.json.JSONObject;@6fb3584"}"
subOptions = {JSONObject@12106} "{"name":"ticker","markets":"[Ljava.lang.String;@c17ef97"}"

NOTE the Ljava.lang.String and Lorg.json.JSONObject

when using Java example:

options = {JSONObject@3402} "{"channels":[{"markets":["BTC-EUR"],"name":"ticker"}],"action":"subscribe"}"
subOptions = {JSONObject@3406} "{"markets":["BTC-EUR"],"name":"ticker"}"

Any suggestions why this is happening? And how to resolve it? Do I have to use a special flag when building the jar for kotlin/android?

joeri-vv commented 3 years ago

This SDK has not been built with support for kotlin/android in mind. It seems like the object is not properly stringified before being sent in your example. You can try to adjust this SDK for android. But we can not guarantee that this will work.