Sensorberg Smart Spaces SDK for Android / com.sensorberg.smartworkspace.sdk / SmartWorkspaceSdk

SmartWorkspaceSdk

interface SmartWorkspaceSdk

Sensorberg Smart Spaces SDK interface. All methods are expected to be called from UI-thread. The SDK handles all needed threading internally. The Smart Workspaces SDK must be a singleton in the application. Consult the implementation guide for singleton pattern.

There are three implementations of the SDK:

    SmartWorkspaceSdk
        .Builder(context) // Android context
        .baseUrl(baseUrl) // base URL to the server
        .oauthId(oauthId) // oauth ID of the Android application on the server
        .certificate(certificate) // server public key certificate hash on the format: "sha256/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="
        .build()
    testImplementation 'com.sensorberg.smartworkspace:test-sdk:VERSION'

    val sdk = EmptySdk()
    sdk.getUserResponse.value = Response.success(user)
    sdk.getUnitsResponse.value = Response.success(units) ... etc

    assertEquals(user, sdk.getUnitController().getUnits(Availability.All, Sorting.None))

    androidTestImplementation 'com.sensorberg.smartworkspace:test-sdk:VERSION'

    val sdk = TestSdk()
    sdk.getUnitController().getUnits(...)
                           .observeForEver {
    					       // response will be executing and later success with some mocked data
    					 }

Types

Builder

class Builder

Builder for the real Smart Workspace implementation. All parameters are required and can be found on the Smart Workspaces admin panel.

Functions

getBookingManager

abstract fun getBookingManager(): BookingManager

Manages bookings and schedules on the units.

getTapController

abstract fun getTapController(): TapController

Controller for magneto and NFC "tap" actions.

getUnitController

abstract fun getUnitController(): UnitController

Controller for IotUnit. Find nearby, open, etc

getUserManager

abstract fun getUserManager(): UserManager

Manages user authentication. Provides methods for login, logout, change password and the logged-in/out

refresh

abstract fun refresh(vararg refresh: Refresh = arrayOf(Refresh.All)): Unit

Force refreshes relevant data from backend. On success, this new data will be reflected on their appropriate LiveData. Optional refresh parameter to refresh only certain data types.