ok24601 / etoro-api

etoro trading REST API
ISC License
101 stars 47 forks source link

Split the project into a reusable client library and the current REST server #42

Open marco-eckstein opened 3 years ago

marco-eckstein commented 3 years ago

Right now, if I want to implement a client for your API, I have to implement a client for your REST API, i.e., model classes, mappings to JSON and the client class that performs the HTTP requests. While not hard, this is a very tedious task. I need to duplicate most of the code that is already in your project, e.g., EtoroHttpClient and EtoroPosition. I could probably reuse some of your code by depending on the Jar, but that would be very cumbersome, because your code relies on Spring's dependency injection. So I would need to use reflection to construct a EtoroHttpClient instance, e.g.

It would be very handy if you extracted your client into a separate project that could be used as a library and with code akin to:

val client = EtoroHttpClient()
client.login("username", "password")
val positions: List<EtoroPosition> = client.getPositions(TradingMode.REAL)

Your REST API project would then simply depend on that new client library, just as my code.

This client library (or at least parts of it) could even be a Kotlin multiplatform project, i.e. usable not only from JVM languages like Kotlin and Java, but also from JavaScript and other languages.

I would guess that extracting a JVM-only client would not be a lot of work for you. A multiplatform client might be a bit more challenging, but since I have some limited experience with that, I could offer my help.

mohammadfarari1360 commented 2 years ago

Okay