import 'package:json_annotation/json_annotation.dart';
import 'package:payment_plugin/utils/json.dart';

part '../../_generated/domain/models/add_card_payment_method.g.dart';

enum CardType {
  visa,
  mastercard,
  amexgooglepay,
  maestro;

  static CardType fromString(String type) {
    switch (type.toLowerCase()) {
      case 'visa':
        return CardType.visa;
      case 'mc':
        return CardType.mastercard;
      case 'maestro':
        return CardType.maestro;
      case 'amex_googlepay':
        return CardType.amexgooglepay;
      default:
        throw Exception('Unknown card type: $type');
    }
  }
}

@JsonSerializable()
class AddCardPaymentMethod {
  final Iterable<CardType> brands;
  final String name;
  final String type;

  AddCardPaymentMethod({
    required this.brands,
    required this.name,
    required this.type,
  });

  Json toJson() => _$AddCardPaymentMethodToJson(this);
}