import 'dart:convert';

class PaymentMethodResponseModel {
  final String? status;
  final PaymentMethodData? data;

  PaymentMethodResponseModel({
    this.status,
    this.data,
  });

  factory PaymentMethodResponseModel.fromJson(String str) =>
      PaymentMethodResponseModel.fromMap(json.decode(str));

  String toJson() => json.encode(toMap());

  factory PaymentMethodResponseModel.fromMap(Map<String, dynamic> json) =>
      PaymentMethodResponseModel(
        status: json["status"],
        data: json["data"] == null
            ? null
            : PaymentMethodData.fromMap(json["data"]),
      );

  Map<String, dynamic> toMap() => {
        "status": status,
        "data": data?.toMap(),
      };
}

class PaymentMethodData {
  final String? total;
  final List<PaymentMethodItem>? paymentMethods;

  PaymentMethodData({
    this.total,
    this.paymentMethods,
  });

  factory PaymentMethodData.fromJson(String str) =>
      PaymentMethodData.fromMap(json.decode(str));

  String toJson() => json.encode(toMap());

  factory PaymentMethodData.fromMap(Map<String, dynamic> json) =>
      PaymentMethodData(
        total: json["total"],
        paymentMethods: json["payment_methods"] == null
            ? []
            : List<PaymentMethodItem>.from(
                json["payment_methods"]!.map((x) => PaymentMethodItem.fromMap(x))),
      );

  Map<String, dynamic> toMap() => {
        "total": total,
        "payment_methods": paymentMethods == null
            ? []
            : List<dynamic>.from(paymentMethods!.map((x) => x.toMap())),
      };
}

class PaymentMethodItem {
  final String? paymentMethod;
  final String? totalAmount;
  final int? transactionCount;

  PaymentMethodItem({
    this.paymentMethod,
    this.totalAmount,
    this.transactionCount,
  });

  factory PaymentMethodItem.fromJson(String str) =>
      PaymentMethodItem.fromMap(json.decode(str));

  String toJson() => json.encode(toMap());

  factory PaymentMethodItem.fromMap(Map<String, dynamic> json) =>
      PaymentMethodItem(
        paymentMethod: json["payment_method"],
        totalAmount: json["total_amount"],
        transactionCount: json["transaction_count"],
      );

  Map<String, dynamic> toMap() => {
        "payment_method": paymentMethod,
        "total_amount": totalAmount,
        "transaction_count": transactionCount,
      };
} 