Git Product home page Git Product logo

bdkautomatic's Introduction

BDKAutomatic

Version Platform Build Status

Overview

A library, along with a sample project, that demonstrates some basic usage of the Automatic REST API. Right now, the library does the following:

  • Downloads and parses trip data
  • Downloads and parses trip's vehicle and location ('terminus') data
  • Parses trip paths to MKPolyline object (separate subspec included)

Sweet GIF action:

In action

Usage

Just include #import <BDKAutomatic/BDKAutomatic.h> at the top of whatever Objective-C thing you're doing, and fire away.

BDKAutomatic *adapter = [[BDKAutomatic alloc] initWithClientId:clientId
                                                  clientSecret:clientSecret
                                                   redirectUrl:redirectUrl];

You'll need to authenticate it against a user account using the OAuth2 dance. See -[BDKAuthViewController handleAutomaticAuthenticationQueryString:] for usage examples. Once you trade your authorization code for a legitimate BDKAutomaticToken (which conforms to NSCopying, by the way, so you can marshal that bad boy to Keychain or something), you can make calls on behalf of an Automatic user.

[self.automatic getTrips:^(NSError *error, NSArray *trips) {
    BDKAutomaticTrip *trip = [trips firstObject];
    NSLog(@"Trip started %@.", trip.startTime);
}];

If you want an MKPolyline out of -[BDKAutomaticTrip path], you'll want to include the separate BDKAutomatic/MKPolylineSupport subspec in your Podfile, and use it like so.

#import <BDKAutomatic/MKPolyline+BDKEncodedString.h>
...
MKPolyline *mapPath = [MKPolyline polylineWithEncodedString:trip.path];
[self.mapView addOverlay:mapPath level:MKOverlayLevelAboveRoads];

You get the idea. See BDKMapViewController.m for more goodies.

Example project setup

To run the example project; clone the repo, and run pod install from the Project directory first. Then, open BDKAutomatic.xcworkspace in the Project directory.

You'll want to copy the secret PLIST file from Project/Classes/BDKAutomaticSecrets.plist.example to Project/Classes/BDKAutomaticSecrets.plist and fill it out with your Automatic API client ID and client secret.

Installation

BDKAutomatic is available through CocoaPods, which is righteously awesome. To install it, simply add the following line to your Podfile.

pod 'BDKAutomatic'

If you don't want to use the "path-to-MKPolyline" functionality, just use the subspec for the adapter.

pod 'BDKAutomatic/Adapter'

Author

Ben Kreeger, [email protected]

License

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

bdkautomatic's People

Contributors

kreeger avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.