Swiftpack.co - alchemy-swift/papyrus-alamofire as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by alchemy-swift.
alchemy-swift/papyrus-alamofire v0.1.2
Requesting Papyrus Endpoints with Alamofire
⭐️ 0
🕓 2 weeks ago
iOS macOS
.package(url: "https://github.com/alchemy-swift/papyrus-alamofire.git", from: "v0.1.2")

PapyrusAlamofire

Requesting Papyrus API definitions with Alamofire.

Usage

Define an API...

class TodosAPI: EndpointGroup {
    @GET("/todos")
    var getAll: Endpoint<GetTodosRequest, [TodoDTO]>

    struct GetTodosRequest: EndpointRequest {
        @URLQuery
        var limit: Int

        @URLQuery
        var incompleteOnly: Bool
    }

    struct TodoDTO: Codable {
        var name: String
        var isComplete: Bool
    }
}

...and request it.

import PapyrusAlamofire

let todosAPI = TodosAPI(baseURL: "http://localhost:8888")
todosAPI.getAll
    .request(.init(limit: 50, incompleteOnly: true)) { response, todoResult in
        switch todoResult {
        case .success(let todos):
            for todo in todos {
                print("Got todo: \(todo.name)")
            }
        case .failure(let error):
            print("Got error: \(error).")
        }
    }

GitHub

link
Stars: 0
Last commit: 2 weeks ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Release Notes

v0.1.2
2 weeks ago

Rename parameters to httpComponents and bodyEncoding to contentEncoding.

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