import 'dart:convert'; PharmacyAddressesModel pharmacyAddressesModelFromJson(String str) => PharmacyAddressesModel.fromJson(json.decode(str)); String pharmacyAddressesModelToJson(PharmacyAddressesModel data) => json.encode(data.toJson()); class PharmacyAddressesModel { PharmacyAddressesModel({ this.customers, }); List customers; factory PharmacyAddressesModel.fromJson(Map json) => PharmacyAddressesModel( customers: List.from(json["customers"].map((x) => Customer.fromJson(x))), ); Map toJson() => { "customers": List.from(customers.map((x) => x.toJson())), }; } class Customer { Customer({ this.addresses, }); List
addresses; factory Customer.fromJson(Map json) => Customer( addresses: List
.from(json["addresses"].map((x) => Address.fromJson(x))), ); Map toJson() => { "addresses": List.from(addresses.map((x) => x.toJson())), }; } class Address { Address({ this.id, this.firstName, this.lastName, this.email, this.company, this.countryId, this.country, this.stateProvinceId, this.city, this.address1, this.address2, this.zipPostalCode, this.phoneNumber, this.faxNumber, this.customerAttributes, this.createdOnUtc, this.province, this.latLong, }); String id; FirstName firstName; LastName lastName; Email email; dynamic company; int countryId; Country country; dynamic stateProvinceId; City city; String address1; String address2; String zipPostalCode; String phoneNumber; dynamic faxNumber; String customerAttributes; DateTime createdOnUtc; dynamic province; String latLong; factory Address.fromJson(Map json) => Address( id: json["id"], firstName: firstNameValues.map[json["first_name"]], lastName: lastNameValues.map[json["last_name"]], email: emailValues.map[json["email"]], company: json["company"], countryId: json["country_id"], country: countryValues.map[json["country"]], stateProvinceId: json["state_province_id"], city: cityValues.map[json["city"]], address1: json["address1"], address2: json["address2"], zipPostalCode: json["zip_postal_code"], phoneNumber: json["phone_number"], faxNumber: json["fax_number"], customerAttributes: json["customer_attributes"], createdOnUtc: DateTime.parse(json["created_on_utc"]), province: json["province"], latLong: json["lat_long"], ); Map toJson() => { "id": id, "first_name": firstNameValues.reverse[firstName], "last_name": lastNameValues.reverse[lastName], "email": emailValues.reverse[email], "company": company, "country_id": countryId, "country": countryValues.reverse[country], "state_province_id": stateProvinceId, "city": cityValues.reverse[city], "address1": address1, "address2": address2, "zip_postal_code": zipPostalCode, "phone_number": phoneNumber, "fax_number": faxNumber, "customer_attributes": customerAttributes, "created_on_utc": createdOnUtc.toIso8601String(), "province": province, "lat_long": latLong, }; } enum City { RIYADH, AL_OYUN } final cityValues = EnumValues({ "Al Oyun": City.AL_OYUN, "Riyadh": City.RIYADH }); enum Country { SAUDI_ARABIA } final countryValues = EnumValues({ "Saudi Arabia": Country.SAUDI_ARABIA }); enum Email { TAMER_FANASHEH_GMAIL_COM, TAMER_DASDASDAS_GMAIL_COM } final emailValues = EnumValues({ "Tamer.dasdasdas@gmail.com": Email.TAMER_DASDASDAS_GMAIL_COM, "Tamer.fanasheh@gmail.com": Email.TAMER_FANASHEH_GMAIL_COM }); enum FirstName { TAMER, TAMER_FANASHEH } final firstNameValues = EnumValues({ "TAMER": FirstName.TAMER, "TAMER FANASHEH": FirstName.TAMER_FANASHEH }); enum LastName { FANASHEH, MUSA } final lastNameValues = EnumValues({ "FANASHEH": LastName.FANASHEH, "MUSA": LastName.MUSA }); class EnumValues { Map map; Map reverseMap; EnumValues(this.map); Map get reverse { if (reverseMap == null) { reverseMap = map.map((k, v) => new MapEntry(v, k)); } return reverseMap; } }