Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/yageek/tpgswift
:bus: TPG OpenData Swift Library
https://github.com/yageek/tpgswift
geneva ios opendata swift tpg
Last synced: about 2 months ago
JSON representation
:bus: TPG OpenData Swift Library
- Host: GitHub
- URL: https://github.com/yageek/tpgswift
- Owner: yageek
- License: mit
- Created: 2016-05-13T06:16:55.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2019-02-19T11:24:34.000Z (almost 6 years ago)
- Last Synced: 2024-04-29T14:02:57.611Z (9 months ago)
- Topics: geneva, ios, opendata, swift, tpg
- Language: Swift
- Homepage:
- Size: 251 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# TPGSwift
Swift libary for the TPG Open Data.
For more explanation: [TPG Open Data](http://www.tpg.ch/fr/web/open-data/mode-d-emploi)
[![Build Status](https://travis-ci.org/yageek/TPGSwift.svg?branch=master)](https://travis-ci.org/yageek/TPGSwift)
[![MIT License](http://img.shields.io/badge/license-MIT-blue.svg?style=flat)](LICENSE)
[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)
[![CocoaPods Compatible](https://img.shields.io/cocoapods/v/TPGSwift.svg)](https://img.shields.io/cocoapods/v/TPGSwift.svg)
[![Platform](https://img.shields.io/cocoapods/p/TPGSwift.svg?style=flat)](http://cocoadocs.org/docsets/TPGSwift)## Usage
```swift
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 = .iso8601do {
let stops = try json.decode(Record.self, from: data)
print("Stops: \(stops)")
} catch let error {
print("Error: \(error)")
}```
## Paw
You can find a basic Paw file which will help you to play with the API.
Open `TPGSwift.paw` and change the `KEY` variable in the `Production` group
with the one received from the TPG.## License
TPGSwift is released under the MIT license. See LICENSE for details.