GarageClientSwift
Swift client library for the Garage application API
Install / Use
/learn @slightair/GarageClientSwiftREADME
GarageClientSwift
Swift client library for the Garage application API
Requirements
- Swift 3
- Mac OS 10.10+
- iOS 8.0+
- watchOS 2.0+
- tvOS 9.0+
Installation
Carthage
- Add
github "slightair/GarageClientSwift" ~> 2.0toCartfile - Run
carthage update
Usage
1. Define Garage resource model
struct User: Decodable {
let id: Int
let name: String
let email: String
static func decode(_ e: Extractor) throws -> User {
return try User(
id: e <| "id",
name: e <| "name",
email: e <| "email"
)
}
}
2. Define Garage request
struct GetUsersRequest: GarageRequest {
typealias Resource = [User]
var method: HTTPMethod {
return .get
}
var path: String {
return "/users"
}
var queryParameters: [String: Any]? {
return [
"per_page": 1,
"page": 2,
]
}
}
3. Define Garage configuration
struct Configuration: GarageConfiguration {
let endpoint: URL
let accessToken: String
}
let configuration = Configuration(
endpoint: URL(string: "http://localhost:3000")!,
accessToken: "YOUR ACCESS TOKEN"
)
4. Send request
let garageClient = GarageClient(configuration: configuration)
garageClient.sendRequest(GetUsersRequest()) { result in
switch result {
case .success(let response):
debugPrint(response)
let users = response.resource
debugPrint(users)
case .failure(let error):
debugPrint(error)
}
}
License
GarageClientSwift is available under the MIT license. See the LICENSE file for more info.
Related Skills
node-connect
352.2kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
111.1kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
352.2kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
352.2kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
