Pinball is a tiny networking library for Swift!
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")]import Pinball
letpaths:[String]=["widgets"]letqueries:[Pinball.Query]=[Pinball.Query(key:"foo", value:"bar")]letheaders:[Pinball.Header]=[Pinball.Header.accept("application/json"),Pinball.Header.contentType("application/json")]letdata:Data=...letendpoint=Pinball.Endpoint(method:.get, scheme:.https, host:"localhost", port:3000, user:"example", password:"password", paths: paths, queries: queries, headers: headers, data: data)do{letdataTask=tryURLSession.shared.dataTask(for: endpoint)
// Do something with the data task!
}catch{
// Failed!
}do{let _ =tryURLSession.shared.dataTask(for: endpoint, completionHandler:{(data, response, error)in // Do something with response!
})}catch{
// Failed!
}do{letpublisher=tryURLSession.shared.dataTaskPublisher(for: endpoint)
// Do something with the Combine publisher!
}catch{
// Failed!
}Pinball is released under the MIT license. See LICENSE for details.