// To parse this JSON data, do
//
//     final category = categoryFromJson(jsonString);

import 'dart:convert';

import 'package:equatable/equatable.dart';
import 'package:mc_common_app/models/model/branch2.dart';

Category categoryFromJson(String str) => Category.fromJson(json.decode(str));

String categoryToJson(Category data) => json.encode(data.toJson());

class Category {
  Category({
    this.totalItemsCount,
    this.data,
    this.messageStatus,
    this.message,
  });

  int? totalItemsCount;
  List<CategoryData>? data;
  int? messageStatus;
  String? message;

  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() => {
        "totalItemsCount": totalItemsCount == null ? null : totalItemsCount,
        "data": data == null ? null : List<dynamic>.from(data!.map((x) => x.toJson())),
        "messageStatus": messageStatus == null ? null : messageStatus,
        "message": message == null ? null : message,
      };
}

// ignore: must_be_immutable
class CategoryData extends Equatable {
  CategoryData({
    this.id,
    this.categoryName,
    this.categoryNameN,
    this.serviceCategoryIconUrl,
    this.serviceCategoryImageUrl,
    this.services,
  });

  int? id;
  String? categoryName;
  String? categoryNameN;
  dynamic? serviceCategoryIconUrl;
  dynamic? serviceCategoryImageUrl;
  List<ServiceProviderService>? services;

  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"],
        serviceCategoryIconUrl: json["serviceCategoryIconUrl"],
        serviceCategoryImageUrl: json["serviceCategoryImageUrl"],
        services: [],
      );

  Map<String, dynamic> toJson() => {
        "id": id == null ? null : id,
        "categoryName": categoryName == null ? null : categoryName,
        "categoryNameN": categoryNameN == null ? null : categoryNameN,
        "serviceCategoryIconUrl": serviceCategoryIconUrl,
        "serviceCategoryImageUrl": serviceCategoryImageUrl,
      };

  @override
  List<Object> get props => [id ?? 0];
}
