import 'package:jaguar_serializer/jaguar_serializer.dart';
part 'card_data.jser.dart';
class CardData {
@Alias('magnet_stripe_data')
final Map<String, String> magnetStripeData;
@Alias('nfc_data')
final Map<String, String> nfcData;
@Alias('pin_ksn')
final String pinKsn;
@Alias('tlv')
final String tlv;
@Alias('cvv')
final String cvv;
@Alias('masked_pan')
final String maskedPan;
@Alias('pin_provided')
final bool pinProvided;
CardData(
{
this.magnetStripeData = const {},
this.nfcData = const {},
this.pinKsn = null,
this.tlv = null,
this.cvv = null,
this.maskedPan = null,
this.pinProvided = false
}
);
@override
String toString() {
return 'CardData[magnetStripeData=$magnetStripeData, nfcData=$nfcData, pinKsn=$pinKsn, tlv=$tlv, cvv=$cvv, maskedPan=$maskedPan, pinProvided=$pinProvided, ]';
}
}
@GenSerializer(nullableFields: false)
class CardDataSerializer extends Serializer<CardData> with _$CardDataSerializer {
}
And here is what's generated:
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'card_data.dart';
// **************************************************************************
// JaguarSerializerGenerator
// **************************************************************************
abstract class _$CardDataSerializer implements Serializer<CardData> {
@override
Map<String, dynamic> toMap(CardData model) {
if (model == null) return null;
Map<String, dynamic> ret = <String, dynamic>{};
setMapValueIfNotNull(
ret,
'magnet_stripe_data',
codeNonNullMap(model.magnetStripeData, (val) => val as String,
<String, dynamic>{}));
setMapValueIfNotNull(
ret,
'nfc_data',
codeNonNullMap(
model.nfcData, (val) => val as String, <String, dynamic>{}));
setMapValueIfNotNull(ret, 'pin_ksn', model.pinKsn);
setMapValueIfNotNull(ret, 'tlv', model.tlv);
setMapValueIfNotNull(ret, 'cvv', model.cvv);
setMapValueIfNotNull(ret, 'masked_pan', model.maskedPan);
setMapValueIfNotNull(ret, 'pin_provided', model.pinProvided);
return ret;
}
@override
CardData fromMap(Map map) {
if (map == null) return null;
final obj = new CardData(
magnetStripeData: codeNonNullMap<String>(
map['magnet_stripe_data'] as Map,
(val) => val as String, <String, String>{}) ??
getJserDefault('magnetStripeData'),
nfcData: codeNonNullMap<String>(map['nfc_data'] as Map,
(val) => val as String, <String, String>{}) ??
getJserDefault('nfcData'),
pinKsn: map['pin_ksn'] as String ?? getJserDefault('pinKsn'),
tlv: map['tlv'] as String ?? getJserDefault('tlv'),
cvv: map['cvv'] as String ?? getJserDefault('cvv'),
maskedPan: map['masked_pan'] as String ?? getJserDefault('maskedPan'),
pinProvided:
map['pin_provided'] as bool ?? getJserDefault('pinProvided'));
return obj;
}
}
For magnet_stripe_data and nfc_data I have this codeNonNullMap that prevent me to actually have null on those field and don't sent them to my backend.
Any way to get rid of those ?
Here is my definition :
And here is what's generated:
For
magnet_stripe_data
andnfc_data
I have thiscodeNonNullMap
that prevent me to actually have null on those field and don't sent them to my backend. Any way to get rid of those ?