Swiftpack.co - JamitLabs/Jetworking as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by JamitLabs.
JamitLabs/Jetworking 0.9.0
A multi-module library providing a user-friendly interface for common networking tasks
⭐️ 4
🕓 5 weeks ago
iOS macOS
.package(url: "https://github.com/JamitLabs/Jetworking.git", from: "0.9.0")

Build Status Swift: 5.3 Version: 0.9.0 Platforms: iOS – macOS License: MIT SwiftPM: Compatible

InstallationUsageModulesContributingLicenseIssuesPull Requests

Jetworking is a multi-module iOS and macOS library providing a user-friendly interface for common networking tasks.

Installation

Jetworking can only be installed via the Swift Package Manager.

Supported platforms are iOS (10.0+) and macOS (10.12+).

Swift Package Manager (Xcode-integrated)

To integrate Jetworking using the Xcode-built-in SPM, choose FileSwift PackagesAdd Package Dependency. Enter the following url: https://github.com/JamitLabs/Jetworking and click Next. When asked about the version, leave the preselection and click Next. In the following step, select Jetworking and any further modules you may need and click Finish.

Swift Package Manager (standalone)

To integrate using the standalone version of Apple's Swift Package Manager, add the following as a dependency to your Package.swift (replacing <current-version> with the current version, e. g. 0.9.0):

.package(url: "https://github.com/JamitLabs/Jetworking.git", .upToNextMajor(from: "<current-version>"))

After specifying "Jetworking" and all further modules that you may need as a dependency of the target in which you want to use them, run swift package update.

Modules

Currently, Jetworking consists of the following modules:

Name Description Documentation
Jetworking The base library, defining fundamental types and protocols and providing basic HTTP networking functionality, in particular encompassing the common HTTP methods. Documentation
DataTransfer A module containing functionality concerning uploading and downloading. Documentation

Usage

In this section, the base module, Jetworking, is documented. For more insights, you might want to take a look at the JetworkingTests. Also, feel free to submit a PR with improvements to this documentation.

Jetworking's most important type is the Client. It allows you to access custom Endpoints and perform GET, POST, PUT, PATCH and DELETE operations on them:

let client = Client(configuration: .init(baseURLProvider: URL(string: "https://random.org")!, interceptors: []))

let endpoint = Endpoint<Int>(pathComponent: "integers")
    .addQueryParameters(["num": "1", "min": "1", "max": "10", "col": "1", "base": "10", "format": "plain"])

// Perform GET request
client.get(endpoint: endpoint) { response, result in
    switch result {
    case .failure:
        print("error")

    case let .success(result):
        print("random number is \(result)")
    }
}

Example project

An example project demonstrating the use of Jetworking is currently in development and will be provided soon.

Contributing

We welcome everyone to work with us together delivering helpful tooling to our open source community. Feel free to create an issue to ask questions, give feedback, report bugs or share your new feature ideas. Before creating pull requests, please ensure that you have created a related issue ticket.

License

This project is licensed under the terms of the MIT license. See the LICENSE file.

GitHub

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

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