Swiftpack.co -  jameshurst/Transmission-Swift as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
jameshurst/Transmission-Swift
A Combine powered Transmission RPC API client.
.package(url: "https://github.com/jameshurst/Transmission-Swift.git", from: "1.0.2")

Transmission

A Combine powered Transmission RPC API client.

Usage

import Combine
import Transmission

var cancellables = Set<AnyCancellable>()

let client = Transmission(baseURL: URL(string: "https://my.torrent.server")!, username: nil, password: nil)
client.request(.rpcVersion)
    .sink(receiveCompletion: { _ in }, receiveValue: { rpcVersion in
        print("RPC Version: \(rpcVersion)")
    })
    .store(in: &cancellables)

Requests

A Request describes an RPC method, its arguments, and a function to transform the API response in to a new representation.

There are many requests already built-in. To see the available requests you can can take a look at the Requests directory or browse through the autocomplete menu when typing client.request(..

let rpcVersion = Request<Int>(
    method: "session-get",
    args: ["fields": ["rpc-version"]],
    transform: { response in
        guard let arguments = response["arguments"] as? [String: Any],
                let version = arguments["rpc-version"] as? Int
        else {
            return .failure(.unexpectedResponse)
        }

        return .success(version)
    }
)

Installation

Xcode 11+

  • Select File > Swift Packages > Add Package Dependency...
  • Enter the package repository URL: https://github.com/jameshurst/Transmission-Swift.git
  • Confirm the version and let Xcode resolve the package

License

This library is released under the MIT license. See LICENSE for details.

GitHub

link
Stars: 13
Last commit: 38 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.

Release Notes

38 weeks ago

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