Swiftpack.co -  ElevatedUnderdogs/Callable as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
ElevatedUnderdogs/Callable
A light weight Swift Package for making web calls
.package(url: "https://github.com/ElevatedUnderdogs/Callable.git", from: "1.0.0")

Callable

A light weight Swift Package for making web calls.

Swift Version License

Callable was created to solve the tiresome and tedius chore of writing URLSession.shared.dataTask etc. etc. etc.

Installation into a project

Copy the .git url for this repo.

Screen Shot 2021-04-03 at 10 11 14 PM Screen Shot 2021-04-03 at 10 11 31 PM

Paste it here:

Screen Shot 2021-04-03 at 10 12 07 PM

Click enter, then follow the prompts.

Installation into a package

Add this project on your Package.swift

import PackageDescription

let package = Package(
    dependencies: [
        .Package(url: "https://github.com/user/project.git", majorVersion: 0, minor: 0)
    ]
)

Usage example

You can simply specify your URL and then access either Data, JSON or through the magic of generics: a Codable type.

import Callable

URL(string: "http://api/website.com").callCodable { (myStruct: MyStruct?) in 
    print("The data", (myStruct == nil ? "doesn't convert": "converts"), "to MyStruct.")
}

URLRequest conforms to Callable as well, so you can do the same thing:

import Callable

let myURLRequest: URLRequest!
myURLRequest.callCodable { (myStruct: MyStruct?) in 
    print("The data", (myStruct == nil ? "doesn't convert": "converts"), "to MyStruct.")
}

Meta

Scott Lydon – Linkedin

Distributed under the MIT license. See LICENSE for more information.

ElevatedUnderdogs

GitHub

link
Stars: 0
Last commit: 4 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.

Related Packages

Release Notes

Initial
4 weeks ago

MVP

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