Fix DeliveryAddress parser to handle string IDs from API
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
ce8cc74e96
commit
28e41a445e
1 changed files with 12 additions and 10 deletions
|
|
@ -1513,18 +1513,20 @@ class DeliveryAddress {
|
|||
});
|
||||
|
||||
factory DeliveryAddress.fromJson(Map<String, dynamic> json) {
|
||||
final rawId = json["AddressID"] ?? json["ADDRESSID"] ?? 0;
|
||||
final rawStateId = json["StateID"] ?? json["STATEID"] ?? 0;
|
||||
return DeliveryAddress(
|
||||
addressId: (json["AddressID"] ?? json["ADDRESSID"] ?? 0) as int,
|
||||
label: (json["Label"] ?? json["LABEL"] ?? "Address") as String,
|
||||
addressId: rawId is int ? rawId : int.tryParse(rawId.toString()) ?? 0,
|
||||
label: (json["Label"] ?? json["LABEL"] ?? "Address").toString(),
|
||||
isDefault: (json["IsDefault"] ?? json["ISDEFAULT"] ?? false) == true,
|
||||
line1: (json["Line1"] ?? json["LINE1"] ?? "") as String,
|
||||
line2: (json["Line2"] ?? json["LINE2"] ?? "") as String,
|
||||
city: (json["City"] ?? json["CITY"] ?? "") as String,
|
||||
stateId: (json["StateID"] ?? json["STATEID"] ?? 0) as int,
|
||||
stateAbbr: (json["StateAbbr"] ?? json["STATEABBR"] ?? "") as String,
|
||||
stateName: (json["StateName"] ?? json["STATENAME"] ?? "") as String,
|
||||
zipCode: (json["ZIPCode"] ?? json["ZIPCODE"] ?? "") as String,
|
||||
displayText: (json["DisplayText"] ?? json["DISPLAYTEXT"] ?? "") as String,
|
||||
line1: (json["Line1"] ?? json["LINE1"] ?? "").toString(),
|
||||
line2: (json["Line2"] ?? json["LINE2"] ?? "").toString(),
|
||||
city: (json["City"] ?? json["CITY"] ?? "").toString(),
|
||||
stateId: rawStateId is int ? rawStateId : int.tryParse(rawStateId.toString()) ?? 0,
|
||||
stateAbbr: (json["StateAbbr"] ?? json["STATEABBR"] ?? "").toString(),
|
||||
stateName: (json["StateName"] ?? json["STATENAME"] ?? "").toString(),
|
||||
zipCode: (json["ZIPCode"] ?? json["ZIPCODE"] ?? "").toString(),
|
||||
displayText: (json["DisplayText"] ?? json["DISPLAYTEXT"] ?? "").toString(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue