part of 'generated.dart';

class CreateAccountVariablesBuilder {
  String bank;
  AccountType type;
  String last4;
  Optional<bool> _isPrimary = Optional.optional(nativeFromJson, nativeToJson);
  String ownerId;
  Optional<String> _accountNumber = Optional.optional(nativeFromJson, nativeToJson);
  Optional<String> _routeNumber = Optional.optional(nativeFromJson, nativeToJson);
  Optional<Timestamp> _expiryTime = Optional.optional((json) => json['expiryTime'] = Timestamp.fromJson(json['expiryTime']), defaultSerializer);

  final FirebaseDataConnect _dataConnect;  CreateAccountVariablesBuilder isPrimary(bool? t) {
   _isPrimary.value = t;
   return this;
  }
  CreateAccountVariablesBuilder accountNumber(String? t) {
   _accountNumber.value = t;
   return this;
  }
  CreateAccountVariablesBuilder routeNumber(String? t) {
   _routeNumber.value = t;
   return this;
  }
  CreateAccountVariablesBuilder expiryTime(Timestamp? t) {
   _expiryTime.value = t;
   return this;
  }

  CreateAccountVariablesBuilder(this._dataConnect, {required  this.bank,required  this.type,required  this.last4,required  this.ownerId,});
  Deserializer<CreateAccountData> dataDeserializer = (dynamic json)  => CreateAccountData.fromJson(jsonDecode(json));
  Serializer<CreateAccountVariables> varsSerializer = (CreateAccountVariables vars) => jsonEncode(vars.toJson());
  Future<OperationResult<CreateAccountData, CreateAccountVariables>> execute() {
    return ref().execute();
  }

  MutationRef<CreateAccountData, CreateAccountVariables> ref() {
    CreateAccountVariables vars= CreateAccountVariables(bank: bank,type: type,last4: last4,isPrimary: _isPrimary,ownerId: ownerId,accountNumber: _accountNumber,routeNumber: _routeNumber,expiryTime: _expiryTime,);
    return _dataConnect.mutation("createAccount", dataDeserializer, varsSerializer, vars);
  }
}

@immutable
class CreateAccountAccountInsert {
  final String id;
  CreateAccountAccountInsert.fromJson(dynamic json):
  
  id = nativeFromJson<String>(json['id']);
  @override
  bool operator ==(Object other) {
    if(identical(this, other)) {
      return true;
    }
    if(other.runtimeType != runtimeType) {
      return false;
    }

    final CreateAccountAccountInsert otherTyped = other as CreateAccountAccountInsert;
    return id == otherTyped.id;
    
  }
  @override
  int get hashCode => id.hashCode;
  

  Map<String, dynamic> toJson() {
    Map<String, dynamic> json = {};
    json['id'] = nativeToJson<String>(id);
    return json;
  }

  CreateAccountAccountInsert({
    required this.id,
  });
}

@immutable
class CreateAccountData {
  final CreateAccountAccountInsert account_insert;
  CreateAccountData.fromJson(dynamic json):
  
  account_insert = CreateAccountAccountInsert.fromJson(json['account_insert']);
  @override
  bool operator ==(Object other) {
    if(identical(this, other)) {
      return true;
    }
    if(other.runtimeType != runtimeType) {
      return false;
    }

    final CreateAccountData otherTyped = other as CreateAccountData;
    return account_insert == otherTyped.account_insert;
    
  }
  @override
  int get hashCode => account_insert.hashCode;
  

  Map<String, dynamic> toJson() {
    Map<String, dynamic> json = {};
    json['account_insert'] = account_insert.toJson();
    return json;
  }

  CreateAccountData({
    required this.account_insert,
  });
}

@immutable
class CreateAccountVariables {
  final String bank;
  final AccountType type;
  final String last4;
  late final Optional<bool>isPrimary;
  final String ownerId;
  late final Optional<String>accountNumber;
  late final Optional<String>routeNumber;
  late final Optional<Timestamp>expiryTime;
  @Deprecated('fromJson is deprecated for Variable classes as they are no longer required for deserialization.')
  CreateAccountVariables.fromJson(Map<String, dynamic> json):
  
  bank = nativeFromJson<String>(json['bank']),
  type = AccountType.values.byName(json['type']),
  last4 = nativeFromJson<String>(json['last4']),
  ownerId = nativeFromJson<String>(json['ownerId']) {
  
  
  
  
  
    isPrimary = Optional.optional(nativeFromJson, nativeToJson);
    isPrimary.value = json['isPrimary'] == null ? null : nativeFromJson<bool>(json['isPrimary']);
  
  
  
    accountNumber = Optional.optional(nativeFromJson, nativeToJson);
    accountNumber.value = json['accountNumber'] == null ? null : nativeFromJson<String>(json['accountNumber']);
  
  
    routeNumber = Optional.optional(nativeFromJson, nativeToJson);
    routeNumber.value = json['routeNumber'] == null ? null : nativeFromJson<String>(json['routeNumber']);
  
  
    expiryTime = Optional.optional((json) => json['expiryTime'] = Timestamp.fromJson(json['expiryTime']), defaultSerializer);
    expiryTime.value = json['expiryTime'] == null ? null : Timestamp.fromJson(json['expiryTime']);
  
  }
  @override
  bool operator ==(Object other) {
    if(identical(this, other)) {
      return true;
    }
    if(other.runtimeType != runtimeType) {
      return false;
    }

    final CreateAccountVariables otherTyped = other as CreateAccountVariables;
    return bank == otherTyped.bank && 
    type == otherTyped.type && 
    last4 == otherTyped.last4 && 
    isPrimary == otherTyped.isPrimary && 
    ownerId == otherTyped.ownerId && 
    accountNumber == otherTyped.accountNumber && 
    routeNumber == otherTyped.routeNumber && 
    expiryTime == otherTyped.expiryTime;
    
  }
  @override
  int get hashCode => Object.hashAll([bank.hashCode, type.hashCode, last4.hashCode, isPrimary.hashCode, ownerId.hashCode, accountNumber.hashCode, routeNumber.hashCode, expiryTime.hashCode]);
  

  Map<String, dynamic> toJson() {
    Map<String, dynamic> json = {};
    json['bank'] = nativeToJson<String>(bank);
    json['type'] = 
    type.name
    ;
    json['last4'] = nativeToJson<String>(last4);
    if(isPrimary.state == OptionalState.set) {
      json['isPrimary'] = isPrimary.toJson();
    }
    json['ownerId'] = nativeToJson<String>(ownerId);
    if(accountNumber.state == OptionalState.set) {
      json['accountNumber'] = accountNumber.toJson();
    }
    if(routeNumber.state == OptionalState.set) {
      json['routeNumber'] = routeNumber.toJson();
    }
    if(expiryTime.state == OptionalState.set) {
      json['expiryTime'] = expiryTime.toJson();
    }
    return json;
  }

  CreateAccountVariables({
    required this.bank,
    required this.type,
    required this.last4,
    required this.isPrimary,
    required this.ownerId,
    required this.accountNumber,
    required this.routeNumber,
    required this.expiryTime,
  });
}

