|
|
|
|
@ -9,12 +9,7 @@ class WalaPlusRetailersResponse {
|
|
|
|
|
int? perPage;
|
|
|
|
|
List<WalaPlusRetailerModel>? retailers;
|
|
|
|
|
|
|
|
|
|
WalaPlusRetailersResponse({
|
|
|
|
|
this.page,
|
|
|
|
|
this.pagesCount,
|
|
|
|
|
this.perPage,
|
|
|
|
|
this.retailers,
|
|
|
|
|
});
|
|
|
|
|
WalaPlusRetailersResponse({this.page, this.pagesCount, this.perPage, this.retailers});
|
|
|
|
|
|
|
|
|
|
factory WalaPlusRetailersResponse.fromJson(Map<String, dynamic> json) {
|
|
|
|
|
List<WalaPlusRetailerModel> retailersList = [];
|
|
|
|
|
@ -35,21 +30,15 @@ class WalaPlusRetailersResponse {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return WalaPlusRetailersResponse(
|
|
|
|
|
page: json['page'] is int
|
|
|
|
|
? json['page']
|
|
|
|
|
: int.tryParse(json['page']?.toString() ?? json['WP_Page']?.toString() ?? '1'),
|
|
|
|
|
pagesCount: json['pages_count'] is int
|
|
|
|
|
? json['pages_count']
|
|
|
|
|
: int.tryParse(json['pages_count']?.toString() ?? json['pagesCount']?.toString() ?? json['totalPages']?.toString() ?? '1'),
|
|
|
|
|
perPage: json['per_page'] is int
|
|
|
|
|
? json['per_page']
|
|
|
|
|
: int.tryParse(json['per_page']?.toString() ?? json['perPage']?.toString() ?? json['WP_Per_page']?.toString() ?? '10'),
|
|
|
|
|
page: json['page'] is int ? json['page'] : int.tryParse(json['page']?.toString() ?? json['WP_Page']?.toString() ?? '1'),
|
|
|
|
|
pagesCount: json['pages_count'] is int ? json['pages_count'] : int.tryParse(json['pages_count']?.toString() ?? json['pagesCount']?.toString() ?? json['totalPages']?.toString() ?? '1'),
|
|
|
|
|
perPage: json['per_page'] is int ? json['per_page'] : int.tryParse(json['per_page']?.toString() ?? json['perPage']?.toString() ?? json['WP_Per_page']?.toString() ?? '10'),
|
|
|
|
|
retailers: retailersList,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Map<String, dynamic> toJson() {
|
|
|
|
|
Map<String, dynamic> data = <String, dynamic>{};
|
|
|
|
|
Map<String, dynamic> data = <String, dynamic>{};
|
|
|
|
|
data['page'] = page;
|
|
|
|
|
data['pages_count'] = pagesCount;
|
|
|
|
|
data['per_page'] = perPage;
|
|
|
|
|
@ -68,22 +57,11 @@ class WalaPlusRetailersByIDResponse {
|
|
|
|
|
List<WalaPlusOfferModel>? offers;
|
|
|
|
|
List<WalaPlusRetailerModel>? retailer;
|
|
|
|
|
|
|
|
|
|
WalaPlusRetailersByIDResponse({
|
|
|
|
|
this.page,
|
|
|
|
|
this.pagesCount,
|
|
|
|
|
this.perPage,
|
|
|
|
|
this.locations,
|
|
|
|
|
this.offers,
|
|
|
|
|
this.retailer,
|
|
|
|
|
});
|
|
|
|
|
WalaPlusRetailersByIDResponse({this.page, this.pagesCount, this.perPage, this.locations, this.offers, this.retailer});
|
|
|
|
|
|
|
|
|
|
factory WalaPlusRetailersByIDResponse.fromJson(Map<String, dynamic> json) {
|
|
|
|
|
List<WalaPlusRetailerLocation> locList = WalaPlusRetailerModel.parseLocationsList(
|
|
|
|
|
json['locations'] ?? json['Locations'] ?? json['location'] ?? json['Location'],
|
|
|
|
|
);
|
|
|
|
|
List<WalaPlusOfferModel> offList = WalaPlusRetailerModel.parseOffersList(
|
|
|
|
|
json['offers'] ?? json['Offers'],
|
|
|
|
|
);
|
|
|
|
|
List<WalaPlusRetailerLocation> locList = WalaPlusRetailerModel.parseLocationsList(json['locations'] ?? json['Locations'] ?? json['location'] ?? json['Location']);
|
|
|
|
|
List<WalaPlusOfferModel> offList = WalaPlusRetailerModel.parseOffersList(json['offers'] ?? json['Offers']);
|
|
|
|
|
|
|
|
|
|
List<WalaPlusRetailerModel> retList = [];
|
|
|
|
|
dynamic retData = json['retailer'] ?? json['Retailer'];
|
|
|
|
|
@ -109,15 +87,9 @@ class WalaPlusRetailersByIDResponse {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return WalaPlusRetailersByIDResponse(
|
|
|
|
|
page: json['page'] is int
|
|
|
|
|
? json['page']
|
|
|
|
|
: int.tryParse(json['page']?.toString() ?? json['WP_Page']?.toString() ?? ''),
|
|
|
|
|
pagesCount: json['pages_count'] is int
|
|
|
|
|
? json['pages_count']
|
|
|
|
|
: int.tryParse(json['pages_count']?.toString() ?? json['pagesCount']?.toString() ?? ''),
|
|
|
|
|
perPage: json['per_page'] is int
|
|
|
|
|
? json['per_page']
|
|
|
|
|
: int.tryParse(json['per_page']?.toString() ?? json['perPage']?.toString() ?? ''),
|
|
|
|
|
page: json['page'] is int ? json['page'] : int.tryParse(json['page']?.toString() ?? json['WP_Page']?.toString() ?? ''),
|
|
|
|
|
pagesCount: json['pages_count'] is int ? json['pages_count'] : int.tryParse(json['pages_count']?.toString() ?? json['pagesCount']?.toString() ?? ''),
|
|
|
|
|
perPage: json['per_page'] is int ? json['per_page'] : int.tryParse(json['per_page']?.toString() ?? json['perPage']?.toString() ?? ''),
|
|
|
|
|
locations: locList,
|
|
|
|
|
offers: offList,
|
|
|
|
|
retailer: retList,
|
|
|
|
|
@ -289,9 +261,7 @@ class WalaPlusRetailerModel {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<WalaPlusOfferModel> offersList = parseOffersList(offersSource ?? targetJson['offers'] ?? targetJson['Offers']);
|
|
|
|
|
List<WalaPlusRetailerLocation> locationsList = parseLocationsList(
|
|
|
|
|
locationsSource ?? targetJson['locations'] ?? targetJson['Locations'] ?? targetJson['location'] ?? targetJson['Location'],
|
|
|
|
|
);
|
|
|
|
|
List<WalaPlusRetailerLocation> locationsList = parseLocationsList(locationsSource ?? targetJson['locations'] ?? targetJson['Locations'] ?? targetJson['location'] ?? targetJson['Location']);
|
|
|
|
|
|
|
|
|
|
List<WalaPlusCategoryModel> categoriesList = [];
|
|
|
|
|
if (targetJson['categories'] != null && targetJson['categories'] is List) {
|
|
|
|
|
@ -309,7 +279,8 @@ class WalaPlusRetailerModel {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String? foundValidity = targetJson['validity']?.toString() ??
|
|
|
|
|
String? foundValidity =
|
|
|
|
|
targetJson['validity']?.toString() ??
|
|
|
|
|
targetJson['valid_to']?.toString() ??
|
|
|
|
|
targetJson['valid_until']?.toString() ??
|
|
|
|
|
targetJson['end_date']?.toString() ??
|
|
|
|
|
@ -323,9 +294,7 @@ class WalaPlusRetailerModel {
|
|
|
|
|
if (foundValidity == null || foundValidity == "null" || foundValidity.trim().isEmpty) {
|
|
|
|
|
for (var entry in targetJson.entries) {
|
|
|
|
|
String k = entry.key.toLowerCase();
|
|
|
|
|
if ((k.contains('valid') || k.contains('expir') || k.contains('duration')) &&
|
|
|
|
|
!k.contains('isverificationcodevalid') &&
|
|
|
|
|
!k.contains('barcode')) {
|
|
|
|
|
if ((k.contains('valid') || k.contains('expir') || k.contains('duration')) && !k.contains('isverificationcodevalid') && !k.contains('barcode')) {
|
|
|
|
|
if (entry.value != null && entry.value.toString().trim().isNotEmpty && entry.value.toString() != "null") {
|
|
|
|
|
foundValidity = entry.value.toString().trim();
|
|
|
|
|
break;
|
|
|
|
|
@ -335,7 +304,8 @@ class WalaPlusRetailerModel {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return WalaPlusRetailerModel(
|
|
|
|
|
id: targetJson['id']?.toString() ??
|
|
|
|
|
id:
|
|
|
|
|
targetJson['id']?.toString() ??
|
|
|
|
|
targetJson['WP_RetailerID']?.toString() ??
|
|
|
|
|
targetJson['retailer_id']?.toString() ??
|
|
|
|
|
targetJson['RetailerID']?.toString() ??
|
|
|
|
|
@ -388,10 +358,7 @@ class WalaPlusRetailerModel {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
s = s
|
|
|
|
|
.replaceAll(r'\/', '/')
|
|
|
|
|
.replaceAll(r'\"', '"')
|
|
|
|
|
.replaceAll(r"\'", "'");
|
|
|
|
|
s = s.replaceAll(r'\/', '/').replaceAll(r'\"', '"').replaceAll(r"\'", "'");
|
|
|
|
|
|
|
|
|
|
s = s.replaceAllMapped(RegExp(r'\\u([0-9a-fA-F]{4})'), (match) {
|
|
|
|
|
try {
|
|
|
|
|
@ -600,10 +567,7 @@ class WalaPlusRetailerModel {
|
|
|
|
|
}
|
|
|
|
|
if (locations != null && locations!.isNotEmpty) {
|
|
|
|
|
for (var loc in locations!) {
|
|
|
|
|
if (loc.contact != null &&
|
|
|
|
|
loc.contact!.trim().isNotEmpty &&
|
|
|
|
|
loc.contact != "null" &&
|
|
|
|
|
!loc.contact!.contains('@')) {
|
|
|
|
|
if (loc.contact != null && loc.contact!.trim().isNotEmpty && loc.contact != "null" && !loc.contact!.contains('@')) {
|
|
|
|
|
return loc.contact!.trim();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -619,11 +583,12 @@ class WalaPlusRetailerModel {
|
|
|
|
|
|
|
|
|
|
bool get isOnlineStore => (type?.trim().toLowerCase() == 'online');
|
|
|
|
|
|
|
|
|
|
bool get isInstore => (type?.trim().toLowerCase() == 'instore' ||
|
|
|
|
|
type?.trim().toLowerCase() == 'in_store' ||
|
|
|
|
|
type?.trim().toLowerCase() == 'in store' ||
|
|
|
|
|
type?.trim().toLowerCase() == 'store' ||
|
|
|
|
|
(type == null && locations != null && locations!.isNotEmpty));
|
|
|
|
|
bool get isInstore =>
|
|
|
|
|
(type?.trim().toLowerCase() == 'instore' ||
|
|
|
|
|
type?.trim().toLowerCase() == 'in_store' ||
|
|
|
|
|
type?.trim().toLowerCase() == 'in store' ||
|
|
|
|
|
type?.trim().toLowerCase() == 'store' ||
|
|
|
|
|
(type == null && locations != null && locations!.isNotEmpty));
|
|
|
|
|
|
|
|
|
|
String? get normalizedType {
|
|
|
|
|
if (type != null && type!.trim().isNotEmpty) {
|
|
|
|
|
@ -659,16 +624,7 @@ class WalaPlusRetailerContact {
|
|
|
|
|
String? instagram;
|
|
|
|
|
String? twitter;
|
|
|
|
|
|
|
|
|
|
WalaPlusRetailerContact({
|
|
|
|
|
this.email,
|
|
|
|
|
this.emails,
|
|
|
|
|
this.phone,
|
|
|
|
|
this.phones,
|
|
|
|
|
this.website,
|
|
|
|
|
this.address,
|
|
|
|
|
this.instagram,
|
|
|
|
|
this.twitter,
|
|
|
|
|
});
|
|
|
|
|
WalaPlusRetailerContact({this.email, this.emails, this.phone, this.phones, this.website, this.address, this.instagram, this.twitter});
|
|
|
|
|
|
|
|
|
|
factory WalaPlusRetailerContact.fromJson(Map<String, dynamic> json) {
|
|
|
|
|
List<String> emailsList = [];
|
|
|
|
|
@ -706,16 +662,7 @@ class WalaPlusRetailerContact {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Map<String, dynamic> toJson() {
|
|
|
|
|
return {
|
|
|
|
|
'email': email,
|
|
|
|
|
'emails': emails,
|
|
|
|
|
'phone': phone,
|
|
|
|
|
'phones': phones,
|
|
|
|
|
'website': website,
|
|
|
|
|
'address': address,
|
|
|
|
|
'instagram': instagram,
|
|
|
|
|
'twitter': twitter,
|
|
|
|
|
};
|
|
|
|
|
return {'email': email, 'emails': emails, 'phone': phone, 'phones': phones, 'website': website, 'address': address, 'instagram': instagram, 'twitter': twitter};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String? get primaryEmail {
|
|
|
|
|
@ -748,6 +695,7 @@ class WalaPlusRetailerLocation {
|
|
|
|
|
String? contact;
|
|
|
|
|
String? countryNameAr;
|
|
|
|
|
String? countryNameEn;
|
|
|
|
|
String? distance;
|
|
|
|
|
double? latitude;
|
|
|
|
|
double? longitude;
|
|
|
|
|
dynamic placeId;
|
|
|
|
|
@ -761,6 +709,7 @@ class WalaPlusRetailerLocation {
|
|
|
|
|
this.contact,
|
|
|
|
|
this.countryNameAr,
|
|
|
|
|
this.countryNameEn,
|
|
|
|
|
this.distance,
|
|
|
|
|
this.latitude,
|
|
|
|
|
this.longitude,
|
|
|
|
|
this.placeId,
|
|
|
|
|
@ -776,6 +725,7 @@ class WalaPlusRetailerLocation {
|
|
|
|
|
contact: json['contact']?.toString(),
|
|
|
|
|
countryNameAr: WalaPlusRetailerModel.decodeUnicodeString(json['country_name_ar']),
|
|
|
|
|
countryNameEn: WalaPlusRetailerModel.decodeUnicodeString(json['country_name_en']),
|
|
|
|
|
distance: WalaPlusRetailerModel.decodeUnicodeString(json['distance']),
|
|
|
|
|
latitude: json['latitude'] is num ? (json['latitude'] as num).toDouble() : double.tryParse(json['latitude']?.toString() ?? ''),
|
|
|
|
|
longitude: json['longitude'] is num ? (json['longitude'] as num).toDouble() : double.tryParse(json['longitude']?.toString() ?? ''),
|
|
|
|
|
placeId: json['place_id'],
|
|
|
|
|
@ -792,6 +742,7 @@ class WalaPlusRetailerLocation {
|
|
|
|
|
data['contact'] = contact;
|
|
|
|
|
data['country_name_ar'] = countryNameAr;
|
|
|
|
|
data['country_name_en'] = countryNameEn;
|
|
|
|
|
data['distance'] = distance;
|
|
|
|
|
data['latitude'] = latitude;
|
|
|
|
|
data['longitude'] = longitude;
|
|
|
|
|
data['place_id'] = placeId;
|
|
|
|
|
@ -840,18 +791,7 @@ class WalaPlusOfferModel {
|
|
|
|
|
dynamic usage;
|
|
|
|
|
String? expiredAt;
|
|
|
|
|
|
|
|
|
|
WalaPlusOfferModel({
|
|
|
|
|
this.id,
|
|
|
|
|
this.retailerId,
|
|
|
|
|
this.title,
|
|
|
|
|
this.image,
|
|
|
|
|
this.imageThumb,
|
|
|
|
|
this.type,
|
|
|
|
|
this.description,
|
|
|
|
|
this.price,
|
|
|
|
|
this.usage,
|
|
|
|
|
this.expiredAt,
|
|
|
|
|
});
|
|
|
|
|
WalaPlusOfferModel({this.id, this.retailerId, this.title, this.image, this.imageThumb, this.type, this.description, this.price, this.usage, this.expiredAt});
|
|
|
|
|
|
|
|
|
|
factory WalaPlusOfferModel.fromJson(Map<String, dynamic> json) {
|
|
|
|
|
return WalaPlusOfferModel(
|
|
|
|
|
|