4 "summary": "RESTful web service consumer for iOS (Swift) with builder.",
5 "description": "Features\n- Builder pattern\n- Auto encode param and form url encoded body\n- Support synchronous or asynchronous operation\n- Support progress observer\n- Support HandyJSON object\n\nRequirements\n\n- Swift 3.2 or higher\n\nUsage Example\n\n- Synchronous\nBuild the object using HttpRequestBuilder and then execute\n\nCode :\n//HttpGet\nlet getResponse : Response? = EatrRequestBuilder.httpGet.set(url : \"http://your.url.here\")\n.addHeader(withKey : \"SOME-HEADER\", andValue : \"header_value\")\n.addParam(withKey : \"param_key\", andValue : \"param_value\")\n.awaitExecute()\n\nif let response : EatrResponse = getResponse {\n let rawResponse : URLResponse? = response.rawResponse\n let isSuccess : Bool = response.isSuccess\n let isError : Bool = response.isError\n let statusCode : Int? = response.statusCode\n let body : Data? = response.rawBody\n let strBody : String? = response.bodyAsString\n let jsonBody : [String : Any?] = response.bodyAsJson\n let arrJsonBody : [Any?] = response.bodyAsJsonArray\n let parsedBody : YourHandyJSONObj = response.parsedBody()\n let parsedArray : [YourHandyJSONObj?] = response.parsedArrayBody\n}\n\n//HttpPost with Json body\nlet postJsonResponse : Response? = EatrRequestBuilder.httpPost.set(url : \"http://your.url.here\")\n.addHeader(withKey : \"SOME-HEADER\", andValue : \"header_value\")\n.addParam(withKey : \"param_key\", andValue : \"param_value\")\n.set(jsonBody : jsonDictionary).awaitExecute()\n\n\n\nYou can use raw body, form data, string, HandyJSON Object or any JSON Object for request body\n\n- Simple Asynchronous\nEverything is same like synchronous, but you need to pass consumer function into the execute method\nRemember, response inside closure will be null if reaching timeout\n\nCode:\n//Basic\nEatrRequestBuilder.httpGet.set(url : \"http://your.url.here\")\n .addHeader(withKey : \"SOME-HEADER\", andValue : \"header_value\")\n .addParam(withKey : \"param_key\", andValue : \"param_value\")\n .asyncExecute(onFinished : { response : Response? in\n //YOUR CODE HERE\n // WILL BE EXECUTE AFTER REQUEST IS FINISHED\n })\n\n\n- Advanced Asynchronous/Synchronous\n Same like any async http request, but you can set your consumer separately. you can set 5 closure consumer:\n - onProgress which will run for every progress, it will give the progress in float start from 0.0f to 1.0f\n Because this method will called periodically, its better if you're not put object creation inside this method\n - onBeforeSending which will run before sending\n - onResponded which will **ONLY** run when you get response\n - onTimeout which will **ONLY** run when you get no response after timeout\n - onException which will **ONLY** run when you get unhandled exception\n - onFinished which will run after all request is complete\n \n You don't need to set all of the consumer. just the one you need.\n \n Remember, response inside closure will be null if reaching timeout\n \n Code:\n //with onFinished closure\n EatrRequestBuilder.httpGet.set(url : \"http://your.url.here\")\n .addHeader(withKey : \"SOME-HEADER\", andValue : \"header_value\")\n .addParam(withKey : \"param_key\", andValue : \"param_value\")\n .set(onTimeout : {\n //YOUR CODE HERE\n })\n .set(onBeforeSending : { (session : URLSession) -> URLSession in\n //YOUR CODE HERE\n })\n .set(onError : { error : Error in\n //YOUR CODE HERE\n })\n .set(onProgress : { progress : Float in\n //YOUR CODE HERE\n })\n .set(onResponded : { response : Response in\n //YOUR CODE HERE\n })\n .asyncExecute()\n \n //you can even do it synchronously and all your closure will be executed synchronously\n let response : Response? = EatrRequestBuilder.httpGet.set(url : \"http://your.url.here\")\n .addHeader(withKey : \"SOME-HEADER\", andValue : \"header_value\")\n .addParam(withKey : \"param_key\", andValue : \"param_value\")\n .set(onTimeout : {\n //YOUR CODE HERE\n })\n .set(onBeforeSending : { (session : URLSession) -> URLSession in\n //YOUR CODE HERE\n })\n .set(onError : { error : Error in\n //YOUR CODE HERE\n })\n .set(onProgress : { progress : Float in\n //YOUR CODE HERE\n })\n .set(onResponded : { response : Response in\n //YOUR CODE HERE\n })\n .awaitExecute()\n \n- Using Delegate\n If you prefer using delegate, there is delegate protocol for you to use which is EatrDelegate with available method :\n - eatrOnBeforeSending(_ sessionToSend : URLSession) -> URLSession\n - eatrOnTimeout()\n - eatrOnError(_ error: Error)\n - eatrOnProgress(_ progress: Float)\n - eatrOnResponded(_ response: EatrResponse)\n - eatrOnFinished()\n \n All method are optional, use the one you need\n \n Code:\n EatrRequestBuilder.httpGet.set(url : \"http://your.url.here\")\n .addHeader(withKey : \"SOME-HEADER\", andValue : \"header_value\")\n .addParam(withKey : \"param_key\", andValue : \"param_value\")\n .set(delegate : self)\n .asyncExecute()",
6 "homepage": "https://github.com/nayanda1/iOSEatr",
12 "nayanda1": "nayanda1@outlook.com"
15 "git": "https://github.com/nayanda1/iOSEatr.git",
21 "source_files": "Eatr/Classes/**/*",
27 "deprecated_in_favor_of": "iONess",
28 "swift_version": "4.2"