Thank you for the answer. The reason of such this is that I wanted to achieve a flowing structure:
1. There are
Api
classes that contains functions returning
Endpoint
instances
2.
Endpoint
class describes an endpoint, it has:
baseUrl
,
method
,
path
,
body
etc. (return type as KType?)
3. My
HttpClient
accepts `Endpoint`s and returns
Resource<T>
4.
Resource<T>
is either
Data
or
Error
Using this structure everything is easily swappable and testable, which is very important for me, because I’m working on a multiplatform project where mocking is hard
Of course I can test
HttpClient
with
MockEngine
and I’m doing it right now (testing if for example on
OK
response there is
Resource.Data
returned), but in for example
Repository
class where I’m using
HttpClient
I would like to easily swap its instance with mocked one