{"id":26872366,"url":"https://github.com/paradisehell/one","last_synced_at":"2025-05-07T09:17:00.096Z","repository":{"id":16622541,"uuid":"435071781","full_name":"ParadiseHell/one","owner":"ParadiseHell","description":"An tool to help developer to use Retrofit elegantly while using kotlinx.coroutines.","archived":false,"fork":false,"pushed_at":"2022-03-13T02:59:24.000Z","size":73,"stargazers_count":34,"open_issues_count":0,"forks_count":6,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-07T09:16:49.260Z","etag":null,"topics":["android","kotlin","kotlin-coroutines","retrofit2"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ParadiseHell.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-12-05T04:20:34.000Z","updated_at":"2024-03-25T02:18:35.000Z","dependencies_parsed_at":"2022-08-07T08:15:29.398Z","dependency_job_id":null,"html_url":"https://github.com/ParadiseHell/one","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ParadiseHell%2Fone","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ParadiseHell%2Fone/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ParadiseHell%2Fone/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ParadiseHell%2Fone/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ParadiseHell","download_url":"https://codeload.github.com/ParadiseHell/one/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252847568,"owners_count":21813461,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","kotlin","kotlin-coroutines","retrofit2"],"created_at":"2025-03-31T08:31:08.590Z","updated_at":"2025-05-07T09:16:59.839Z","avatar_url":"https://github.com/ParadiseHell.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# one\n\nAn tool to help developer to use [Retrofit](https://github.com/square/retrofit)\nelegantly while using [kotlinx.coroutines](https://github.com/Kotlin/kotlinx.coroutines).\n\n## Feature\n1. Transform different data structs to one.\n\t- `{errorCode, data, messsage}`, `{status, data, messsage}` etc to one like `{code, data, message}`.\n2. No try catch needed when call a suspend method.\n\t- try catch has been processed by reproxy interface.\n\n## Example\n\n```kotlin\n// call `proxyRetrofit` after `Retrofit#create`, in this method it will handle\n// exception automatically.\nval service = retrofit.create(WanAndroidService::class.java).proxyRetrofit()\n// test\nservice.test()\n\t.onSuccess { println(\"execute test success ==\u003e $it\") }\n\t.onFailure { println(\"execute test() failure ==\u003e $it\") }\n\t// userInfo\n\t.onFailureThen { service.userInfo() }\n\t?.onSuccess { println(\"execute userInfo success ==\u003e $it\") }\n\t?.onFailure { println(\"execute userInfo() failure ==\u003e $it\") }\n\t// banner\n\t?.onFailureThen { service.banner() }\n\t?.onSuccess { println(\"execute banner() success ==\u003e $it\") }\n\t?.onFailure { println(\"execute banner() failure ==\u003e $it\") }\n```\n\nIs that realy simple and clean without try catch? If so, continuate to read following\nsections.\n\n## Usage\n1. Define a `BaseAPIResult`.\n2. Define a `ThrowableResolver` to handle throwable and return a `BaseAPIRsult`\nwhich contains failure.\n3. Define a `ResponseThransformer` to transfrom different response data struct\nto the same response data struct.\n4. Add `TansformConverterFactory` to `Retrofit` Converter.Factory list at first.\n5. Call `proxyRetrofit` after calling `Retrofit#create`.\n\nRead [OneTest](https://github.com/ParadiseHell/one/blob/main/src/test/kotlin/org/paradisehell/one/OneTest.kt)\nto understand details.\n\n## About the one\nWhy the repository is named **one**, just because I cannot figure how to name it.\n\nLicense\n=======\n\n    Copyright 2021 ParadiseHell.\n\n    Licensed under the Apache License, Version 2.0 (the \"License\");\n    you may not use this file except in compliance with the License.\n    You may obtain a copy of the License at\n\n       http://www.apache.org/licenses/LICENSE-2.0\n\n    Unless required by applicable law or agreed to in writing, software\n    distributed under the License is distributed on an \"AS IS\" BASIS,\n    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n    See the License for the specific language governing permissions and\n    limitations under the License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fparadisehell%2Fone","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fparadisehell%2Fone","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fparadisehell%2Fone/lists"}