{"id":22612343,"url":"https://github.com/utsavdotpro/connectionlibrary","last_synced_at":"2026-04-28T22:32:25.102Z","repository":{"id":42202339,"uuid":"454528446","full_name":"utsavdotpro/ConnectionLibrary","owner":"utsavdotpro","description":"HTTP connection library with offline support for Android","archived":false,"fork":false,"pushed_at":"2022-04-10T18:08:11.000Z","size":203,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-28T23:46:11.877Z","etag":null,"topics":["android","connection-lib","http-request","kotlin","rest"],"latest_commit_sha":null,"homepage":"https://jitpack.io/#utsavdotpro/ConnectionLibrary","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/utsavdotpro.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-02-01T19:48:15.000Z","updated_at":"2022-03-12T13:51:16.000Z","dependencies_parsed_at":"2022-08-12T09:11:18.302Z","dependency_job_id":null,"html_url":"https://github.com/utsavdotpro/ConnectionLibrary","commit_stats":null,"previous_names":[],"tags_count":22,"template":false,"template_full_name":null,"purl":"pkg:github/utsavdotpro/ConnectionLibrary","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/utsavdotpro%2FConnectionLibrary","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/utsavdotpro%2FConnectionLibrary/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/utsavdotpro%2FConnectionLibrary/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/utsavdotpro%2FConnectionLibrary/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/utsavdotpro","download_url":"https://codeload.github.com/utsavdotpro/ConnectionLibrary/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/utsavdotpro%2FConnectionLibrary/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32402666,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-28T19:38:08.556Z","status":"ssl_error","status_checked_at":"2026-04-28T19:37:55.688Z","response_time":56,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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","connection-lib","http-request","kotlin","rest"],"created_at":"2024-12-08T17:12:23.042Z","updated_at":"2026-04-28T22:32:25.079Z","avatar_url":"https://github.com/utsavdotpro.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![](https://jitpack.io/v/u-barnwal/ConnectionLibrary.svg)](https://jitpack.io/#u-barnwal/ConnectionLibrary)\n# ConnectionLibrary\nHTTP connection library to consume REST APIs in structured way with automatic support for offline data.\n\n## Implementation\n**Step 1:** Add to project level build.gradle\n```gradle\nallprojects {\n\trepositories {\n\t\t...\n\t\tmaven { url 'https://jitpack.io' }\n\t}\n}\n```\n\n**Step 2:** Add to app level build.gradle\n\n```gradle\ndependencies {\n\timplementation 'com.github.utsavdotpro:ConnectionLibrary:VERSION'\n}\n```\n\n## How to use?\n\n### Create Helper Class\nYou need to create a helper class that configures the **Connection** and provides callbacks for all events.\n\u003cdetails\u003e\n  \u003csummary\u003eExpand: \u003ckbd\u003eConnectionHelper.kt\u003c/kbd\u003e\u003c/summary\u003e\n  \n```kotlin\nimport android.content.Context\nimport com.isolpro.library.connection.Connection\n\nclass ConnectionHelper\u003cT\u003e(private val ctx: Context, private val classType: Class\u003cT\u003e) : Connection\u003cT\u003e() {\n\toverride var config: Config = Config(\"API_BASE_ENDPOINT\")\n\n\toverride fun getContext(): Context {\n\t\treturn ctx;\n\t}\n\n\toverride fun showLoader() {\n\t\tTODO(\"Write your function for showing loader\")\n\t}\n\n\toverride fun hideLoader() {\n\t\tTODO(\"Write your function for hiding loader\")\n\t}\n\n\toverride fun handleOnRequestCreated(endpoint: String, data: Any?) {\n\t\tTODO(\"Access the request endpoint and data\")\n\t}\n\n\toverride fun handleOnResponseReceived(data: String?) {\n\t\tTODO(\"This is triggered everytime your receive a response, implement your logger\")\n\t}\n\n\toverride fun handleOnNoResponseError() {\n\t\tTODO(\"Handle when nothing is received as response\")\n\t}\n\n\toverride fun handleOnOfflineDataUnsupported() {\n\t\tTODO(\"Handle when the request made, doesn't store offline data\")\n\t}\n\n\toverride fun handleOnOfflineDataUnavailable() {\n\t\tTODO(\"Handle when the request made, store offline data but doesn't have anything cache yet\")\n\t}\n\n\toverride fun handleOnError(e: Exception) {\n\t\tTODO(\"Handle all other errors\")\n\t}\n\n\toverride fun getClassType(): Class\u003cT\u003e {\n\t\treturn classType;\n\t}\n}\n```\n\u003c/details\u003e\n\n### Create Models\nWhile you are free to structure your requests in any way you like, we suggest to create **model* classes* for all your data.\n\n\u003cdetails\u003e\n  \u003csummary\u003eExpand Example Model\u003c/summary\u003e\n  \n```kotlin\nclass Post {\n\tval userId: Number = 0;\n\tval id: Number = 0;\n\tval title: String = \"\";\n\tval body: String = \"\";\n}\n```\n\u003c/details\u003e\n\n### Create Services\nWe also suggest to create service class with all request functions required for the data model.\n\n\u003cdetails\u003e\n  \u003csummary\u003eExpand Example Service\u003c/summary\u003e\n\n```kotlin\nobject PostService {\n\n\tfun getPosts(ctx: Context): Connection\u003cPost\u003e {\n\t\treturn ConnectionHelper(ctx, Post::class.java)\n\t\t\t.endpoint(\"/posts\")\n\t\t\t.loader(false)\n\t}\n\n\tfun createPost(ctx: Context, post: Post): Connection\u003cPost\u003e {\n\t\treturn ConnectionHelper(ctx, Post::class.java)\n\t\t\t.payload(post)\n\t\t\t.endpoint(\"/posts/insert\")\n\t\t\t.loader(false)\n\t}\n\n}\n```\n\u003c/details\u003e\n\n### Making the Request\nOnce you have created your models and services, making a request is a piece of cake\n\n- Simple Request\n\t```kotlin\n\tPostService.getPosts(this)\n\t\t.post()\n\t```\n\n- Request with Callbacks\n\t```kotlin\n\tPostService.getPosts(this)\n\t\t.success {\n\t\t\tTODO(\"Use your data from $it\")\n\t\t\t// use $it.userId to get userId from Post \n\t\t}\n\t\t.failure {\n\t\t\tTODO(\"Let user know that the request has failed\")\n\t\t}\n\t\t.post()\n\t\t}\n\t```\n\nAnd you're done ✅\n\n## Enable Offline Mode\n\nTo make a request to start caching data for offline usage, just pass a unique `offlineEndpoint` . **Not to be used with data creation/modification requests**.\n\n### When fetching a list of items\n```kotlin\nConnectionHelper(ctx, Post::class.java)\n\t.payload(post)\n\t.endpoint(\"/posts\")\n\t.offlineEndpoint(\"posts\")\n\t.loader(false)\n```\n\n### When fetching a single item (*pass the unique item it as second parameter*)\n```kotlin\nConnectionHelper(ctx, Post::class.java)\n\t.payload(post)\n\t.endpoint(\"/posts/$postId\")\n\t.offlineEndpoint(\"posts\", postId)\n\t.loader(false)\n```\n\n### Recommended attributes for `offlineEndpoint`\n- should be unique\n- avoid using any symbols\n- cannot be empty (empty indicates that request doesn't support offline mode)\n\n\nAnd you're done ✅\n\n\n| **See [sample app](\"./app/src/main\")**\n\n## Features\n\n - Easy to use\n - Easy to customize \u0026 configure\n - Automated offline mode\n - Simple file structure: Create *models* \u0026 *services*\n - Syntax similar to modern programming notions","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Futsavdotpro%2Fconnectionlibrary","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Futsavdotpro%2Fconnectionlibrary","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Futsavdotpro%2Fconnectionlibrary/lists"}