Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/haroldadmin/networkresponseadapter
Retrofit call adapter to model success/failed responses as sealed types
https://github.com/haroldadmin/networkresponseadapter
kotlin kotlin-coroutines kotlin-test retrofit
Last synced: 5 days ago
JSON representation
Retrofit call adapter to model success/failed responses as sealed types
- Host: GitHub
- URL: https://github.com/haroldadmin/networkresponseadapter
- Owner: haroldadmin
- License: apache-2.0
- Created: 2019-04-26T18:13:27.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2024-04-17T07:28:17.000Z (7 months ago)
- Last Synced: 2024-10-18T20:36:47.420Z (18 days ago)
- Topics: kotlin, kotlin-coroutines, kotlin-test, retrofit
- Language: Kotlin
- Homepage: https://haroldadmin.github.io/NetworkResponseAdapter
- Size: 1.23 MB
- Stars: 562
- Watchers: 6
- Forks: 61
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# NetworkResponse Retrofit adapter
[![Build Status](https://github.com/haroldadmin/networkresponseadapter/workflows/CI/badge.svg)](https://github.com/haroldadmin/networkresponseadapter/actions)
This library provides a Kotlin Coroutines based Retrofit call adapter for wrapping your API responses in
a `NetworkResponse` sealed type.## Documentation
[**https://haroldadmin.github.io/NetworkResponseAdapter**](https://haroldadmin.github.io/NetworkResponseAdapter)
## Network Response
`NetworkResponse` is a Kotlin sealed interface with the following states:
- `Success`: Represents successful network calls (2xx response codes)
- `Error`: Represents unsuccessful network calls
- `ServerError`: Server errors (non 2xx responses)
- `NetworkError`: IO Errors, connectivity problems
- `UnknownError`: Any other errors, like serialization exceptionsIt is generic on two types: a success response (`S`), and an error response (`E`).
- `S`: Kotlin representation of a successful API response
- `E`: Representation of an unsuccessful API responseFind complete documentation at [**https://haroldadmin.github.io/NetworkResponseAdapter**](https://haroldadmin.github.io/NetworkResponseAdapter).
## Installation
Add the Jitpack repository to your list of repositories:
```groovy
allprojects {
repositories {
maven { url 'https://jitpack.io' }
}
}
```And then add the dependency in your gradle file:
```groovy
dependencies {
implementation "com.github.haroldadmin:NetworkResponseAdapter:(latest-version)"
}
```[![Release](https://jitpack.io/v/haroldadmin/NetworkResponseAdapter.svg)](https://jitpack.io/#haroldadmin/NetworkResponseAdapter)
## License
```text
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License athttp://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
```