项目作者: emma-k-alexandra

项目描述 :
WMATA.swift is a Swift interface to the Washington Metropolitan Area Transit Authority API
高级语言: Swift
项目地址: git://github.com/emma-k-alexandra/WMATA.swift.git
创建时间: 2019-06-23T21:42:58Z
项目社区:https://github.com/emma-k-alexandra/WMATA.swift

开源协议:MIT License

下载


WMATA.swift

WMATA.swift is a Swift interface to the Washington Metropolitan Area Transit Authority API.

Install

Requirements

  • Swift 5.9
  • Xcode 15

Swift Package Manager

  1. dependencies: [
  2. .package(
  3. name: "WMATA",
  4. url: "https://github.com/emma-k-alexandra/WMATA.swift.git",
  5. .upToNextMajor(from: "15.0.0")
  6. )
  7. ]

Usage

Standard API

To work with WMATA’s Standard API use the WMATA package.

  1. import WMATA
  2. let nextTrains = Rail.NextRails(
  3. key: YOUR_API_KEY,
  4. station: .waterfront
  5. )
  6. nextTrains.request { result in
  7. switch result {
  8. case let .success(response):
  9. print(response.trains)
  10. case let .failure(error):
  11. print(error)
  12. }
  13. }

GTFS Static

To work with GTFS Static data use the MetroGTFS package.

  1. import MetroGTFS
  2. let ashburn = try GTFSStop("STN_N12")
  3. print(ashburn.name) // "ASHBURN METRORAIL STATION"

Documentation

Full documentation is available at https://emma-k-alexandra.github.io/WMATA.swift/documentation/wmata or within Xcode.

To view documentation within Xcode, within the menu navigate to Product > Build Documentation. WMATA’s documentation will appear under Workspace Documentation within the Developer Documentation window. Navigate to Window > Developer Documentation to open this window.

OS Support

WMATA.swift commits to supporting current minus 2 OS versions.

Currently, WMATA.swift is compatible with macOS 12, iOS 15, tvOS 15, watchOS 8 or higher.

Versioning

WMATA.swift uses semantic versioning. Only major versions will contain breaking changes.

Dependencies

Contact

Feel free to email questions and comments to emma@emma.sh

Contributing

Todo:

  • Support all GTFS Static data in MetroGTFS
  • Convert async functions from a Result to return or throw behavior, the dominant async pattern in Swift

Developer

To generate documentation for deploying to Github Pages, run ./docs.sh.

License

WMATA.swift is released under the MIT license. See LICENSE for details.

This package is not distributed by or affiliated with WMATA.