Latest 0.1.3
Homepage https://github.com/fahadHyder/Swift_NetworkEngine
License MIT
Platforms ios 10.0
Dependencies SwiftyJSON, Alamofire
Authors

NetworkEngine

NetworkEngine will help you to make API call easily with out the overhead of writing tons of boilerplate codes. Currently it has dependency with two awesome frameworks SwiftyJSON and Alamofire, but in future we will re-write the engine in such a way that, there won’t be any hardcoded dependency.

Quick Start

In your [Podfile]:

use_frameworks!

target "Change Me!" do
  pod "NetworkMediator"
end

NetworkEngine support Xcode 8.3, 9.0, 9.1, 9.2 and 9.3; Swift 3.1,
3.2, 3.3, 4.0 and 4.1.

Getting Started

Create an Operation which is a subclass of JSONOperation and provide a ResponseModel which conform to Codable protocol.

public class StartWarsOperation: JSONOperation<StarWarsCharacterResponseModel> {
    public override init() {
        super.init()
        self.request = Request(method: .get, endpoint: "/people", params: nil, fields: nil, body: nil)
    }
}

Response model will look like,

public struct StarWarsCharacterResponseModel:Codable {
    let next: String
    let characters: [JediProfile]

    private enum CodingKeys: String,CodingKey {
        case next
        case characters = "results"
    }
}

Finaly, create a ServiceConfig and Service to make API call.

//You could configure your own service instance with different config setup.
let serviceConfig = ServiceConfig(name: "StarWars", base: "https://swapi.co/api")
let service = Service(configuration: serviceConfig!)
StartWarsOperation().execute(in: service) { [weak self] (startWarsResponse, resultType) in
    self?.jdProfiles = startWarsResponse?.characters
    DispatchQueue.main.async {
         completion(true)
    }
}

For more details please check Example

Latest podspec

{
    "name": "NetworkMediator",
    "version": "0.1.3",
    "summary": "NetworkMediator will help you to make Api calls with out writing tons of boilerplate code.",
    "description": "NetworkMediator will help you to make Api calls with out writing tons of boilerplate code!.The current release has a dependency with Alamofire which will be removed in future so that you could add normal NSURLSession or any other dependency in the lowest abstarction.",
    "homepage": "https://github.com/fahadHyder/Swift_NetworkEngine",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Fahad C H": "[email protected]"
    },
    "source": {
        "git": "https://github.com/fahadHyder/Swift_NetworkEngine.git",
        "tag": "0.1.3"
    },
    "platforms": {
        "ios": "10.0"
    },
    "source_files": "NetworkEngine/*",
    "dependencies": {
        "SwiftyJSON": [],
        "Alamofire": []
    }
}

Pin It on Pinterest

Share This