Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jameshurst/Transmission-Swift
A Combine powered Transmission RPC API client.
https://github.com/jameshurst/Transmission-Swift
api rpc swift torrent transmission
Last synced: 2 months ago
JSON representation
A Combine powered Transmission RPC API client.
- Host: GitHub
- URL: https://github.com/jameshurst/Transmission-Swift
- Owner: jameshurst
- License: mit
- Created: 2020-03-19T04:07:22.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2020-10-30T19:15:51.000Z (over 4 years ago)
- Last Synced: 2024-08-09T17:30:14.536Z (6 months ago)
- Topics: api, rpc, swift, torrent, transmission
- Language: Swift
- Homepage:
- Size: 95.7 KB
- Stars: 20
- Watchers: 2
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Transmission
A Combine powered Transmission RPC API client.
## Usage
```swift
import Combine
import Transmissionvar cancellables = Set()
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](Sources/Transmission/Requests/) directory or browse through the autocomplete menu when typing `client.request(.`.
```swift
let rpcVersion = Request(
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](LICENSE) for details.