Latest 0.3.0
Homepage https://github.com/juancruzmdq/NLService
License MIT
Platforms ios 8.0
Dependencies Ono, Alamofire
Authors

[![CI Status](http://img.shields.io/travis/Juan Cruz Ghigliani/NLService.svg?style=flat)](https://travis-ci.org/Juan Cruz Ghigliani/NLService)
Version
License
Platform

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

Installation

NLService is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod "NLService"

Example


The simplest example

let service = NLRemoteService(baseURL: NSURL(string: "https://api.github.com")!, manager:NLAlamofireManager())
let resource = NLRemoteResource<NSDictionary>("/repos/juancruzmdq/NLService")
service.request(resource).load { (dict) in
    switch dict {
    case .Success(let dict):
        print("API Result: (dict)")
        break
    case .Error(let error):
        print("API Error: (error.localizedDescription)")
        break
    }
}

// Build Main Service
let service = NLRemoteService(baseURL: NSURL(string: "https://api.github.com")!, manager: NLAlamofireManager(headers: ["Header-Global":"value global"])) // optional global headers

// Build resource endpoint with parser
let repoInfo = NLRemoteResource<String>("/repos/juancruzmdq/NLService")
repoInfo.headers = ["Header-Repo":"value for repo"]
repoInfo.parser =  = {( result )->ParseResult<String> in
    guard let info = result as? NSDictionary else{
        return .Error(NSError(domain: "ViewController", code: 0, localizedDescription: "Invalid response???"))
    }
    return .Success("(info["id"]!) - (info["name"]!)")
}

// Use service to create request to resource, and perform call (load) of the remote resource
api.request(repoInfo).load { (result) in
    switch result {
    case .Success(let string):
        print("API Result: (string)")
        break
    case .Error(let error):
        print("API Error: (error.localizedDescription)")
        break
    }
}

Author

Juan Cruz Ghigliani, [email protected]

License

NLService is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "NLService",
    "version": "0.3.0",
    "summary": "Network Layer Service.",
    "description": "Simple Networking layer over Alamofire",
    "homepage": "https://github.com/juancruzmdq/NLService",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Juan Cruz Ghigliani": "[email protected]"
    },
    "source": {
        "git": "https://github.com/juancruzmdq/NLService.git",
        "tag": "0.3.0"
    },
    "social_media_url": "https://twitter.com/juancruzmdq",
    "platforms": {
        "ios": "8.0"
    },
    "source_files": "NLService/Classes/**/*",
    "dependencies": {
        "Ono": [],
        "Alamofire": []
    }
}

Pin It on Pinterest

Share This