1.2.0
馃オ Released a new version 1.2.0! 馃オ
You can check the migration codes here Pokedex(#35).
What's New?
Now the data property is a non-nullable type
The data property in the ApiResponse.Success is non-nullable from this release.
Previously, the data property in the ApiResponse would be null-able if the response has been succeeded but there is an empty-body response regardless of the status code. It will throw NoContentException if we try to access the data property for the 204 and 205 cases (succeeded but empty body). Thanks, @jakoss for discussing this (#20).
EmptyBodyInterceptor
If we want to bypass the NoContentException and handle it as an empty body response, we can use the EmptyBodyInterceptor. Then we will not get the NoContentException if we try to access the data property for the 204 and 205 response code.
OkHttpClient.Builder()
.addInterceptor(EmptyBodyInterceptor())
.build()create factories
Now we should create the factory classes using the create() method.
.addCallAdapterFactory(CoroutinesResponseCallAdapterFactory.create())getOrElse
We can get the data or default value based on the success or failed response.
Returns the encapsulated data if this instance represents ApiResponse.Success or returns a default value if this is failed.
val data: List<Poster> = disneyService.fetchDisneyPosterList().getOrElse(emptyList())