Latest 0.1.3
Homepage https://github.com/orlandoamorim/GoBus
License MIT
Platforms ios 8.0
Authors

GoBus: Elegant way to get data from Inthegra API in Swift.

Build status
Platform iOSSwift 2 compatible
CocoaPods compatible
License: MIT

Introduction

GoBus! is a library to help developers to interact with Inthegra API in Swift. We provide an easy way to get data and some new features not implemented on api.

Requirements

  • iOS 8.0+
  • Xcode 7.3+

Getting involved

  • If you want to contribute please feel free to submit pull requests.
  • If you have a feature request please open an issue.
  • If you found a bug check older issues before submitting an issue.

Example

Follow these 3 steps to run Example project: Clone GoBus repository, open Example workspace and run the Example project.

Usage

Set Auth Token

It is quite simple to set auth token, just like this:

import UIKit
import GoBus

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?

    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
        // Override point for customization after application launch.

        GoBus().setupWithApiKey(apiKey: String, email: String, password: String, url: String)
        return true
    }
}

In this example we just set your application key, email and password. With this, you will automatically logged and the access token retrieved and updated automatically.

Now you are read to use GoBus funcs.

How to get bus values

We can get bus values by invoking the following three GoBus function:

Get All Bus

GoBus().getBus(completion: (([Bus]?, [Line]?, NSError?) -> Void))

GoBus().getBus() { (buss, lines, error) in
    if error != nil {
        print(error?.code)
        print(error?.domain)
    }else {
        if lines != nil {
            for line in lines! {
                print(line.description)
            }
        }

        if buss != nil {
            for bus in buss! {
                print(bus.description)
            }
        }
    }
}

Will return an array with Bus objects, an array with Line objects and an NSError

All Bus of specific line

GoBus().getBus(inLine: String?, completion: (([Bus]?, [Line]?, NSError?) -> Void))

GoBus().getBus(inLine: "0408") { (buss, line, error) in
    if error != nil {
        print(error?.code)
        print(error?.domain)
    }else {
        if line != nil {
            //We received only one Line, which correspond to the line researched
            print(line![0].description)
        }

        // - buss - correspond to all Bus in the line researched
        if buss != nil {
            for bus in buss! {
                print(bus.description)
            }
        }
    }
}

Pass the number of the line you want to return and will receive an array with Bus objects of this line, an array with the Line and an NSError

Use GoBus().getBus PROTOCOL

//** repeatAfter works in Seconds
GoBus().getBus(inLine: String?, repeatAfter: Double?, completion: (([Bus]?, [Line]?, NSError?) -> Void))

//Usage:

//  1: GoBus().getBus(inLine: "0408", repeatAfter: 30, completion: (([Bus]?, [Line]?, NSError?) -> Void)) with Search
//  2: GoBus().getBus(repeatAfter: 30, completion: (([Bus]?, [Line]?, NSError?) -> Void)) without Search

//  3: In this case, you can use either the first way as the second

// - First, add GoBusDelegate in the class

let go = GoBus()
//Returns both the bus as the line now. From now on, every five seconds the function implemented by the protocol will return updated values.
let cancel = go.getBus(inLine: "0408", repeatAfter: 5) { (buss, line, error) in }

//Using this way (3), now you can cancel repeat After and the call protocol
go.cancel(cancel)

See more like how get Line and Stops in Example Project

Installation

CocoaPods

CocoaPods is a dependency manager for Cocoa projects.

Specify GoBus into your project’s Podfile:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!

pod 'GoBus'

Then run the following command:

$ pod install

To-Do List


  • [ ] Add ability to stop being sought by lines
  • [ ] Improve Documentation

Author

Orlando Amorim, [email protected]

License

GoBus is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "GoBus",
    "version": "0.1.3",
    "summary": "Elegant way to get data from Inthegra API.",
    "homepage": "https://github.com/orlandoamorim/GoBus",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Orlando Amorim": "[email protected]"
    },
    "source": {
        "git": "https://github.com/orlandoamorim/GoBus.git",
        "tag": "0.1.3"
    },
    "social_media_url": "https://twitter.com/or_amorim",
    "ios": {
        "frameworks": [
            "UIKit",
            "Foundation"
        ]
    },
    "platforms": {
        "ios": "8.0"
    },
    "source_files": "GoBus/Classes/**/*.swift"
}

Pin It on Pinterest

Share This