Swiftpack.co - infinitetoken/Pinball as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
infinitetoken/Pinball
A tiny networking library for Swift
.package(url: "https://github.com/infinitetoken/Pinball.git", from: "v2.0.1")

Pinball

Pinball is a tiny networking library for Swift!

Installation

Pinball can be installed using the Swift Package Manager. Add the following to your Package.swift file:


dependencies: [
    .Package(url: "https://github.com/infinitetoken/Pinball.git", from: "1.0.0")
]

Usage


import Pinball

let paths: [String] = ["widgets"]
let queries: [Pinball.Query] = [
    Pinball.Query(key: "foo", value: "bar")
]
let headers: [Pinball.Header] = [
    Pinball.Header.accept("application/json"),
    Pinball.Header.contentType("application/json")
]
let data: Data = ...

let endpoint = Pinball.Endpoint(method: .get, scheme: .https, host: "localhost", port: 3000, user: "example", password: "password", paths: paths, queries: queries, headers: headers, data: data)

do {
    let dataTask = try URLSession.shared.dataTask(for: endpoint)
    
    // Do something with the data task!
} catch {
    // Failed!
}

do {
    let _ = try URLSession.shared.dataTask(for: endpoint, completionHandler: { (data, response, error) in 
        // Do something with response!
    })
} catch {
    // Failed!
}

do {
    let publisher = try URLSession.shared.dataTaskPublisher(for: endpoint)
    
    // Do something with the Combine publisher!
} catch {
    // Failed!
}

Reference

License

Pinball is released under the MIT license. See LICENSE for details.

GitHub

link
Stars: 4
Last commit: 2 weeks ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Submit a free job ad (while I'm testing this). The analytics numbers for this website are here.

Release Notes

v2.0.1
2 weeks ago

Fix iOS build error

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