import '../../marianumconnect_query.dart';

/// Triggers a test push to all of the current user's registered devices via
/// `POST /api/mobile/v1/me/push-device/test`. Returns the number of devices the
/// backend dispatched to (0 when none are registered).
class PushDeviceTest extends MarianumConnectQuery {
  PushDeviceTest({super.dio});

  Future<int> run() => guard(() async {
    final response = await dio.post<Map<String, dynamic>>(
      endpoint('me/push-device/test'),
    );
    return (response.data?['devices'] as num?)?.toInt() ?? 0;
  });
}
