Smart Spaces Sdk
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:
the real SDK instantiated via SmartSpacesSdk.Builder
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
Functions
Controller for authentication use cases.
Manages bookings and schedules on the units.
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
Used to query and control IotDevice.
Functions in this interface will only work if you add the plugin dependency: 'com.sensorberg.smartspaces:push' and initialize the plugin.
Controller for magneto "tap" actions.
Controller for IotUnit. Find nearby, open, etc
Manages user authentication. Provides methods for login, logout, change password and the logged-in/out