Go to file
Shial a3f000a541
Merge pull request #1 from shial4/Release-0.1.0
Release 0.1.0
2017-12-27 14:51:20 +11:00
SLazeKit.xcodeproj [0.1.0] Example model class 2017-12-27 14:16:29 +11:00
Sources/SLazeKit [0.1.0] Add documentation 2017-12-27 14:44:10 +11:00
Tests [0.1.0] Example model class 2017-12-27 14:16:29 +11:00
.gitignore Initial Commit 2017-12-12 17:03:04 +11:00
.swift-version Initial Commit 2017-12-12 17:03:04 +11:00
LICENSE Initial Commit 2017-12-12 17:03:04 +11:00
Package.swift Initial Commit 2017-12-12 17:03:04 +11:00
README.md [0.1.0] Add documentation 2017-12-27 14:44:10 +11:00
SLazeKit.podspec Initial Commit 2017-12-12 17:03:04 +11:00

README.md

SLazeKit

Language License CocoaPods Carthage

SLazeKit is an easy to use Swift restful collection of extensions and classes. Don't spend hours writing your code to map your rest api request into models and coredata serialization. Stop wasting your time!

SLazeKit allows you:

  • map your models by Codable protocol
  • serialize CoreData models from API response
  • fast and simple extend your models with API & CoreData

🔧 Installation

CocoaPods:

Add the line pod "SLazeKit" to your Podfile

Carthage:

Add the line github "shial4/SLazeKit" to your Cartfile

Manual:

Clone the repo and drag the folder SLazeKit into your Xcode project.

Swift Package Manager:

Add the line .package(url: "https://github.com/shial4/SLazeKit.git", from: "0.1.0"), to your Package.swift

Swift Package Manager in your iOS Project: This project demonstrates a working method for using Swift Package Manager (SPM) to manage the dependencies of an iOS project.

Example of how to use SPM v4 to manage iOS dependencies

💊 Usage

For positive experience, you should configure SLazeKit at first. This step is REQUIRED!

import SLazeKit
/// Required override of this method which will provide Context for bacground execution.
///
/// - Returns: NSManagedObjectContext
open class func newBackgroundContext() -> NSManagedObjectContext? { return nil }

This step is optional. You may leave it as it is default.

import SLazeKit

extension SLazeKit {
    //Provide base path for your API requests.
    open class var basePath?: String { return "www.yourdomain.com" }
    //Additional you can set port for your requests.
    open class var basePort: Int? { return 8040  }
    //You can provide your own instance of JSONDecoder.
    open class var decoder: JSONDecoder { return JSONDecoder() }
    //You can customize instance of URLSession in here.
    open class var urlSession: URLSession { return URLSession.shared }
    
    //If you feel like to set header dor requests do it in here.
    open class func setup(_ request: URLRequest) -> URLRequest {
        var request: URLRequest = request
        request.setValue("Your token", forHTTPHeaderField: "X-Access-Token")
        request.setValue("application/json", forHTTPHeaderField: "Content-Type")
        return request
    }
    //If you feel like to monitor response. You can do it in here.
    open class func handle(_ response: HTTPURLResponse?) {
        if response?.statusCode == 401 {
            Client.logout()
        }
    }
}

Model example Simple Object.swift Advance Model.swift

Contributing

Be welcome to contribute to this project! :)

Questions

Just create an issue on GitHub.

📝 License

This project was released under the MIT license.