TPGSwift 4.0.0

TPGSwift 4.0.0

测试已测试
语言语言 SwiftSwift
许可证 MIT
发布上次发布2019年2月
SPM支持 SPM

Yannick Heinrich 维护。



TPGSwift 4.0.0

TPGSwift

TPG 开放数据的 Swift 库。

更多说明: TPG 开放数据

Build Status

MIT License Carthage compatible CocoaPods Compatible Platform

使用

import TPGSwift

// MARK: - Setting the key

// Set the API Key
API.Key = "MY_API_KEY"

// MARK: - Creating an API call url

// Get stops for the stop code "WTC0"
let getStops = API.getStops(stopCode: "WTC0", stopName: nil, line: nil, latitude: nil, longitude: nil)

print("API Stops: \(getStops.URL)")
// -> API Stops: https://prod.ivtr-od.tpg.ch/v1/GetStops.json?key=KEY&stopCode=WTC0

// MARK: - Decode

let json = JSONDecoder()
// This is mandatory
decoder.dateDecodingStrategy = .iso8601

do {
    let stops = try json.decode(Record<Stop>.self, from: data)
    print("Stops: \(stops)")
} catch let error {
    print("Error: \(error)")
}

Paw

您可以在 TPGSwift.paw 中找到一个基本的 Paw 文件,这可以帮助您与 API 进行交互。打开 TPGSwift.paw 并将 Production 组中的 KEY 变量更改为从 TPG 收到的值。

许可证

TPGSwift 在 MIT 许可证下发布。有关详细信息,请参阅 LICENSE。