Swiftpack.co - quangnghiadev/RequestKits as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by quangnghiadev.
quangnghiadev/RequestKits 1.0.2
RequestKits is a framework for network request (API Request, Upload/Download Task)
⭐️ 0
🕓 2 years ago
iOS
.package(url: "https://github.com/quangnghiadev/RequestKits.git", from: "1.0.2")

Build Status SPM compatible Swift Xcode MIT

RequestKits

RequestKits is a framework for network request (API Request, Upload/Download Task)

Requirements

  • iOS 11.0+
  • Swift 5.0+

Dependency

  • RxSwift
  • Alamofire

Installation

Swift Package Manager

You can use The Swift Package Manager to install RequestKits by adding https://github.com/quangnghiadev/RequestKits.git to Swift Package of your XCode project

Usage

Define your Network instance

private let network = Network(config: NetworkConfig())

Make a request with:

  • Pure
var request = URLRequest(url: URL(string: "https://httpbin.org/get")!)
request.method = .get
network.request(request, validationType: .successCodes) { data, error in
    print(data as Any)
    print(error as Any)
}
  • Requestable

struct GetAllPostsRequest: Requestable {
    var baseURL: URL {
        return URL(string: "https://httpbin.org/")!
    }

    var path: String {
        return "get"
    }

    var method: HTTPMethod {
        return .get
    }

    var task: Task {
        .requestPlain
    }
}

network.request(requestable: GetAllPostsRequest()) { data, error in
    print(data as Any)
    print(error as Any)
}
  • RxSwift and Requestable
let request: Observable<EmptyEntity> = network.rxRequest(requestable: GetAllPostsRequest())
request.subscribe(onNext: { response in
    print(response)
}).disposed(by: disposeBag)

Pluggin

RequestAdapter

EventMonitor

License

  • RequestKits is using Alamofire. See LICENSE for more information.
  • RequestKits is using RxSwift. See LICENSE for more information.
  • RequestKits is using source code from Moya. See LICENSE for more information.
  • RequestKits is released under the MIT license. See LICENSE for more information.

GitHub

link
Stars: 0
Last commit: 1 year ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Release Notes

1.0.2
2 years ago

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics