Skip to content

Releases: haroldadmin/NetworkResponseAdapter

Version 5.0.0

Choose a tag to compare

@haroldadmin haroldadmin released this 06 Mar 05:11
7321aef

A new stable release for your favourite Retrofit call adapter. v5 is a culmination of a lot of community contributions and an overhaul of the internals of the library. It's completely backward compatible for existing users of the library, but the changes are significant enough to warrant a major version update.

Upgrade Guide: https://haroldadmin.github.io/NetworkResponseAdapter/upgrade-guides/v5/

Changes since v4:

Sealed Interfaces

The NetworkResponse class is now based on sealed interfaces. This allows for more concise when expressions when you don't care about the specific type of the error:

when (networkResponse) {
  is NetworkResponse.Success -> ...
  is NetworkResponse.Error -> ...
}

Raw Retrofit Responses

NetworkResponse.Success, NetworkResponse.ServerError and NetworkResponse.UnknownError now bundle the raw retrofit Response<S> object to allow for greater access to the response of the network request.

when (networkResponse) {
  is NetworkResponse.Success -> {
    val statusCode = networkResponse.response.code()
  }
}

Handling Empty Response Bodies

In the current version of the library you have to use the Unit response type if you expected your server to respond without a body. This is fine when the API never returns a body, but causes problems if it sometimes returns a body and sometimes doesn't (200 vs 204 status code).

The bundled raw Retrofit responses provide a better way to handle this situation.

interface PostsService {
  @GET("/")
  suspend fun getPost(): NetworkResponse<Unit, ErrorResponse>
}

when (val postResponse  = service.getPost()) {
  is NetworkResponse.Success -> {
    if (postResponse.code != 204) {
      val rawBody = postResponse.response.rawBody()
      // Manually parse the raw body to access the response
    }
  }
  is NetworkResponse.Error -> { ... }
}

Tests Overhaul & Migration to Kotest

This PR gets refactors the library's test suite to get rid of redundant and obscure tests, and replaces them with a streamlined test suite focused on publicly exposed functionality.

We've also finally moved away from the deprecated kotlintest artifacts to the new kotest libraries.

Remove Deprecated Classes

We've removed deprecated ways to instantiate adapter factory. The existing classes had been marked as deprecated for a long period, and I hope everyone has moved away from them.

Kotlin 1.6.0

Updated the language level to 1.6.0

Sample App

Add a module showing sample usage of the library using the kotlinx.serialization library.


Huge thanks to @argenkiwi and @gilgoldzweig for their contributions to this release.

Version 5.0.0-beta01

Choose a tag to compare

@haroldadmin haroldadmin released this 26 Jan 10:23

This release brings the v5 beta for NetworkResponseAdapter!

Changes

  • NetworkResponse.UnknownError now bundles the raw Retrofit response when available
  • Updated documentation site for changes in the v5 release
  • Added upgrade guide to v5 to the docs
  • Added a projects and endorsements page

Version 5.0.0-alpha01

Choose a tag to compare

@haroldadmin haroldadmin released this 16 Dec 18:17

The next version of NetworkResponseAdapter is here! Here's a list of all the changes:

Sealed Interfaces

The NetworkResponse class is now based on sealed interfaces. This allows for more concise when expressions when you don't care about the specific type of the error:

when (networkResponse) {
  is NetworkResponse.Success -> ...
  is NetworkResponse.Error -> ...
}

Raw Retrofit Responses

NetworkResponse.Success and NetworkResponse.ServerError now bundle the raw retrofit Response<S> object to allow for greater access to the response of the network request.

when (networkResponse) {
  is NetworkResponse.Success -> {
    val statusCode = networkResponse.response.code()
  }
}

We still supply code and headers properties as before to retain familiarity with the existing API design.

Handling Empty Response Bodies

In the current version of the library you have to use the Unit response type if you expected your server to respond without a body. This is fine when the API never returns a body, but causes problems if it sometimes returns a body and sometimes doesn't (200 vs 204 status code).

The bundled raw Retrofit responses provide a better way to handle this situation.

interface PostsService {
  @GET("/")
  suspend fun getPost(): NetworkResponse<Unit, ErrorResponse>
}

when (val postResponse  = service.getPost()) {
  is NetworkResponse.Success -> {
    if (postResponse.code != 204) {
      val rawBody = postResponse.response.rawBody()
      // Manually parse the raw body to access the response
    }
  }
  is NetworkResponse.Error -> { ... }
}

Tests Overhaul & Migration to Kotest

This PR gets refactors the library's test suite to get rid of redundant and obscure tests, and replaces them with a streamlined test suite focused on publicly exposed functionality.

We've also finally moved away from the deprecated kotlintest artifacts to the new kotest libraries.

Remove Deprecated Classes

We've removed deprecated ways to instantiate adapter factory. The existing classes had been marked as deprecated for a long period, and I hope everyone has moved away from them.

Kotlin 1.6.0

Updated the language level to 1.6.0

Sample App

Add a module showing sample usage of the library using the kotlinx.serialization library.

Version 4.2.2

Choose a tag to compare

@haroldadmin haroldadmin released this 04 Jul 03:49

New

  • Gracefully handle the case when a service interface method's return type can not be handled by NetworkResponseAdapterFactory

Misc

  • Upgrade to Kotlin 1.5.20 and Gradle 7.1
  • Migrate to Maven publish plugin

Version 4.2.1

Choose a tag to compare

@haroldadmin haroldadmin released this 05 May 17:08

Version 4.2.1

Fixes the Jitpack build issue that plagued v4.2.0.

Version 4.2.0

Choose a tag to compare

@haroldadmin haroldadmin released this 03 May 05:04

Version 4.2.0

This version is not available for download yet

  • Build issues on Jitpack mean that JAR files for v4.2.0 are not available for download yet.
  • Please continue using v4.1.0, or wait for the next release that fixes this problem.**

New

  • Introduce a new generic Error interface for when you don't about the specific type of error in a NetworkResponse (thanks @gilgoldzweig!)
  • Update Kotlin to v1.4.31 and Dokka to v1.4.32
  • Migrate to Pipenv for the documentation website

Version 4.1.0

Choose a tag to compare

@haroldadmin haroldadmin released this 13 Dec 08:48
37f9427

Version 4.1.0

  • Add nullable status code and headers fields to NetworkResponse.UnknownError
  • Update to Kotlin 1.4.21, Coroutines 1.4.2, OkHttp 4.9.0
  • Make kotlin, coroutines, retrofit and okhttp as api dependencies

Version 4.0.1

Choose a tag to compare

@haroldadmin haroldadmin released this 13 May 07:46
58b6a3f

This release adds a couple of new features:

  • A special case of successful responses with empty bodies
    can now be handled by declaring the success type to be Unit
  • NetworkResponse.Success class now contains a field representing
    the response code

Version 3.0.1

Choose a tag to compare

@haroldadmin haroldadmin released this 18 Oct 17:06

Fixes:

  • This release fixes a bug in NetworkResponseCall class, which caused Retrofit's suspending functions to always receive null as the ErrorType.

Version 3.0

Choose a tag to compare

@haroldadmin haroldadmin released this 14 Sep 18:53

This release adds a big new feature to this library: Support for suspending functions in Retrofit's service interfaces!

New:

  • Support for suspending functions
  • Kotlin 1.3.50
  • Coroutines 1.3 stable

Changes:

  • Deprecate CoroutinesNetworkResponseAdapter and CoroutinesNetworkResponseAdapterFactory classes. Replaced with NetworkResponseAdapter and NetworkResponseAdapterFactory. Quickfix suggestion should be available within the IDE.

Huge thanks to @JavierSegoviaCordoba for helping out with this release.