import 'package:e_commerce_training/src/model/response/billing_address.dart';
import 'package:e_commerce_training/src/model/response/billing_profile.dart';

///
/// Code generated by jsonToDartModel https://ashamp.github.io/jsonToDartModel/
///
class UserData {
/*
{
  "CustomerId": 0,
  "FullName": "thanh vu",
  "Email": "thanh@gmail.com",
  "PhoneNumber": "0123456789",
  "Password": "123456",
  "ShippingName": "Nhà",
  "ShippingPhone": "0123456789",
  "ShippingAddress": "Ngo 310 co nhue",
  "ShippingAddress2": "string",
  "ShippingWardId": 1,
  "ShippingCityId": 1,
  "ShippingDistrictId": 1,
  "RefrencesCode": "123",
  "MoneyPoint": 10,
  "IsActive": true,
  "ShippingCityName": "Ha Noi",
  "ShippingDistrictName": "Ba Dinh",
  "ShippingWardName": "Ba Dinh"
}
*/

  int? customerId;
  String? fullName;
  String? email;
  String? phoneNumber;
  String? password;
  String? shippingName;
  String? shippingPhone;
  String? shippingAddress;
  String? shippingAddress2;
  BillingAddress? address;
  int? shippingWardId;
  int? shippingCityId;
  int? shippingDistrictId;
  String? refrencesCode;
  int? moneyPoint;
  bool? isActive;
  String? shippingCityName;
  String? shippingDistrictName;
  String? shippingWardName;

  UserData({
    this.customerId,
    this.fullName,
    this.email,
    this.phoneNumber,
    this.password,
    this.shippingName,
    this.shippingPhone,
    this.shippingAddress,
    this.shippingAddress2,
    this.shippingWardId,
    this.shippingCityId,
    this.shippingDistrictId,
    this.address,
    this.refrencesCode,
    this.moneyPoint,
    this.isActive,
    this.shippingCityName,
    this.shippingDistrictName,
    this.shippingWardName,
  });
  UserData.fromJson(Map<String, dynamic> json) {
    customerId = json["CustomerId"]?.toInt();
    fullName = json["FullName"]?.toString();
    email = json["Email"]?.toString();
    phoneNumber = json["PhoneNumber"]?.toString();
    password = json["Password"]?.toString();
    shippingName = json["ShippingName"]?.toString();
    shippingPhone = json["ShippingPhone"]?.toString();
    shippingAddress = json["ShippingAddress"]?.toString();
    shippingAddress2 = json["ShippingAddress2"]?.toString();
    shippingWardId = json["ShippingWardId"]?.toInt();
    shippingCityId = json["ShippingCityId"]?.toInt();
    shippingDistrictId = json["ShippingDistrictId"]?.toInt();
    if (json['address'] is List) {
      List<BillingAddress> listAddress = [];
      (json['address'] as List).forEach((v) {
        listAddress.add(new BillingAddress.fromJson(v));
      });
      if (listAddress != null && listAddress.isNotEmpty)
        address = listAddress[0];
    } else {
      address = json['address'] != null
          ? BillingProfile.fromJson(json['address']).billingAddress
          : null;
    }
    refrencesCode = json["RefrencesCode"]?.toString();
    moneyPoint = json["MoneyPoint"]?.toInt();
    isActive = json["IsActive"];
    shippingCityName = json["ShippingCityName"]?.toString();
    shippingDistrictName = json["ShippingDistrictName"]?.toString();
    shippingWardName = json["ShippingWardName"]?.toString();
  }
  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = Map<String, dynamic>();
    data["CustomerId"] = customerId;
    data["FullName"] = fullName;
    data["Email"] = email;
    data["PhoneNumber"] = phoneNumber;
    data["Password"] = password;
    data["ShippingName"] = shippingName;
    data["ShippingPhone"] = shippingPhone;
    data["ShippingAddress"] = shippingAddress;
    data["ShippingAddress2"] = shippingAddress2;
    data["ShippingWardId"] = shippingWardId;
    data["ShippingCityId"] = shippingCityId;
    data["ShippingDistrictId"] = shippingDistrictId;
    if (this.address != null) {
      List<BillingAddress> listAddress = [];
      listAddress.add(address!);
      data['address'] = listAddress.map((v) => v.toJson()).toList();
    }
    data["RefrencesCode"] = refrencesCode;
    data["MoneyPoint"] = moneyPoint;
    data["IsActive"] = isActive;
    data["ShippingCityName"] = shippingCityName;
    data["ShippingDistrictName"] = shippingDistrictName;
    data["ShippingWardName"] = shippingWardName;
    return data;
  }
}

class UserResponse {
/*
{
  "totalRecord": 0,
  "isSuccess": true,
  "errorMesssage": "string",
  "Data": {
    "CustomerId": 0,
    "FullName": "thanh vu",
    "Email": "thanh@gmail.com",
    "PhoneNumber": "0123456789",
    "Password": "123456",
    "ShippingName": "Nhà",
    "ShippingPhone": "0123456789",
    "ShippingAddress": "Ngo 310 co nhue",
    "ShippingAddress2": "string",
    "ShippingWardId": 1,
    "ShippingCityId": 1,
    "ShippingDistrictId": 1,
    "RefrencesCode": "123",
    "MoneyPoint": 10,
    "IsActive": true,
    "ShippingCityName": "Ha Noi",
    "ShippingDistrictName": "Ba Dinh",
    "ShippingWardName": "Ba Dinh"
  },
  "message": "string"
}
*/

  int? totalRecord;
  bool? isSuccess;
  String? errorMesssage;
  UserData? data;
  String? message;

  UserResponse({
    this.totalRecord,
    this.isSuccess,
    this.errorMesssage,
    this.data,
    this.message,
  });
  UserResponse.fromJson(Map<String, dynamic> json) {
    totalRecord = json["totalRecord"]?.toInt();
    isSuccess = json["isSuccess"];
    errorMesssage = json["errorMesssage"]?.toString();
    data = (json["Data"] != null) ? UserData.fromJson(json["Data"]) : null;
    message = json["message"]?.toString();
  }
  Map<String, dynamic> toJson() {
    final Map<String, dynamic> json = Map<String, dynamic>();
    json["totalRecord"] = totalRecord;
    json["isSuccess"] = isSuccess;
    json["errorMesssage"] = errorMesssage;
    if (data != null) {
      json["Data"] = data!.toJson();
    }
    json["message"] = message;
    return json;
  }
}
