saveMaintenanceNote function

Future<void> saveMaintenanceNote({
  1. required BuildContext context,
  2. required int deviceId,
  3. required String contents,
})

Saves a maintenance note with the given contents under the given device.

Implementation

Future<void> saveMaintenanceNote({
  required BuildContext context,
  required int deviceId,
  required String contents,
}) async {
  final response = await ProviderScope.containerOf(context)
      .read(energyManagementV3ApiProvider.future)
      .then(
        (api) => api.kemApiV3DevicesIdMaintenanceNotesPost(
          id: deviceId,
          body: MaintenanceNoteUpsertV3Body(
            contents: contents,
          ),
        ),
      );

  assertSuccessfulResponse(response);

  if (!context.mounted) return;
  await context.fullRefresh(maintenanceNotesApiFamily(deviceId));
}