{"id":27811759,"url":"https://github.com/nissaba/easyrestclient","last_synced_at":"2025-05-01T12:02:01.888Z","repository":{"id":290461538,"uuid":"974530470","full_name":"nissaba/EasyRestClient","owner":"nissaba","description":"Lightweight, protocol-oriented Swift framework for easy REST API communication. Supports Codable requests, customizable headers, query parameters, and binary uploads with Swift Package Manager (SPM) support.","archived":false,"fork":false,"pushed_at":"2025-04-29T15:24:25.000Z","size":49,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-29T15:58:51.603Z","etag":null,"topics":["api-client","ios","macos","networking","rest-api","swfit"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nissaba.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-04-28T23:28:40.000Z","updated_at":"2025-04-29T15:24:27.000Z","dependencies_parsed_at":"2025-04-29T15:58:56.895Z","dependency_job_id":null,"html_url":"https://github.com/nissaba/EasyRestClient","commit_stats":null,"previous_names":["nissaba/resteasyapi","nissaba/easyrestclient"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nissaba%2FEasyRestClient","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nissaba%2FEasyRestClient/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nissaba%2FEasyRestClient/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nissaba%2FEasyRestClient/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nissaba","download_url":"https://codeload.github.com/nissaba/EasyRestClient/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251871518,"owners_count":21657466,"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":["api-client","ios","macos","networking","rest-api","swfit"],"created_at":"2025-05-01T12:00:54.027Z","updated_at":"2025-05-01T12:02:01.842Z","avatar_url":"https://github.com/nissaba.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# EazyRestClient\n\n![SwiftPM](https://img.shields.io/badge/SPM-Compatible-brightgreen.svg) ![Platform](https://img.shields.io/badge/platform-iOS%2013%20%7C%20macOS%2010.15%20%7C%20tvOS%2015%20%7C%20watchOS%208-blue) ![Swift](https://img.shields.io/badge/swift-5.9.2-orange.svg) ![Tests](https://github.com/nissaba/EasyRestClient/actions/workflows/tests.yml/badge.svg) ![Release](https://img.shields.io/github/v/release/nissaba/EasyRestClient)\n\n## Features\n\n- Protocol-based requests with `EazyRestRequest`\n- Codable support for automatic encoding/decoding\n- Default headers (`Accept` \u0026 `Content-Type`)\n- Optional authorization token\n- Query parameters and body data support\n- URLSession under the hood\n- Callback and Swift Concurrency (`async/await`) APIs\n\n## Installation\n\nAdd to your `Package.swift`:\n\n```swift\n.package(url: \"https://github.com/nissaba/EasyRestClient.git\", from: \"1.1.0\")\n```\n\n## Usage\n\n### 1. Initialize the Client\n\n```swift\nimport EazyRestClient\n\nlet client = EazyRestClient(baseURL: \"https://api.example.com/\")\n// Optional authorization\nclient.authToken = \"Bearer \u003ctoken\u003e\"\n```\n\n### 2. Define a Request\n\n```swift\nstruct MyRequest: EazyRestRequest {\n    typealias Response = MyResponseModel\n\n    var httpMethod: HTTPMethods { .get }\n    var resourceName: String { \"endpoint\" }\n    // Optionally override queryItems or bodyData\n}\n```\n\n### 3. Callback-based Response Handling\n\n```swift\nclient.send(MyRequest()) { result in\n    switch result {\n    case .success(let response):\n        print(response)\n    case .failure(let error):\n        print(\"Error: \\(error.localizedDescription)\")\n    }\n}\n```\n\n### Or Async/Await Response Handling\n\n```swift\n// Requires iOS 15.0+, macOS 12.0+, tvOS 15.0+, watchOS 8.0+, visionOS 1.0+\nTask {\n    do {\n        let response = try await client.send(MyRequest())\n        print(response)\n    } catch {\n        print(\"Error: \\(error.localizedDescription)\")\n    }\n}\n```\n\n## Custom and Default Headers\n\nBy default, all requests include these HTTP headers:\n\n```http\nAccept: application/json\nContent-Type: application/json\n```\n\nOverride in a specific request if needed:\n\n```swift\npublic extension MyCustomRequest: EazyRestRequest {\n    var headers: [String: String]? {\n        [\n            \"Accept\": \"application/json\",\n            \"Authorization\": \"Bearer \\(token)\"\n        ]\n    }\n}\n```\n\n## Example App\n\nAn **ExampleApp** demonstrating both callback and async/await usage is located in the `Examples/` folder. Open `ExampleApp.xcodeproj` and run on your device or simulator.\n\n## License\n\nMIT License. © 2025 Pascale Beaulac\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnissaba%2Feasyrestclient","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnissaba%2Feasyrestclient","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnissaba%2Feasyrestclient/lists"}