Interface PolarRestServiceApi
-
- All Implemented Interfaces:
public interface PolarRestServiceApi
-
-
Method Summary
Modifier and Type Method Description abstract PolarDeviceRestApiServiceslistRestApiServices(String identifier)Discover available services from device. abstract PolarDeviceRestApiServiceDescriptiongetRestApiDescription(String identifier, String path)Get details related to particular REST API. abstract UnitputNotification(String identifier, String notification, String path)Notify device via a REST API in the device. abstract <T extends RestApiEventPayload> Flow<List<T>>receiveRestApiEvents(String identifier, Function1<String, T> mapper)Stream received device REST API event parameters decoded as given type T. -
-
Method Detail
-
listRestApiServices
abstract PolarDeviceRestApiServices listRestApiServices(String identifier)
Discover available services from device.
Requires feature PolarBleApi.PolarBleSdkFeature.FEATURE_POLAR_FILE_TRANSFER.
- Parameters:
identifier- Polar Device ID or BT address- Returns:
PolarDeviceRestApiServices object listing service names and corresponding paths
-
getRestApiDescription
abstract PolarDeviceRestApiServiceDescription getRestApiDescription(String identifier, String path)
Get details related to particular REST API.
Requires feature PolarBleApi.PolarBleSdkFeature.FEATURE_POLAR_FILE_TRANSFER.
- Parameters:
identifier- Polar Device ID or BT addresspath- the REST API path corresponding to a named service returned by listRestApiServices- Returns:
PolarDeviceRestApiServiceDescription object with detailed description of the service
-
putNotification
abstract Unit putNotification(String identifier, String notification, String path)
Notify device via a REST API in the device.
Requires feature PolarBleApi.PolarBleSdkFeature.FEATURE_POLAR_FILE_TRANSFER.
- Parameters:
identifier- Polar device ID or BT addressnotification- content of the notification in JSON formatpath- the API endpoint that will be notified; the path of the REST API file in device + REST API parameters
-
receiveRestApiEvents
abstract <T extends RestApiEventPayload> Flow<List<T>> receiveRestApiEvents(String identifier, Function1<String, T> mapper)
Stream received device REST API event parameters decoded as given type T.
Requires feature PolarBleApi.PolarBleSdkFeature.FEATURE_POLAR_FILE_TRANSFER.
Normally requires an event action that subscribes to the events using putNotification.
- Parameters:
identifier- Polar device ID or BT addressmapper- lambda that converts JSON string to type T- Returns:
Flow of REST API event parameters decoded from JSON format using mapper lambda to type T. SDK provides default decoding using
String.toObject<T>()where T should be a subclass of RestApiEventPayload. Example of such class is PolarSleepRecordingStatusData. Emits decodedList<T>values until collection is cancelled or the flow completes. Exceptions may include BlePsFtpException, BleGattException.
-
-
-
-