XeeSDK 4.1.3

XeeSDK 4.1.3

TestsTested
LangLanguage SwiftSwift
License Unknown
ReleasedLast Release Jun 2018
SPMSupports SPM

Maintained by Jean-Baptiste Dujardin, Julien Cholin, Oscar Rezoloco.



XeeSDK 4.1.3

Xee iOS SDK

Version License Platform

This SDK make easier the usage of Xee API on iOS devices. It is written in Swift

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

This SDK works for iOS with a version >= 8.0

Installation

XeeSDK is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'XeeSDK'

and launch command

pod install

Setup

Create an application on our developer space to get credentials, see how to create an app

In your AppDelegate, import the SDK

import XeeSDK

next, in the didFinishLaunchingWithOptions method, create a XeeConfig object with all the informations of your app, then give it to the ConnectManager singleton :

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {

    let xeeConfig = XeeConfig(withClientID: "<App Client ID>",
        SecretKet: "<App Secret Key>",
        Scopes: ["<App Scope list>"],
        RedirectURI: "<App Redirect URI>",
        Environment: <App Environment>)
        
    XeeConnectManager.shared.config = xeeConfig
        
    return true
}

Example :

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {

    let xeeConfig = XeeConfig(withClientID: "0123456789abcdefghijklmnopqrstuvwxyz",
        SecretKet: "0123456789abcdefghijklmnopqrstuvwxyz",
        Scopes: ["account.read", "vehicles.read", "vehicles.signals.read", "vehicles.locations.read", "vehicles.trips.read"],
        RedirectURI: "xee-sdk-example://app",
        Environment: .XeeEnvironmentCLOUD)
        
    XeeConnectManager.shared.config = xeeConfig
        
    return true
}

then add this line in the open url method:

func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {
    XeeConnectManager.shared.openURL(URL: url)
    return true
}

Don't forget to add the redirectURI in your URL Schemes ("xee-sdk-example", in this example) :

alt text

You're ready !

Note that we'll keep this SDK up to date to provide you all the endpoints availables on the 4th version of the API

Authentication

Create an account

Add the XeeConnectManagerDelegate protocol to your view controller

Call the connect method of the connectManager singleton when you want the user create an account.

XeeConnectManager.shared.delegate = self
XeeConnectManager.shared.createAccount()

Authenticate the user

Add the XeeConnectManagerDelegate protocol to your view controller

Call the connect method of the connectManager singleton when you want the user logs in order to get a valid access token.

XeeConnectManager.shared.delegate = self
XeeConnectManager.shared.connect()

Disconnect the user

Add the XeeConnectManagerDelegate protocol to your view controller

Call the disconnect method of the connectManager singleton when you want the user disconnect.

XeeConnectManager.shared.delegate = self
XeeConnectManager.shared.disconnect()

XeeConnectManagerDelegate

Four cases:

extension YourViewController : XeeConnectManagerDelegate {
    
    func didSuccess(token: XeeToken) {
        // Success
    }
    
    func didFail(WithError error: Error) {
        // Fail
    }
    
    func didCancel() {
        // Cancel
    }
    
    func didDisconnected() {
        // Disconnected
    }
    
}

If there is no access token or if it's not valid, the SDK will open safari inside the application in order to authenticate with OAuth2. Once safari call back your app, the didSuccess method will be called.

Vehicles

Everything about your vehicles

Associate vehicle

Set a vehicle for an user with a specified device_id and pin code

XeeRequestManager.shared.associateVehicle(WithXeeConnectId: <XeeConnect ID>, PinCode: <Pin Code>, completionHandler: { (error, vehicle) in
    // Your code here
})

Retrieve users's vehicles

Returns vehicles corresponding to specified user id

XeeRequestManager.shared.getVehicles(WithUserID: <User ID or nil for "me">, completionHandler: { (error, vehicules) in
    // Your code here
})

Disassociate vehicle

Delete the pairing between a vehicle and a device

// TODO

Retrieve vehicle

Returns a vehicle corresponding to specified id

XeeRequestManager.shared.getVehicle(WithVehicleID: <Vehicle ID>, completionHandler: { (error, vehicule) in
    // Your code here
})

Update vehicle

Update a vehicle with a specified ID

XeeRequestManager.shared.updateVehicle(WithVehicle: <XeeVehicle object>, completionHandler: { (error, vehicle) in
    // Your code here
})

Retrieve vehicle status

Returns the vehicle status of the vehicle

XeeRequestManager.shared.getStatus(WithVehicleID: <Vehicle ID>, completionHandler: { (error, status) in
    // Your code here
})

Users

Access to your profile

Retrieve an user

Returns a user corresponding to specified id, me is the current user

XeeRequestManager.shared.getUser(WithUserID: <User ID or nil for "me">, completionHandler: { (error, user) in
    // Your code here
})

Update an user

Update an user with a specified ID

XeeRequestManager.shared.updateUser(WithUser: <XeeUser object>, completionHandler: { (error, user) in
    // Your code here
})

Signals

Signals of Vehicles (CAN signals, GPS and Accelerometer)

Retrieve accelerometers

Retrieves the accelerometers data of a vehicle in a given date range

// TODO

Retrieves device data

Retrieves the device data of a vehicle in a given time range

// TODO

Retrieve locations

Retrieves the locations of a vehicle in a given date range

// TODO

Retrieve signals

Retrieves signals for a vehicle in a given date range

// TODO

Privacies

Operations about privacies

Stop a privacy

Stop an existing privacy session

XeeRequestManager.shared.stopPrivacy(ForVPrivacyID: <Privacy ID>, completionHandler: { (error, privacy) in
    // Your code here
})

Retrieve privacies

Returns vehicles privacies between 2 dates inclusive

XeeRequestManager.shared.getPrivacies(ForVehicleID: <Vdehicle ID>, From: <Date or nil>, To: <Date or nil>, Limit: <Int or nil>, completionHandler: { (error, privacies) in
    // Your code here
})

Creates a new privacy

Creates a new privacy session on this vehicle

XeeRequestManager.shared.startPrivacy(ForVehicleID: <Vehicle ID>, completionHandler: { (error, privacy) in
    // Your code here
})

Trips

Access to the trips of the vehicles

Retrieve trip

Returns trip corresponding to specified trip id

XeeRequestManager.shared.getTrip(WithTripID: <Trip ID>, completionHandler: { (error, trip) in
    // Your code here
})

Retrieve trip locations

Returns trips locations by redirecting to the signals api with the good date range

XeeRequestManager.shared.getLocations(WithTripID: <Trip ID>, completionHandler: { (error, locations) in
    // Your code here
})

Retrieve trip signals

Returns trips signals by redirecting to the signals api with the good date range

XeeRequestManager.shared.getSignals(WithTripID: <Trip ID>, completionHandler: { (error, signals) in
    // Your code here
})

Retrieve vehicle trips

Returns trips corresponding to specified vehicle id. Request by date is inclusive. For example if a trip starts from 15:00 and ends at 16:00. A request from 15:15 to 15:45 will return this trip.

XeeRequestManager.shared.getTrips(WithVehicleID: <Vehicle ID>, completionHandler: { (error, trips) in
    // Your code here
})

Authorizations

Manage oAuth authorizations

Revoke authorization

Revokes the specified authorization

// TODO

Retrieve users's authorizations

Returns authorizations corresponding to specified user id

// TODO

Issues

We're working hard to provide you an issue free SDK, but we're just humans so we can do mistakes.

If you find something, feel free to fill an issue or/and fork the repository to fix it !

Author

Xee, [email protected]

License

XeeSDK is available under the Apache License 2.0. See the LICENSE file for more info.