// To parse this JSON data, do
//
//     final subscription = subscriptionFromJson(jsonString);

import 'dart:convert';

import 'package:mc_common_app/extensions/string_extensions.dart';

import '../../utils/enums.dart';

Subscription subscriptionFromJson(String str) => Subscription.fromJson(json.decode(str));

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

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

  factory SubscriptionModel.fromJson(Map<String, dynamic> json) => SubscriptionModel(
        messageStatus: json["messageStatus"],
        totalItemsCount: json["totalItemsCount"],
        data: json["data"] == null ? [] : List<Subscription>.from(json["data"]!.map((x) => Subscription.fromJson(x))),
        message: json["message"],
      );
}

class Subscription {
  Subscription(
      {this.id,
      this.name,
      this.description,
      this.durationName,
      this.durationDays,
      this.price,
      this.currency,
      this.countryId,
      this.countryName,
      this.isSubscribed,
      this.subscriptionAppliedId,
      this.serviceProviderId,
      this.dateStart,
      this.dateEnd,
      this.isExpired,
      this.isActive,
      this.subscriptionTypeEnum,
      this.isMyCurrentPackage,
      this.isRenewable,
      this.subscriptionBranches,
      this.subscriptionSubUsers,
      this.subscriptionAds,
      this.totalBranches,
      this.totalSubUsers,
      this.totalAds,
      this.branchesRemaining,
      this.subUsersRemaining,
      this.adsRemaining});

  int? id;
  String? name;
  String? description;
  String? durationName;
  int? durationDays;
  double? price;
  String? currency;
  int? countryId;
  String? countryName;
  bool? isSubscribed;
  int? subscriptionAppliedId;
  int? serviceProviderId;
  String? dateStart;
  String? dateEnd;
  bool? isExpired;
  bool? isActive;
  SubscriptionTypeEnum? subscriptionTypeEnum;
  bool? isMyCurrentPackage;
  bool? isRenewable;

  int? subscriptionBranches;
  int? subscriptionSubUsers;
  int? subscriptionAds;
  int? totalBranches;
  int? totalSubUsers;
  int? totalAds;
  int? branchesRemaining;
  int? subUsersRemaining;
  int? adsRemaining;

  factory Subscription.fromJson(Map<String, dynamic> json) => Subscription(
        id: json["id"],
        name: json["name"],
        description: json["description"],
        durationName: json["durationName"],
        durationDays: json["durationDays"],
        price: json["price"]?.toDouble(),
        currency: json["currency"],
        countryId: json["countryID"],
        countryName: json["countryName"],
        isSubscribed: json["isSubscribed"],
        subscriptionAppliedId: json["subscriptionAppliedID"],
        serviceProviderId: json["serviceProviderID"],
        dateStart: json["dateStart"],
        dateEnd: json["dateEnd"],
        isExpired: json["isExpired"],
        isActive: json["isActive"],
        isMyCurrentPackage: false,
        isRenewable: json["isRenewable"],
        subscriptionTypeEnum: json["subscriptionType"] == null ? null : ((json['subscriptionType']) as int).toSubscriptionTypeEnum(),
        subscriptionBranches: json["subscriptionBranches"],
        subscriptionSubUsers: json["subscriptionSubUsers"],
        subscriptionAds: json["subscriptionAds"],
        totalBranches: json["totalBranches"],
        totalSubUsers: json["totalBranches"],
        totalAds: json["totalAds"],
        branchesRemaining: json["branchesRemaining"],
        subUsersRemaining: json["subUsersRemaining"],
        adsRemaining: json["adsRemaining"],
      );
}
