PocketSwift / PocketNet

Elegant net framework in Swift 5.0

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PocketNet

CocoaPods Compatible License

PocketNet

Elegant net abstraction layer written in Swift 5.0, we provide an integration with Alamofire.

Requirements

  • iOS 8.0+

Installation

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:

$ gem install cocoapods

CocoaPods 1.1+ is required to build PocketNet 2.4.0

To integrate PocketNet into your Xcode project using CocoaPods, specify it in your Podfile:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!

target '<Your Target Name>' do
    pod 'PocketNet'
end

Then, run the following command:

$ pod install

Usage

import PocketNet

let net: PocketNet = PocketNetAlamofire() /*or for SSL Pinning*/ PocketNetAlamofire(pinningSSLCertURL: Bundle.main.url(forResource: "cert", withExtension: "crt"), domain: "urlDomain")
    
let netSupport = NetSupport(net: net)

let request = NetRequest.Builder()
            	.method(.post)
                .url("url")
                .requestHeader([:])
                .parameterEncoding(.json)
                .body(params: "")
                .shouldCache(false)
                .build()

netSupport.netJsonMappableRequest(request, completion: {(result: Result<DecodableObject, Error>) in
	switch result {
	case .success(let decodableObject):
		/// do something with decodableObject
	case .failure(let error):
	    /// do something with error
	}
})

netSupport.netArrayJsonMappableRequest(request, completion: {(result: Result<[DecodableObject], Error>) in
    switch result {
    case .success(let decodableObject):
        /// do something with decodableObject
    case .failure(let error):
        /// do something with error
    }
})

Authors

Special thanks

Libraries used in this project

License

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

About

Elegant net framework in Swift 5.0

License:MIT License


Languages

Language:Swift 99.7%Language:Ruby 0.2%Language:Objective-C 0.1%