Files
voidea/flutter/lib/models/tariff.dart
T

40 lines
1.1 KiB
Dart

class Tariff {
final String id;
final String name;
final double price;
final String currency;
final Map<String, dynamic> features;
final bool isActive;
final DateTime createdAt;
Tariff({
required this.id,
required this.name,
required this.price,
this.currency = 'RUB',
required this.features,
this.isActive = true,
required this.createdAt,
});
factory Tariff.fromJson(Map<String, dynamic> json) => Tariff(
id: json['id'] as String,
name: json['name'] as String,
price: (json['price'] as num).toDouble(),
currency: json['currency'] as String? ?? 'RUB',
features: json['features'] as Map<String, dynamic>? ?? {},
isActive: json['is_active'] as bool? ?? true,
createdAt: DateTime.parse(json['created_at'] as String),
);
Map<String, dynamic> toJson() => {
'id': id,
'name': name,
'price': price,
'currency': currency,
'features': features,
'is_active': isActive,
'created_at': createdAt.toIso8601String(),
};
}