ParkingPandaSDK 0.6.13

ParkingPandaSDK 0.6.13

TestsTested
LangLanguage SwiftSwift
License Commercial
ReleasedLast Release Dec 2016
SwiftSwift Version 3.0
SPMSupports SPM

Maintained by Brian Drelling.



ParkingPandaSDK

Travis CI

ParkingPandaSDK provides easy access to the Parking Panda API.

Features

  • [x] Easily access almost every call in the Parking Panda API.
  • [x] Authenticate user credentials and optionally cache for subsequent calls.
  • [x] Utilize the client via shared static instance or initialize your own.
  • [x] React to the built-in event subscription to know when API calls return.
  • [x] Receive guaranteed attribution for every referral transaction processed in our system.
  • [x] Breathe easily knowing it’s the same logic we use in our consumer-facing and enterprise apps.

Requirements

  • iOS 9.0+
  • Xcode 8.0+
  • Swift 3.0+
  • An API key from Parking Panda. Contact us for more information.

Dependencies

For the time being, ParkingPandaSDK has three dependencies that will be automatically installed upon including this pod.

  • ObjectMapper, used for JSON deserialization.
  • Alamofire, used for all network requests.
  • AlamofireObjectMapper, a component library with convenience methods to bridge the two.

Installation

Swift Package Manager

Swift Package Manager is a tool for managing the distribution of Swift code. It’s integrated with the Swift build system to automate the process of downloading, compiling, and linking dependencies.

We do not support Swift Package Manager at this time. Please contact us if you require Swift Package Manager support.

Manually

For instructions on how to install the SDK manually, please contact us.

Usage

Initializing the Client

There are two ways to get started.

1) Use the shared instance of the PPAPIClient class.

PPAPIClient.shared.apiKey = "MY-API-KEY"
PPAPIClient.shared.test()

2) Create your own instance of the PPAPIClient class.

let client = PPAPIClient(apiKey: "MY-API-KEY")
client.test()

Every call in PPAPIClient requires an API key which can be set during or after initialization.

The test() method will verify that your client has access to the API.

Authentcation and Caching

Authentication is very simple.

func login(username: String?, password: String?, authType: PPAuthType = .default, includeCreditCards: Bool = true, callback: ((PPUserModel) -> Void)? = nil)

username is typically the user’s email address.
password is the user’s plain text password or API token.
authType (optional) is the authentication type. It is .default by default.
includeCreditCards (optional) determines whether or not a list of the user’s vaulted credit cards are returned.
callback (optional) fires if the authentication is successful.

Example:

PPAPIClient.shared.login(username: "USERNAME", password: "PASSWORD") { (user) in
    print(user.email)
}

By default, the shared instance of PPAPIClient will store user credentials on the device when user authentication is successful. These credentials include the user’s id, email, and api token. You can override this behavior by setting the cacheKey property to nil.

Likewise, you can set the cacheKey property on any instance of PPAPIClient to maintain unique caching of credentials per client. This can be set during or after initialization.

Examples:

let client = PPAPIClient(apiKey: "MY-API-KEY", cacheKey: "CLIENT-A")
let client = PPAPIClient()
client.apiKey = "MY-API-KEY"
client.cacheKey = "CLIENT-B"

Coming Soon

  • Implement drop-in UI button for easy linking.
  • Remove ObjectMapper dependency.
  • Remove Alamofire dependency.

Communication

  • If you found a bug, please open an issue.
  • If you do not have an API key, please contact us.
  • If you have a feature request, please contact us.

License

ParkingPandaSDK is released under the Apache 2.0 license. See LICENSE for details.