Swiftpack.co - Ast3r10n/swiftquests as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by Ast3r10n.
Ast3r10n/swiftquests 0.4.0
An object-oriented, URLSession-based network library.
⭐️ 3
🕓 1 year ago
.package(url: "https://github.com/Ast3r10n/swiftquests.git", from: "0.4.0")

SwiftQuests

An object-oriented, URLSession-based network library.

Swift GitHub tag (latest by date) Codecov License Cocoapods LastCommit

Installation

Swift Package Manager

Add a Swift Package Dependency to your project with URL:

https://github.com/Ast3r10n/swiftquests

Cocoapods

Add SwiftQuests to your Podfile:

pod 'SwiftQuests'

Usage

A Request is a basic, standalone object, with a single associated task, configured through its initialiser. Once initialised, a Request is (for the most part) immutable. Its task will only launch through the perform method call.

Basic Request

To perform a basic Request, initialise one:

do {
  let request = try Request(.get,
                            atPath: "/user")
} catch {
  // Error handling
}

You then call the perform method to launch its associated task.

do {
  try request.perform { result in
    // Response implementation
  }
} catch {
  // Error handling
}

Decodable object Request

Requests support automatic JSON decoding using Decodable objects

Here's an example Request to get a Decodable User object from the /user endpoint.

do {
  try Request(.get,
              atPath: "/user")
    .perform(decoding: User.self) { result in
    
    // Your completion handler here
  }
} catch {
  // Error handling
}

GitHub

link
Stars: 3
Last commit: 1 year ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Release Notes

v0.4.0
1 year ago
  • Added Swift concurrency support

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