import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:functions/src/core/data/models/entities/locate_device_request_entity.dart';
import 'package:functions/src/core/data/models/entities/set_pedometer_request_entity.dart';

part 'send_command_request_model.freezed.dart';
part 'send_command_request_model.g.dart';

@freezed
abstract class SendCommandRequestModel with _$SendCommandRequestModel {
  const factory SendCommandRequestModel({
    required String deviceName,
    required String command,
  }) = _SendCommandRequestModel;

  factory SendCommandRequestModel.fromJson(Map<String, dynamic> json) =>
    _$SendCommandRequestModelFromJson(json);

}

extension LocateDeviceRequestModelMapper on LocateDeviceRequestEntity {
  SendCommandRequestModel toModel() => SendCommandRequestModel(
    deviceName: deviceName,
    command: 'FIND_DEVICE',
  );
}

extension SetPedometerRequestModelMapper on SetPedometerRequestEntity {
  SendCommandRequestModel toModel() => SendCommandRequestModel(
    deviceName: deviceName,
    command: 'SET_PEDOMETER',
  );
}
