import 'dart:convert';

class PaymentMethodsResponseModel {
  final String? status;
  final List<PaymentMethod>? data;

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

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

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

  factory PaymentMethodsResponseModel.fromMap(Map<String, dynamic> json) =>
      PaymentMethodsResponseModel(
        status: json["status"],
        data: json["data"] == null
            ? []
            : List<PaymentMethod>.from(
                json["data"]!.map((x) => PaymentMethod.fromMap(x))),
      );

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

class PaymentMethod {
  final int? id;
  final String? name;
  final String? description;
  final bool? isActive;
  final int? sortOrder;
  final DateTime? createdAt;
  final DateTime? updatedAt;

  PaymentMethod({
    this.id,
    this.name,
    this.description,
    this.isActive,
    this.sortOrder,
    this.createdAt,
    this.updatedAt,
  });

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

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

  factory PaymentMethod.fromMap(Map<String, dynamic> json) => PaymentMethod(
        id: json["id"],
        name: json["name"],
        description: json["description"],
        isActive: json["is_active"],
        sortOrder: json["sort_order"],
        createdAt: json["created_at"] == null
            ? null
            : DateTime.parse(json["created_at"]),
        updatedAt: json["updated_at"] == null
            ? null
            : DateTime.parse(json["updated_at"]),
      );

  Map<String, dynamic> toMap() => {
        "id": id,
        "name": name,
        "description": description,
        "is_active": isActive,
        "sort_order": sortOrder,
        "created_at": createdAt?.toIso8601String(),
        "updated_at": updatedAt?.toIso8601String(),
      };
} 