You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
155 lines
8.6 KiB
Dart
155 lines
8.6 KiB
Dart
// ignore_for_file: non_constant_identifier_names
|
|
// ignore_for_file: camel_case_types
|
|
// ignore_for_file: prefer_single_quotes
|
|
|
|
import 'package:hmg_patient_app/core/model/geofencing/responses/GeoZonesResponseModel.dart';
|
|
import 'package:hmg_patient_app/core/model/geofencing/responses/LogGeoZoneResponseModel.dart';
|
|
|
|
// This file is automatically generated. DO NOT EDIT, all your changes would be lost.
|
|
import 'package:hmg_patient_app/core/model/packages_offers/responses/PackagesCategoriesResponseModel.dart';
|
|
import 'package:hmg_patient_app/core/model/packages_offers/responses/PackagesResponseModel.dart';
|
|
import 'package:hmg_patient_app/generated/json/GeoZonesResponseModel_helper.dart';
|
|
import 'package:hmg_patient_app/generated/json/OfferCategoriesResponseModel_helper.dart';
|
|
import 'package:hmg_patient_app/generated/json/OfferProductsResponseModel_helper.dart';
|
|
import 'package:hmg_patient_app/generated/json/log_geo_zone_response_model_entity_helper.dart';
|
|
|
|
class JsonConvert<T> {
|
|
T fromJson(Map<String, dynamic> json) {
|
|
return _getFromJson<T>(runtimeType, this, json);
|
|
}
|
|
|
|
Map<String, dynamic> toJson() {
|
|
return _getToJson<T>(runtimeType, this);
|
|
}
|
|
|
|
static _getFromJson<T>(Type type, data, json) {
|
|
switch (type) {
|
|
case PackagesCategoriesResponseModel:
|
|
return offerCategoriesResponseModelFromJson(data as PackagesCategoriesResponseModel, json) as T;
|
|
case OfferCategoriesResponseModelLocalizedName:
|
|
return offerCategoriesResponseModelLocalizedNameFromJson(data as OfferCategoriesResponseModelLocalizedName, json) as T;
|
|
case OfferCategoriesResponseModelImage:
|
|
return offerCategoriesResponseModelImageFromJson(data as OfferCategoriesResponseModelImage, json) as T;
|
|
case LogGeoZoneResponseModel:
|
|
return logGeoZoneResponseModelEntityFromJson(data as LogGeoZoneResponseModel, json) as T;
|
|
case PackagesResponseModel:
|
|
return offerProductsResponseModelFromJson(data as PackagesResponseModel, json) as T;
|
|
case OfferProductsResponseModelLocalizedName:
|
|
return offerProductsResponseModelLocalizedNameFromJson(data as OfferProductsResponseModelLocalizedName, json) as T;
|
|
case OfferProductsResponseModelImage:
|
|
return offerProductsResponseModelImageFromJson(data as OfferProductsResponseModelImage, json) as T;
|
|
case OfferProductsResponseModelSpecification:
|
|
return offerProductsResponseModelSpecificationFromJson(data as OfferProductsResponseModelSpecification, json) as T;
|
|
case GeoZonesResponseModel:
|
|
return geoZonesResponseModelEntityFromJson(data as GeoZonesResponseModel, json) as T;
|
|
}
|
|
return data as T;
|
|
}
|
|
|
|
static _getToJson<T>(Type type, data) {
|
|
switch (type) {
|
|
case PackagesCategoriesResponseModel:
|
|
return offerCategoriesResponseModelToJson(data as PackagesCategoriesResponseModel);
|
|
case OfferCategoriesResponseModelLocalizedName:
|
|
return offerCategoriesResponseModelLocalizedNameToJson(data as OfferCategoriesResponseModelLocalizedName);
|
|
case OfferCategoriesResponseModelImage:
|
|
return offerCategoriesResponseModelImageToJson(data as OfferCategoriesResponseModelImage);
|
|
case LogGeoZoneResponseModel:
|
|
return logGeoZoneResponseModelEntityToJson(data as LogGeoZoneResponseModel);
|
|
case PackagesResponseModel:
|
|
return offerProductsResponseModelToJson(data as PackagesResponseModel);
|
|
case OfferProductsResponseModelLocalizedName:
|
|
return offerProductsResponseModelLocalizedNameToJson(data as OfferProductsResponseModelLocalizedName);
|
|
case OfferProductsResponseModelImage:
|
|
return offerProductsResponseModelImageToJson(data as OfferProductsResponseModelImage);
|
|
case OfferProductsResponseModelSpecification:
|
|
return offerProductsResponseModelSpecificationToJson(data as OfferProductsResponseModelSpecification);
|
|
case GeoZonesResponseModel:
|
|
return geoZonesResponseModelEntityToJson(data as GeoZonesResponseModel);
|
|
}
|
|
return data as T;
|
|
}
|
|
|
|
//Go back to a single instance by type
|
|
static _fromJsonSingle<M>(json) {
|
|
String type = M.toString();
|
|
if (type == (PackagesCategoriesResponseModel).toString()) {
|
|
return PackagesCategoriesResponseModel().fromJson(json);
|
|
} else if (type == (OfferCategoriesResponseModelLocalizedName).toString()) {
|
|
return OfferCategoriesResponseModelLocalizedName().fromJson(json);
|
|
} else if (type == (OfferCategoriesResponseModelImage).toString()) {
|
|
return OfferCategoriesResponseModelImage().fromJson(json);
|
|
} else if (type == (LogGeoZoneResponseModel).toString()) {
|
|
return LogGeoZoneResponseModel().fromJson(json);
|
|
} else if (type == (PackagesResponseModel).toString()) {
|
|
return PackagesResponseModel().fromJson(json);
|
|
} else if (type == (OfferProductsResponseModelLocalizedName).toString()) {
|
|
return OfferProductsResponseModelLocalizedName().fromJson(json);
|
|
} else if (type == (OfferProductsResponseModelImage).toString()) {
|
|
return OfferProductsResponseModelImage().fromJson(json);
|
|
} else if (type == (OfferProductsResponseModelSpecification).toString()) {
|
|
return OfferProductsResponseModelSpecification().fromJson(json);
|
|
} else if (type == (GeoZonesResponseModel).toString()) {
|
|
return GeoZonesResponseModel().fromJson(json);
|
|
}
|
|
return null;
|
|
}
|
|
|
|
//list is returned by type
|
|
static M _getListChildType<M>(List<Map> data) {
|
|
//Changed By Aamir
|
|
if (<PackagesCategoriesResponseModel>[] is M) {
|
|
return data.map((e) => PackagesCategoriesResponseModel().fromJson(e as Map<String, dynamic>)).toList() as M;
|
|
} else if (<OfferCategoriesResponseModelLocalizedName>[] is M) {
|
|
return data.map((e) => OfferCategoriesResponseModelLocalizedName().fromJson(e as Map<String, dynamic>)).toList() as M;
|
|
} else if (<OfferCategoriesResponseModelImage>[] is M) {
|
|
return data.map((e) => OfferCategoriesResponseModelImage().fromJson(e as Map<String, dynamic>)).toList() as M;
|
|
} else if (<LogGeoZoneResponseModel>[] is M) {
|
|
return data.map((e) => LogGeoZoneResponseModel().fromJson(e as Map<String, dynamic>)).toList() as M;
|
|
} else if (<PackagesResponseModel>[] is M) {
|
|
return data.map((e) => PackagesResponseModel().fromJson(e as Map<String, dynamic>)).toList() as M;
|
|
} else if (<OfferProductsResponseModelLocalizedName>[] is M) {
|
|
return data.map((e) => OfferProductsResponseModelLocalizedName().fromJson(e as Map<String, dynamic>)).toList() as M;
|
|
} else if (<OfferProductsResponseModelImage>[] is M) {
|
|
return data.map((e) => OfferProductsResponseModelImage().fromJson(e as Map<String, dynamic>)).toList() as M;
|
|
} else if (<OfferProductsResponseModelSpecification>[] is M) {
|
|
return data.map((e) => OfferProductsResponseModelSpecification().fromJson(e as Map<String, dynamic>)).toList() as M;
|
|
} else if (<GeoZonesResponseModel>[] is M) {
|
|
return data.map((e) => GeoZonesResponseModel().fromJson(e as Map<String, dynamic>)).toList() as M;
|
|
}
|
|
return M as M;
|
|
}
|
|
|
|
// static M _getListChildType<M>(List<Map> data) {
|
|
// if (List<PackagesCategoriesResponseModel>() is M) {
|
|
// return data.map((e) => PackagesCategoriesResponseModel().fromJson(e)).toList() as M;
|
|
// } else if (List<OfferCategoriesResponseModelLocalizedName>() is M) {
|
|
// return data.map((e) => OfferCategoriesResponseModelLocalizedName().fromJson(e)).toList() as M;
|
|
// } else if (List<OfferCategoriesResponseModelImage>() is M) {
|
|
// return data.map((e) => OfferCategoriesResponseModelImage().fromJson(e)).toList() as M;
|
|
// } else if (List<LogGeoZoneResponseModel>() is M) {
|
|
// return data.map((e) => LogGeoZoneResponseModel().fromJson(e)).toList() as M;
|
|
// } else if (List<PackagesResponseModel>() is M) {
|
|
// return data.map((e) => PackagesResponseModel().fromJson(e)).toList() as M;
|
|
// } else if (List<OfferProductsResponseModelLocalizedName>() is M) {
|
|
// return data.map((e) => OfferProductsResponseModelLocalizedName().fromJson(e)).toList() as M;
|
|
// } else if (List<OfferProductsResponseModelImage>() is M) {
|
|
// return data.map((e) => OfferProductsResponseModelImage().fromJson(e)).toList() as M;
|
|
// } else if (List<OfferProductsResponseModelSpecification>() is M) {
|
|
// return data.map((e) => OfferProductsResponseModelSpecification().fromJson(e)).toList() as M;
|
|
// } else if (List<GeoZonesResponseModel>() is M) {
|
|
// return data.map((e) => GeoZonesResponseModel().fromJson(e)).toList() as M;
|
|
// }
|
|
// return null;
|
|
// }
|
|
|
|
static M fromJsonAsT<M>(json) {
|
|
if (json is List) {
|
|
return _getListChildType<M>(json as List<Map<dynamic, dynamic>>);
|
|
//changed by Aamir added after As keyword
|
|
} else {
|
|
return _fromJsonSingle<M>(json) as M;
|
|
}
|
|
}
|
|
}
|