Swiftpack.co -  Package - vivalalova/FetchSwift
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
vivalalova/FetchSwift
Combine
.package(url: "https://github.com/vivalalova/FetchSwift.git", from: "1.0.3")

FetchSwift

Usage

final class JsonPlaceholderAPI: Fetch {
    /// ref: https://jsonplaceholder.typicode.com/
    var domain: String = "https://jsonplaceholder.typicode.com/"

    var decoder = JSONDecoder()

    var encoder = JSONEncoder()

    static var shared: JsonPlaceholderAPI = JsonPlaceholderAPI()

    func willSend(params: [String: Any], method: FetchSwift.Method, path: String) -> Params {
        params
    }

    func willSend(request: URLRequest, method: FetchSwift.Method, path: String, params: [String: Any]) -> URLRequest {
        request
    }

    func show(progress: Float?) {}

    func hide(progress: Float?) {}
}

extension JsonPlaceholderAPI {
    struct Todo: Codable {
        var id: Int?
        var userId: Int?
        var title: String?
        var completed: Bool?
    }

    func todos() -> Response<[Todo]> {
        self.fetch(path: "todos")
    }
}

GitHub

link
Stars: 0
Last commit: 1 week ago

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