import 'package:json_annotation/json_annotation.dart';

import 'package:pshared/data/dto/permissions/data/policy.dart';
import 'package:pshared/data/mapper/permissions/data/policy.dart';
import 'package:pshared/models/permissions/data/policy.dart';

part 'change_policies.g.dart';


@JsonSerializable(explicitToJson: true)
class PoliciesChangeRequest {
  final List<PolicyDTO>? add;
  final List<PolicyDTO>? remove;

  const PoliciesChangeRequest({
    this.add, 
    this.remove,
  });

  factory PoliciesChangeRequest.add({required List<Policy> policies}) => PoliciesChangeRequest(
    add: policies.map((policy) => policy.toDTO()).toList(), 
  );

  factory PoliciesChangeRequest.remove({required List<Policy> policies}) => PoliciesChangeRequest(
    remove: policies.map((policy) => policy.toDTO()).toList(),
  );

  factory PoliciesChangeRequest.change({
    required List<Policy> add, 
    required List<Policy> remove,
  }) => PoliciesChangeRequest(
    add: add.map((policy) => policy.toDTO()).toList(), 
    remove: remove.map((policy) => policy.toDTO()).toList(),
  );

  factory PoliciesChangeRequest.fromJson(Map<String, dynamic> json) => _$PoliciesChangeRequestFromJson(json);
  Map<String, dynamic> toJson() => _$PoliciesChangeRequestToJson(this);
}
