{"id":1664,"url":"https://github.com/rogermolas/RMHttp","last_synced_at":"2025-08-02T04:32:09.914Z","repository":{"id":62452070,"uuid":"125799182","full_name":"rogermolas/RMHttp","owner":"rogermolas","description":"Lightweight REST library for iOS and watchOS. Available on cococapods","archived":false,"fork":false,"pushed_at":"2020-10-20T18:11:47.000Z","size":297,"stargazers_count":7,"open_issues_count":1,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-07-02T23:48:58.559Z","etag":null,"topics":["ios","json","json-parser","rest","swift","swift4","watchos"],"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/rogermolas.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-03-19T03:58:14.000Z","updated_at":"2022-11-19T20:57:25.000Z","dependencies_parsed_at":"2022-11-01T23:45:37.751Z","dependency_job_id":null,"html_url":"https://github.com/rogermolas/RMHttp","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"purl":"pkg:github/rogermolas/RMHttp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rogermolas%2FRMHttp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rogermolas%2FRMHttp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rogermolas%2FRMHttp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rogermolas%2FRMHttp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rogermolas","download_url":"https://codeload.github.com/rogermolas/RMHttp/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rogermolas%2FRMHttp/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268334615,"owners_count":24233793,"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","status":"online","status_checked_at":"2025-08-02T02:00:12.353Z","response_time":74,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["ios","json","json-parser","rest","swift","swift4","watchos"],"created_at":"2024-01-05T20:15:52.733Z","updated_at":"2025-08-02T04:32:09.555Z","avatar_url":"https://github.com/rogermolas.png","language":"Swift","funding_links":[],"categories":["Networking"],"sub_categories":["Video"],"readme":"# RMHttp\n\n[![Build Status](https://travis-ci.org/rogermolas/RMHttp.svg?branch=master)](https://travis-ci.org/rogermolas/RMHttp)\n![Status](https://img.shields.io/badge/status-active-brightgreen.svg?style=flat)\n[![license](https://img.shields.io/github/license/mashape/apistatus.svg?maxAge=2592000)](https://github.com/rogermolas/RMHttp/blob/master/LICENSE)\n[![Platform](https://img.shields.io/cocoapods/p/RMHttp.svg?style=flat)](https://cocoapods.org/pods/RMHttp)\n[![Version](https://img.shields.io/cocoapods/v/RMHttp.svg?style=flat)](https://cocoapods.org/pods/RMHttp)\n[![Twitter](https://img.shields.io/badge/twitter-roger__molas-yellowgreen.svg)](https://www.twitter.com/roger_molas)\n\n![RMHttp Lightweight RESTful library for iOS and watchOS](https://raw.githubusercontent.com/rogermolas/RMHttp/master/Example/Demo/Assets.xcassets/RMHttp.imageset/RMHttp.png)\nRMHttp is a Lightweight REST library for iOS and watchOS.\n\n## Features\n\n- [x]  Chainable Request\n- [x]  URL / JSON  Parameter Encoding\n- [x]  HTTP Methods GET/POST/DELETE/PATCH/PUT based in  [RFC2616](https://tools.ietf.org/html/rfc2616#section-5.1.1)\n- [x]  Custom Request Builder / HEADERS / PARAMETERS\n- [x]  Form-Data Support\n- [x]  Dynamic Response Handler (JSONObject, JSONArray, String)\n- [x] Codable Support\n- [x] Support Parameters Container `RMParams`\n\n##### TODO:\n- [-] Support Upload/Download resource\n\n\n## Example\n\nTo run the example project, clone the repo, and run `pod install` from the Example directory first.\n\n## Installation\n\nRMHttp is available through [CocoaPods](https://cocoapods.org). To install\nit, simply add the following line to your Podfile:\n\n```ruby\npod 'RMHttp'\n```\n\n## Installation\n```ruby\npod \"RMHttp\"\n```\n\nRun the following command in your Terminal\n```bash\n$ pod install\n```\n\n## Usage\n\n##### HTTP Methods\nHTTP Methods are declared in public enum `RMHttpMethod`.\n\n`GET`, `POST` , `DELETE` , `PUT` , `PATCH`\n\n##### Parameter Encoding\nEncoding are declared in public enum `Encoding`\n\n`URLEncoding`\n`JSONEncoding`\n\n##### Serialization\n`JSONObject` - a representation of `Dictionary\u003cString, Any\u003e`\n```swift\n{\n   \"data\" : \"value\",\n   \"isBoolean\" : true,\n   \"list\": [\n      \"object1\",\n      \"object2\"\n   ]\n}\n```\n\n`JSONArray` - a representation of `[Dictionary\u003cString, Any\u003e]`\n\n```swift\n[\n   { \"data1\" : \"value1\"},\n   { \"data2\" : \"value2\"},\n   { \"data3\" : \"value3\"},\n]\n```\n\n`String`\nAny String respresentation (e.g HTML String, XML String, Plain Text)\n\n### Building Request\n##### Building request with parameters from Dictionary type\n```swift\nlet params = [\n   \"string\":\"Ipsum\",   // String\n   \"number\": 100,      // Number\n   \"boolean\":true      // Boolean\n] as [String : Any]\n\nlet urlString = \"https://httpbin.org/get\"\nlet request = RMRequest(urlString, method: .GET(.URLEncoding), parameters: params, hearders: nil)\n```\n\n##### Building request with parameters from `RMParams` container\nURL query representation `names[]=lorem\u0026names[]=ipsum\u0026names[]=dolor\u0026`\n```swift\nlet lorem = RMParams(key: \"names[]\", value: \"lorem\")\nlet ipsum = RMParams(key: \"names[]\", value: \"ipsum\")\nlet dolor = RMParams(key: \"names[]\", value: \"dolor\")\nlet params = [lorem, ipsum, dolor]\n\nlet urlString = \"https://httpbin.org/post\"\nrequest = RMRequest(urlString, .GET(.URLEncoding), params, nil)\nreturn request\n```\n\n### Chained Response Handlers\n##### Expecting Array object Response\n```swift\nRMHttp.JSON(request: request) { (response:JSONArray?, error) in\n   guard error == nil else {\n      self.title = \"Response Error\"\n\t  self.activity.stopAnimating()\n\t  self.textView.text = \"\\(err)\"\n\t  return\n   }\n   self.activity.stopAnimating()\n   if let data = response {\n      self.title = \"Response Sucess\"\n      self.textView.text = \"\\(data)\"\n   }\n}\n```\n\n##### Expecting JSON object Response\n```swift\nRMHttp.JSON(request: request) { (response:JSONObject?, error) in\n   guard error == nil else {\n      self.title = \"Response Error\"\n\t  self.activity.stopAnimating()\n\t  self.textView.text = \"\\(err)\"\n\t  return\n   }\n   self.activity.stopAnimating()\n   if let data = response {\n      self.title = \"Response Sucess\"\n\t  self.textView.text = \"\\(data)\"\n   }\n}\n```\n\nGeneric method that return HTTP response has parameter  `data`  that comply to `RMHttpProtocol` (e.g JSONObject, JSONArray,  String, )\n```swift\npublic class func JSON\u003cT:RMHttpProtocol\u003e(request: RMRequest, completionHandler: @escaping Handler\u003cT\u003e)\n```\n\n### FORM-DATA\n\n##### Add fields from dictionary type\n```swift\nlet params =  [\n   \"name\":\"lorem\", \n   \"lastName\":\"ipsum\"\n]\nlet urlString = \"https://httpbin.org/post\"\nlet request = RMRequest(urlString, .POST(.FomDataEncoding), params, nil)\nreturn request\n```\n\n##### Add file\nSee [Media Types](https://www.iana.org/assignments/media-types/media-types.xhtml)\n```swift\nlet request = RMRequest(url: URL(string: urlString)!)\nrequest.addForm(field: \"file\", file: imgData, fileName: \"image.jpeg\", mimeType: \"image/jpeg\")\nrequest.setHttp(method: .POST(.FomDataEncoding))\nreturn request\n```\n\n##### Or manually add field\n```swift\nlet request = RMRequest(url: URL(string: urlString)!)\nrequest.addForm(fieldName: \"field1\", value: \"lorem ipsum\")\nrequest.addForm(fieldName: \"field2\", value: \"sit dolor amet\")\n```\n## Author\n\nrogermolas, contact@rogermolas.com\n\n## License\n\n\nThe MIT License (MIT)\n\nCopyright (c) 2018-2020 Roger Molas\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frogermolas%2FRMHttp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frogermolas%2FRMHttp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frogermolas%2FRMHttp/lists"}