Latest 0.9.3
Homepage https://github.com/katsana/katsana-sdk-ios
License apache
Platforms osx 10.11, ios 8.0, requires ARC
Dependencies Siesta, XCGLogger
Frameworks CoreLocation
Authors

KatsanaSDK is a framework for accessing data from Katsana platform using iOS/macOS app.

Installation

KatsanaSDK is available via Cocoapods.

Cocoapods

Add these to your Podfile

For iOS

use_frameworks!
target "PROJECT_NAME" do
    platform :ios, '8.0'
    pod 'KatsanaSDK', '~>0.9.0'
end

For macOS

use_frameworks!
target "PROJECT_NAME" do
    platform :osx, 10.11'
    pod 'KatsanaSDK', '~>0.9.0'
end

Usage

Import KatsanaSDK for each source file:

import KatsanaSDK

In your AppDelegate in the

application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]? = nil)

Configure KatsanaAPI and using client id, client secret and grant type

KatsanaAPI.configure(clientId: CLIENT_ID, clientSecret: CLIENT_SECRET, grantType: GRANT_TYPE)

Then, you can login using your credential

KatsanaAPI.shared.login(email: EMAIL, password: PASSWORD, completion: { user in
    //Handle user login success
}) { error in
    //Login error        
}

Vehicles

Vehicle class contains vehicle information such as vehicle id, today max speed, image url, and current vehicle location.

To load all vehicles information, use:

KatsanaAPI.shared.requestAllVehicles(completion: { (vehicles) in
    //Vehicles loaded 
})

To load a single vehicle:

KatsanaAPI.shared.requestVehicle(vehicleId: "78", completion: { (vehicle) in
    //Vehicle loaded
})

You can also use:

KatsanaAPI.shared.vehicleWith(vehicleId: "78")

which will return vehicle with vehicle id if already requested from server.

Vehicle Location

VehicleLocation class contains location data of the vehicle including, coordinate, speed and device voltage.

You can get vehicle location from Vehicle class

 let location = vehicle.current

Or request latest vehicle location:

KatsanaAPI.shared.requestVehicleLocation(vehicleId: "78", completion: { (vehicleLocation) in
    //Success
})

Travel

Travel class contains travel history for specific vehicle. Each travel contains trip data for a single day only except for multiple days trip.

To request travel data for specific day:

KatsanaAPI.shared.requestTravel(for: Date(), vehicleId: "78", completion: { (travel) in
    //Success
}) { (error) in
    //Error
}

If you need travel data for multiple dates in range:

KatsanaAPI.shared.requestTravelSummaries(vehicleId: "78", fromDate: date1, toDate: date2, completion: { (travels) in
    //Success
})

Travel summary request also return instance of Travel but it does not include trip data to save bandwidth.

You can request full travel data for specific date again if needed

let summary = ... //Travel summary already requested from server
KatsanaAPI.shared.requestTravelUsing(summary: summary, completion: { (travel) in
    //Success
}) { (error) in
    //Error
}

Requesting a single travel summary for today:

KatsanaAPI.shared.requestTravelSummaryToday(vehicleId: "78") { travel in
    //Success   
}

Latest podspec

{
    "name": "KatsanaSDK",
    "version": "0.9.3",
    "summary": "Access Katsana platform",
    "description": "SDK for accessing Katsana platform data",
    "homepage": "https://github.com/katsana/katsana-sdk-ios",
    "license": "apache",
    "authors": {
        "Wan Ahmad Lutfi": "[email protected]"
    },
    "platforms": {
        "osx": "10.11",
        "ios": "8.0"
    },
    "source_files": "KatsanaSDK/**/*.{swift,h,m}",
    "public_header_files": "KatsanaSDK/**/*.h",
    "ios": {
        "exclude_files": "KatsanaSDK/macOS",
        "frameworks": "UIKit"
    },
    "osx": {
        "exclude_files": "KatsanaSDK/iOS",
        "frameworks": "AppKit"
    },
    "frameworks": "CoreLocation",
    "requires_arc": true,
    "source": {
        "git": "https://github.com/katsana/katsana-sdk-ios.git",
        "tag": "0.9.3"
    },
    "dependencies": {
        "Siesta": [],
        "XCGLogger": []
    },
    "pushed_with_swift_version": "3.0"
}

Pin It on Pinterest

Share This