import 'package:json_annotation/json_annotation.dart';
import 'package:qpay/screens/recipient/recipients_controller.dart';

part 'recipient_group_model.g.dart';

@JsonSerializable(explicitToJson: true)
class RecipientGroup {
  final String? id;
  final String name;
  final String? description;
  final String? userId;
  final String? workspaceId;
  final String? createdAt;

  const RecipientGroup({
    this.id,
    required this.name,
    this.description,
    this.userId,
    this.workspaceId,
    this.createdAt,
  });

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

  Map<String, dynamic> toJson() => _$RecipientGroupToJson(this);
}

@JsonSerializable(explicitToJson: true)
class RecipientGroupMember {
  final String? id;
  final String recipientGroupId;
  final String? recipientUid;
  final String? userId;
  final String? account;
  final String? createdAt;
  final Recipient recipient;

  const RecipientGroupMember({
    this.id,
    required this.recipientGroupId,
    this.recipientUid,
    this.userId,
    this.account,
    this.createdAt,
    required this.recipient,
  });

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

  Map<String, dynamic> toJson() => _$RecipientGroupMemberToJson(this);
}

@JsonSerializable(explicitToJson: true)
class CreateGroupRequest {
  final String name;
  final String? description;
  final String userId;
  final String workspaceId;
  final List<Recipient> recipients;

  const CreateGroupRequest({
    required this.name,
    this.description,
    required this.userId,
    required this.workspaceId,
    required this.recipients,
  });

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

  Map<String, dynamic> toJson() => _$CreateGroupRequestToJson(this);
}
