CocoaPods trunk is moving to be read-only. Read more on the blog, there are 18 months to go.

NAlamofire 2.0.17

NAlamofire 2.0.17

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Feb 2017
SwiftSwift Version 3.0
SPMSupports SPM

Maintained by Nguyen Phu Nghia.



 
Depends on:
NRxSwift>= 0
Alamofire>= 0
SwiftyJSON>= 0
ObjectMapper>= 0
NLogProtocol>= 0
 

NAlamofire 2.0.17

  • By
  • Nghia Nguyen

NAlamofire

NAlamofire - the easy way to convert directly the request to object, array objects via RxSwift in a few lines code. It is wrapper of Alamofire.

Referenced libs : 1. ObjectMapper 2. NRxSwift 3. SwiftyJSON 4. NLogProtocol

INSTALLATION

Pod

use_frameworks!
pod 'NAlamofire'

USAGE

import ObjectMapper
import NAlamofire

//Object must be conformed to Mappable or NKMappable.
struct Item: Mappable {
    private enum Key: String, NKAlamofireKey {
        case id, name
    }

    var id: Int = 0
    var name: String = ""

    init?(_ map: Map) {}

    mutating func mapping(map: Map) {
        id <- map[Key.id]
        name <- map[Key.name]
    }
}

//create API client
let apiClient = NKApiClient(host: "https://server.com")

// create items observable
let itemsObservable: Observable[Item]> = apiClient.get("items")

//subscrible observables to get objects
itemsObservable.subscrible(onNext: { items in
})

NKApiClient

This is wrapper of Alamofire Manager to help you make a request easier (get/post/put/delete). Support multipart/formdata type.

Public apis:

    public func setDefaultHeader(key:value:)
    public func removeDefaultHeader(key:)
    public func extraUserAgent()
    open func bussinessErrorFromResponse(_:) // override to customize bussinessError. See also at NKNetworkErrorType.
Subscribe notification name NKApiClient.kUnauthorizedNotificationName to handle unauthorization case.

Print request and response data

    import NLogProtocol

    struct CustomNLog: NLogProtocol {//See apis at NLogProtocol}

    NKLOG = CustomNLog.self

Thanks @khoinguyenvu and @trinhngocthuyen for your constribution.