50 lines
1.3 KiB
Dart
50 lines
1.3 KiB
Dart
class SalesChannel {
|
|
final int? id;
|
|
final int? userId;
|
|
final String name;
|
|
final String? code;
|
|
final String? icon;
|
|
final int? defaultLedgerId;
|
|
final bool isActive;
|
|
final DateTime? createdAt;
|
|
final DateTime? updatedAt;
|
|
|
|
SalesChannel({
|
|
this.id,
|
|
this.userId,
|
|
required this.name,
|
|
this.code,
|
|
this.icon,
|
|
this.defaultLedgerId,
|
|
this.isActive = true,
|
|
this.createdAt,
|
|
this.updatedAt,
|
|
});
|
|
|
|
factory SalesChannel.fromJson(Map<String, dynamic> json) {
|
|
return SalesChannel(
|
|
id: json['id'],
|
|
userId: json['userId'] ?? json['user_id'],
|
|
name: json['name'] ?? '',
|
|
code: json['code'],
|
|
icon: json['icon'],
|
|
defaultLedgerId: json['defaultLedgerId'] ?? json['default_ledger_id'],
|
|
isActive: json['isActive'] ?? json['is_active'] ?? true,
|
|
createdAt: json['createdAt'] != null ? DateTime.tryParse(json['createdAt']) : null,
|
|
updatedAt: json['updatedAt'] != null ? DateTime.tryParse(json['updatedAt']) : null,
|
|
);
|
|
}
|
|
|
|
Map<String, dynamic> toJson() {
|
|
return {
|
|
if (id != null) 'id': id,
|
|
if (userId != null) 'userId': userId,
|
|
'name': name,
|
|
if (code != null) 'code': code,
|
|
if (icon != null) 'icon': icon,
|
|
if (defaultLedgerId != null) 'defaultLedgerId': defaultLedgerId,
|
|
'isActive': isActive,
|
|
};
|
|
}
|
|
}
|