genaric models update #2

Merged
mirzashafique merged 1 commits from mirza_development into master 2 years ago

@ -5,6 +5,7 @@
import 'dart:convert';
import 'package:mc_common_app/models/profile/categroy.dart';
import 'package:mc_common_app/models/services/branch_model.dart';
ProviderModel branch2FromJson(String str) => ProviderModel.fromJson(json.decode(str));
@ -59,7 +60,7 @@ class ProviderModelData {
final int? allDocStatus;
final bool? isValidSubscription;
final String? userId;
final List<ServiceProviderBranch>? serviceProviderBranch;
final List<BranchModel>? serviceProviderBranch;
factory ProviderModelData.fromJson(Map<String, dynamic> json) => ProviderModelData(
id: json["id"] == null ? null : json["id"],
@ -70,7 +71,7 @@ class ProviderModelData {
allDocStatus: json["allDocStatus"] == null ? null : json["allDocStatus"],
isValidSubscription: json["isValidSubscription"] == null ? null : json["isValidSubscription"],
userId: json["userID"] == null ? null : json["userID"],
serviceProviderBranch: json["serviceProviderBranch"] == null ? null : List<ServiceProviderBranch>.from(json["serviceProviderBranch"].map((x) => ServiceProviderBranch.fromJson(x))),
serviceProviderBranch: json["serviceProviderBranch"] == null ? null : List<BranchModel>.from(json["serviceProviderBranch"].map((x) => BranchModel.fromJson(x))),
);
Map<String, dynamic> toJson() => {
@ -84,108 +85,3 @@ class ProviderModelData {
};
}
class ServiceProviderBranch {
ServiceProviderBranch({
this.id,
this.cityId,
this.cityName,
this.branchName,
this.branchDescription,
this.address,
this.latitude,
this.longitude,
this.status,
this.serviceProviderServices,
this.countryID,
this.countryName,
this.categories,
});
final int? id;
int? countryID;
String? countryName;
final int? cityId;
final dynamic? cityName;
final String? branchName;
final String? branchDescription;
final String? address;
final String? latitude;
final String? longitude;
final int? status;
final List<ServiceProviderService>? serviceProviderServices;
List<CategoryData>? categories;
factory ServiceProviderBranch.fromJson(Map<String, dynamic> json) => ServiceProviderBranch(
id: json["id"] == null ? null : json["id"],
countryID: 0,
countryName: "",
cityId: json["cityID"] == null ? null : json["cityID"],
cityName: json["cityName"],
branchName: json["branchName"] == null ? null : json["branchName"],
branchDescription: json["branchDescription"] == null ? null : json["branchDescription"],
address: json["address"] == null ? null : json["address"],
latitude: json["latitude"] == null ? null : json["latitude"],
longitude: json["longitude"] == null ? null : json["longitude"],
status: json["status"] == null ? null : json["status"],
serviceProviderServices: json["serviceProviderServices"] == null ? null : List<ServiceProviderService>.from(json["serviceProviderServices"].map((x) => ServiceProviderService.fromJson(x))),
categories: [],
);
Map<String, dynamic> toJson() => {
"id": id == null ? null : id,
"cityID": cityId == null ? null : cityId,
"cityName": cityName,
"branchName": branchName == null ? null : branchName,
"branchDescription": branchDescription == null ? null : branchDescription,
"address": address == null ? null : address,
"latitude": latitude == null ? null : latitude,
"longitude": longitude == null ? null : longitude,
"status": status == null ? null : status,
"serviceProviderServices": serviceProviderServices == null ? null : List<dynamic>.from(serviceProviderServices!.map((x) => x.toJson())),
};
}
class ServiceProviderService {
ServiceProviderService({
this.serviceId,
this.serviceName,
this.serviceNameN,
this.categoryId,
this.categoryName,
this.serviceStatus,
this.isAllowAppointment,
this.customerLocationRange,
this.rangePricePerKm,
});
final int? serviceId;
final String? serviceName;
final String? serviceNameN;
final int? categoryId;
final String? categoryName;
final int? serviceStatus;
final bool? isAllowAppointment;
final int? customerLocationRange;
final String? rangePricePerKm;
factory ServiceProviderService.fromJson(Map<String, dynamic> json) => ServiceProviderService(
serviceId: json["serviceID"] == null ? null : json["serviceID"],
serviceName: json["serviceName"] == null ? null : json["serviceName"],
serviceNameN: json["serviceNameN"] == null ? null : json["serviceNameN"],
categoryId: json["categoryID"] == null ? null : json["categoryID"],
categoryName: json["categoryName"] == null ? null : json["categoryName"],
serviceStatus: json["serviceStatus"] == null ? null : json["serviceStatus"],
isAllowAppointment: json["isAllowAppointment"] == null ? null : json["isAllowAppointment"],
customerLocationRange: json["customerLocationRange"] == null ? null : json["customerLocationRange"],
rangePricePerKm: json["rangePricePerKm"] == null ? null : json["rangePricePerKm"].toString(),
);
Map<String, dynamic> toJson() => {
"serviceID": serviceId == null ? null : serviceId,
"serviceName": serviceName == null ? null : serviceName,
"serviceNameN": serviceNameN == null ? null : serviceNameN,
"categoryID": categoryId == null ? null : categoryId,
"categoryName": categoryName == null ? null : categoryName,
"serviceStatus": serviceStatus == null ? null : serviceStatus,
};
}

@ -6,6 +6,7 @@ import 'dart:convert';
import 'package:equatable/equatable.dart';
import 'package:mc_common_app/models/model/provider_model.dart';
import 'package:mc_common_app/models/services/service_model.dart';
Category categoryFromJson(String str) => Category.fromJson(json.decode(str));
@ -24,16 +25,14 @@ class Category {
int? messageStatus;
String? message;
factory Category.fromJson(Map<String, dynamic> json) =>
Category(
factory Category.fromJson(Map<String, dynamic> json) => Category(
totalItemsCount: json["totalItemsCount"] == null ? null : json["totalItemsCount"],
data: json["data"] == null ? null : List<CategoryData>.from(json["data"].map((x) => CategoryData.fromJson(x))),
messageStatus: json["messageStatus"] == null ? null : json["messageStatus"],
message: json["message"] == null ? null : json["message"],
);
Map<String, dynamic> toJson() =>
{
Map<String, dynamic> toJson() => {
"totalItemsCount": totalItemsCount == null ? null : totalItemsCount,
"data": data == null ? null : List<dynamic>.from(data!.map((x) => x.toJson())),
"messageStatus": messageStatus == null ? null : messageStatus,
@ -61,10 +60,9 @@ class CategoryData extends Equatable {
dynamic? serviceCategoryImageUrl;
String? branchId;
String? branchName;
List<ServiceProviderService>? services;
List<ServiceModel>? services;
factory CategoryData.fromJson(Map<String, dynamic> json) =>
CategoryData(
factory CategoryData.fromJson(Map<String, dynamic> json) => CategoryData(
id: json["id"] == null ? null : json["id"],
categoryName: json["categoryName"] == null ? null : json["categoryName"],
categoryNameN: json["categoryNameN"] == null ? null : json["categoryNameN"],
@ -73,8 +71,7 @@ class CategoryData extends Equatable {
services: [],
);
Map<String, dynamic> toJson() =>
{
Map<String, dynamic> toJson() => {
"id": id == null ? null : id,
"categoryName": categoryName == null ? null : categoryName,
"categoryNameN": categoryNameN == null ? null : categoryNameN,

@ -1,5 +1,4 @@
import 'package:mc_common_app/models/profile/categroy.dart';
import 'package:mc_common_app/models/services/service_model.dart';
class BranchModel {
@ -18,6 +17,8 @@ class BranchModel {
final int? status;
final dynamic statusText;
final List<ServiceModel>? branchServices;
List<CategoryData>? categories;
bool isExpanded;
BranchModel({
this.id,
@ -35,6 +36,8 @@ class BranchModel {
this.status,
this.statusText,
this.branchServices,
this.categories,
required this.isExpanded,
});
factory BranchModel.fromJson(Map<String, dynamic> json) => BranchModel(
@ -52,7 +55,9 @@ class BranchModel {
closeTime: json["closeTime"],
status: json["status"],
statusText: json["statusText"],
branchServices: json["branchServices"] == null ? [] : List<ServiceModel>.from(json["branchServices"]!.map((x) => ServiceModel.fromJson(x))),
branchServices: json["serviceProviderServices"] == null ? [] : List<ServiceModel>.from(json["serviceProviderServices"]!.map((x) => ServiceModel.fromJson(x))),
categories: [],
isExpanded: false,
);
Map<String, dynamic> toJson() => {
@ -70,6 +75,6 @@ class BranchModel {
"closeTime": closeTime,
"status": status,
"statusText": statusText,
"branchServices": branchServices == null ? [] : List<dynamic>.from(branchServices!.map((x) => x.toJson())),
"serviceProviderServices": branchServices == null ? [] : List<dynamic>.from(branchServices!.map((x) => x.toJson())),
};
}

@ -1,61 +1,70 @@
//TODO: this needs to match with ServiceProviderService from backend side
class ServiceModel {
final int? providerBranchServiceId;
final int? serviceProviderServiceId;
final dynamic providerServiceDescription;
final int? serviceCategoryId;
final int? categoryId;
final String? categoryName;
final int? serviceId;
final String? serviceDescription;
final String? serviceDescriptionN;
final int? status;
final int? serviceStatus;
final dynamic statusText;
final bool? isAllowAppointment;
final bool? isAllowAppointmentHome;
final int? customerLocationRange;
final String? rangePricePerKm;
final int? itemsCount;
bool isExpanded;
ServiceModel({
this.providerBranchServiceId,
this.serviceProviderServiceId,
this.providerServiceDescription,
this.serviceCategoryId,
this.categoryId,
this.categoryName,
this.serviceId,
this.serviceDescription,
this.serviceDescriptionN,
this.status,
this.serviceStatus,
this.statusText,
this.isAllowAppointment,
this.isAllowAppointmentHome,
this.customerLocationRange,
this.rangePricePerKm,
this.itemsCount,
required this.isExpanded,
});
factory ServiceModel.fromJson(Map<String, dynamic> json) =>
ServiceModel(
providerBranchServiceId: json["providerBranchServiceID"],
factory ServiceModel.fromJson(Map<String, dynamic> json) => ServiceModel(
serviceProviderServiceId: json["serviceProviderServiceID"],
providerServiceDescription: json["providerServiceDescription"],
serviceCategoryId: json["serviceCategoryID"],
categoryId: json["categoryID"],
categoryName: json["categoryName"],
serviceId: json["serviceID"],
serviceDescription: json["serviceDescription"],
serviceDescriptionN: json["serviceDescriptionN"],
status: json["status"],
serviceDescription: json["serviceDescription"] ?? json["serviceName"],
serviceDescriptionN: json["serviceDescriptionN"]?? json["serviceNameN"],
serviceStatus: json["serviceStatus"],
statusText: json["statusText"],
isAllowAppointment: json["isAllowAppointment"],
isAllowAppointmentHome: json["isAllowAppointmentHome"],
customerLocationRange: json["customerLocationRange"],
rangePricePerKm: json["rangePricePerKm"].toString(),
itemsCount: json["itemsCount"],
isExpanded: false,
);
Map<String, dynamic> toJson() =>
{
"providerBranchServiceID": providerBranchServiceId,
Map<String, dynamic> toJson() => {
"serviceProviderServiceID": serviceProviderServiceId,
"providerServiceDescription": providerServiceDescription,
"serviceCategoryID": serviceCategoryId,
"categoryID": categoryId,
"categoryName": categoryName,
"serviceID": serviceId,
"serviceDescription": serviceDescription,
"serviceDescriptionN": serviceDescriptionN,
"status": status,
"serviceStatus": serviceStatus,
"statusText": statusText,
"isAllowAppointment": isAllowAppointment,
"isAllowAppointmentHome": isAllowAppointmentHome,
"customerLocationRange": customerLocationRange,
"rangePricePerKm": rangePricePerKm,
"itemsCount": itemsCount,
};
}
}

Loading…
Cancel
Save