fix functional bugs
This commit is contained in:
24
lib/domain/entities/client_subscription.dart
Normal file
24
lib/domain/entities/client_subscription.dart
Normal file
@@ -0,0 +1,24 @@
|
||||
import 'package:be_happy/domain/entities/subscription.dart';
|
||||
|
||||
class ClientSubscription {
|
||||
final int id;
|
||||
final int subscriptionId;
|
||||
final Subscription subscription;
|
||||
final DateTime? expiredAt;
|
||||
|
||||
ClientSubscription({
|
||||
required this.id,
|
||||
required this.subscriptionId,
|
||||
required this.subscription,
|
||||
this.expiredAt,
|
||||
});
|
||||
|
||||
factory ClientSubscription.fromJson(Map<String, dynamic> json) {
|
||||
return ClientSubscription(
|
||||
id: json['id'] ?? 0,
|
||||
subscriptionId: json['subscriptionId'] ?? 0,
|
||||
subscription: Subscription.fromJson(json['subscription'] as Map<String, dynamic>),
|
||||
expiredAt: json['expiredAt'] != null ? DateTime.parse(json['expiredAt']) : null,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -43,8 +43,9 @@ class Scooter {
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'Scooter{id: $id, title: $title}';
|
||||
return 'Scooter{id: $id, title: $title, status: $status, latitude: $latitude, longitude: $longitude, batteryLevel: $batteryLevel, isOnline: $isOnline}';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ import 'scooter.dart';
|
||||
class ScooterOrder {
|
||||
final int id;
|
||||
final int scooterId;
|
||||
final Scooter? scooter;
|
||||
final Scooter scooter;
|
||||
final int? planId;
|
||||
final ScooterPlan? plan;
|
||||
final int clientId;
|
||||
@@ -33,7 +33,7 @@ class ScooterOrder {
|
||||
ScooterOrder({
|
||||
required this.id,
|
||||
required this.scooterId,
|
||||
this.scooter,
|
||||
required this.scooter,
|
||||
this.planId,
|
||||
this.plan,
|
||||
required this.clientId,
|
||||
@@ -65,7 +65,7 @@ class ScooterOrder {
|
||||
return ScooterOrder(
|
||||
id: json['id'] ?? 0,
|
||||
scooterId: json['scooterId'] ?? 0,
|
||||
scooter: json['scooter'] != null ? Scooter.fromJson(json['scooter']) : null,
|
||||
scooter: Scooter.fromJson(json['scooter']),
|
||||
planId: json['planId'],
|
||||
plan: json['plan'] != null ? ScooterPlan.fromJson(json['plan']) : null,
|
||||
clientId: json['clientId'] ?? 0,
|
||||
|
||||
@@ -8,6 +8,7 @@ class Subscription {
|
||||
final String fullDescription;
|
||||
final int planId;
|
||||
final bool isActive;
|
||||
final bool isCurrent;
|
||||
final String currency;
|
||||
final DateTime? activeFrom;
|
||||
final DateTime? activeTo;
|
||||
@@ -28,6 +29,7 @@ class Subscription {
|
||||
this.activeTo,
|
||||
required this.createdAt,
|
||||
required this.updatedAt,
|
||||
required this.isCurrent,
|
||||
required this.options,
|
||||
});
|
||||
|
||||
@@ -48,6 +50,7 @@ class Subscription {
|
||||
activeTo: json['activeTo'] != null ? DateTime.parse(json['activeTo']) : null,
|
||||
createdAt: json['createdAt'] != null ? DateTime.parse(json['createdAt']) : DateTime.now(),
|
||||
updatedAt: json['updatedAt'] != null ? DateTime.parse(json['updatedAt']) : DateTime.now(),
|
||||
isCurrent: json['isCurrent'] ?? false,
|
||||
options: optionsData.map((e) => SubscriptionPeriod.fromJson(e as Map<String, dynamic>)).toList(),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user