SmartSpacesSdk

interface SmartSpacesSdk

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

There are three implementations of the SDK:

    SmartSpacesSdk
.Builder(
context, // Android context
baseUrl, // base URL to the server
clientId, // clientId of the Android application on the server
certificate // server public key certificate hash on the format: "sha256/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="
)
.enableTapDetection(true) // optional, defaults to true
.build()
  • An empty implementation with exposed fields that can be easily used for unit testing

    testImplementation 'com.sensorberg.smartspaces: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))
  • A test implementation that roughly behaves like the real implementation but uses randomly mocked data. That's mostly ideal for UI testing The test implementation initial status is always Status.NotLoggedIn Operations (backend queries, open, etc) are time delayed and are always successful

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

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

Types

Builder
Link copied to clipboard
class Builder(application: Application, baseUrl: String, clientId: String, certificates: Set<String>)

Builder for the real Smart Workspace implementation. The parameters can be found on the Smart Workspaces admin panel.

Functions

getAccessPointController
Link copied to clipboard
abstract fun getAccessPointController(): AccessPointController
getAuthenticationController
Link copied to clipboard
abstract fun getAuthenticationController(): AuthenticationController

Controller for authentication use cases.

getBookingManager
Link copied to clipboard
abstract fun getBookingManager(): BookingManager

Manages bookings and schedules on the units.

getGraphQl
Link copied to clipboard
abstract fun getGraphQl(): GraphQl

Direct access to the backend graphQl endpoint. This allows client applications to directly query/mutate data as needed See https://github.com/apollographql/apollo-android

getIotDevicesController
Link copied to clipboard
abstract fun getIotDevicesController(): IotDeviceController

Used to query and control IotDevice.

getPushNotificationController
Link copied to clipboard
abstract fun getPushNotificationController(): PushNotificationController

Functions in this interface will only work if you add the plugin dependency: 'com.sensorberg.smartspaces:push' and initialize the plugin.

getTapController
Link copied to clipboard
abstract fun getTapController(): TapController

Controller for magneto "tap" actions.

getUnitController
Link copied to clipboard
abstract fun getUnitController(): UnitController

Controller for IotUnit. Find nearby, open, etc

getUserManager
Link copied to clipboard
abstract fun getUserManager(): UserManager

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

refresh
Link copied to clipboard
abstract fun refresh(refresh: Refresh = Refresh.All)
abstract fun refresh(refreshList: List<Refresh>)

Force refreshes relevant data from backend. On success, this new data will be reflected on their appropriate LiveData.