// GENERATED CODE - DO NOT MODIFY BY HAND

part of 'transaction_approval_model.dart';

// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************

TransactionApprovalModel _$TransactionApprovalModelFromJson(
  Map<String, dynamic> json,
) => TransactionApprovalModel(
  id: json['id'] as String,
  transactionId: json['transactionId'] as String,
  transactionType: $enumDecode(
    _$TransactionTypeEnumMap,
    json['transactionType'],
  ),
  amount: (json['amount'] as num).toDouble(),
  currency: json['currency'] as String? ?? 'XOF',
  requesterId: json['requesterId'] as String,
  requesterName: json['requesterName'] as String,
  organizationId: json['organizationId'] as String?,
  requiredLevel: $enumDecode(_$ApprovalLevelEnumMap, json['requiredLevel']),
  status: $enumDecode(_$ApprovalStatusEnumMap, json['status']),
  approvers: json['approvers'] == null
      ? const []
      : TransactionApprovalModel._approversFromJson(json['approvers'] as List?),
  rejectionReason: json['rejectionReason'] as String?,
  createdAt: DateTime.parse(json['createdAt'] as String),
  expiresAt: json['expiresAt'] == null
      ? null
      : DateTime.parse(json['expiresAt'] as String),
  completedAt: json['completedAt'] == null
      ? null
      : DateTime.parse(json['completedAt'] as String),
  metadata: json['metadata'] as Map<String, dynamic>?,
);

Map<String, dynamic> _$TransactionApprovalModelToJson(
  TransactionApprovalModel instance,
) => <String, dynamic>{
  'id': instance.id,
  'transactionId': instance.transactionId,
  'transactionType': _$TransactionTypeEnumMap[instance.transactionType]!,
  'amount': instance.amount,
  'currency': instance.currency,
  'requesterId': instance.requesterId,
  'requesterName': instance.requesterName,
  'organizationId': instance.organizationId,
  'requiredLevel': _$ApprovalLevelEnumMap[instance.requiredLevel]!,
  'status': _$ApprovalStatusEnumMap[instance.status]!,
  'rejectionReason': instance.rejectionReason,
  'createdAt': instance.createdAt.toIso8601String(),
  'expiresAt': instance.expiresAt?.toIso8601String(),
  'completedAt': instance.completedAt?.toIso8601String(),
  'metadata': instance.metadata,
  'approvers': TransactionApprovalModel._approversToJson(instance.approvers),
};

const _$TransactionTypeEnumMap = {
  TransactionType.contribution: 'contribution',
  TransactionType.deposit: 'deposit',
  TransactionType.withdrawal: 'withdrawal',
  TransactionType.transfer: 'transfer',
  TransactionType.solidarity: 'solidarity',
  TransactionType.event: 'event',
  TransactionType.other: 'other',
};

const _$ApprovalLevelEnumMap = {
  ApprovalLevel.none: 'none',
  ApprovalLevel.level1: 'level1',
  ApprovalLevel.level2: 'level2',
  ApprovalLevel.level3: 'level3',
};

const _$ApprovalStatusEnumMap = {
  ApprovalStatus.pending: 'pending',
  ApprovalStatus.approved: 'approved',
  ApprovalStatus.validated: 'validated',
  ApprovalStatus.rejected: 'rejected',
  ApprovalStatus.expired: 'expired',
  ApprovalStatus.cancelled: 'cancelled',
};

ApproverActionModel _$ApproverActionModelFromJson(Map<String, dynamic> json) =>
    ApproverActionModel(
      approverId: json['approverId'] as String,
      approverName: json['approverName'] as String,
      approverRole: json['approverRole'] as String,
      decision: $enumDecode(_$ApprovalDecisionEnumMap, json['decision']),
      comment: json['comment'] as String?,
      decidedAt: json['decidedAt'] == null
          ? null
          : DateTime.parse(json['decidedAt'] as String),
    );

Map<String, dynamic> _$ApproverActionModelToJson(
  ApproverActionModel instance,
) => <String, dynamic>{
  'approverId': instance.approverId,
  'approverName': instance.approverName,
  'approverRole': instance.approverRole,
  'decision': _$ApprovalDecisionEnumMap[instance.decision]!,
  'comment': instance.comment,
  'decidedAt': instance.decidedAt?.toIso8601String(),
};

const _$ApprovalDecisionEnumMap = {
  ApprovalDecision.pending: 'pending',
  ApprovalDecision.approved: 'approved',
  ApprovalDecision.rejected: 'rejected',
};
