new project stable version
This commit is contained in:
13
lib/data/models/auth_response_dto.dart
Normal file
13
lib/data/models/auth_response_dto.dart
Normal file
@@ -0,0 +1,13 @@
|
||||
class AuthResponseDto {
|
||||
final String accessToken;
|
||||
final String refreshToken;
|
||||
|
||||
AuthResponseDto({required this.accessToken, required this.refreshToken});
|
||||
|
||||
factory AuthResponseDto.fromJson(Map<String, dynamic> json) {
|
||||
return AuthResponseDto(
|
||||
accessToken: json["accessToken"] ?? "",
|
||||
refreshToken: json["refreshToken"] ?? "",
|
||||
);
|
||||
}
|
||||
}
|
||||
83
lib/data/models/client_notification_dto.dart
Normal file
83
lib/data/models/client_notification_dto.dart
Normal file
@@ -0,0 +1,83 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import '../../domain/entities/client_notification.dart';
|
||||
|
||||
class ClientNotificationDto {
|
||||
final int id;
|
||||
final String content;
|
||||
final int clientId;
|
||||
final String type;
|
||||
final String category;
|
||||
final String createdAt;
|
||||
final String? canceledAt;
|
||||
final String? readAt;
|
||||
|
||||
ClientNotificationDto({
|
||||
required this.id,
|
||||
required this.content,
|
||||
required this.clientId,
|
||||
required this.type,
|
||||
required this.category,
|
||||
required this.createdAt,
|
||||
this.canceledAt,
|
||||
this.readAt,
|
||||
});
|
||||
|
||||
factory ClientNotificationDto.fromJson(Map<String, dynamic> json) {
|
||||
return ClientNotificationDto(
|
||||
id: json['id'] as int,
|
||||
content: json['content'] as String,
|
||||
clientId: json['clientId'] as int,
|
||||
type: json['type'] as String,
|
||||
category: json['category'] as String,
|
||||
createdAt: json['createdAt'] as String,
|
||||
canceledAt: json['canceledAt'] as String?,
|
||||
readAt: json['readAt'] as String?,
|
||||
);
|
||||
}
|
||||
|
||||
ClientNotification toEntity() {
|
||||
return ClientNotification(
|
||||
id: id,
|
||||
content: content,
|
||||
clientId: clientId,
|
||||
type: _parseType(type),
|
||||
category: _parseCategory(category),
|
||||
createdAt: DateTime.parse(createdAt),
|
||||
canceledAt: canceledAt != null ? DateTime.parse(canceledAt!) : null,
|
||||
readAt: readAt != null ? DateTime.parse(readAt!) : null,
|
||||
);
|
||||
}
|
||||
|
||||
NotificationType _parseType(String type) {
|
||||
switch (type.toLowerCase()) {
|
||||
case 'info':
|
||||
return NotificationType.info;
|
||||
case 'attention':
|
||||
return NotificationType.attention;
|
||||
case 'warning':
|
||||
return NotificationType.warning;
|
||||
default:
|
||||
return NotificationType.info;
|
||||
}
|
||||
}
|
||||
|
||||
NotificationCategory _parseCategory(String category) {
|
||||
switch (category.toLowerCase()) {
|
||||
case 'auth':
|
||||
return NotificationCategory.auth;
|
||||
case 'zone':
|
||||
return NotificationCategory.zone;
|
||||
case 'payment':
|
||||
return NotificationCategory.payment;
|
||||
case 'companyinfo':
|
||||
return NotificationCategory.companyInfo;
|
||||
case 'admininfo':
|
||||
return NotificationCategory.adminInfo;
|
||||
case 'scooter':
|
||||
return NotificationCategory.scooter;
|
||||
default:
|
||||
return NotificationCategory.companyInfo;
|
||||
}
|
||||
}
|
||||
}
|
||||
9
lib/data/models/login_request_dto.dart
Normal file
9
lib/data/models/login_request_dto.dart
Normal file
@@ -0,0 +1,9 @@
|
||||
class LoginRequestDto {
|
||||
final String phone;
|
||||
|
||||
LoginRequestDto({required this.phone});
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {"phone": phone};
|
||||
}
|
||||
}
|
||||
25
lib/data/models/payment_card_request_dto.dart
Normal file
25
lib/data/models/payment_card_request_dto.dart
Normal file
@@ -0,0 +1,25 @@
|
||||
class PaymentCardRequestDto {
|
||||
final String cardNumber;
|
||||
final String cardHolder;
|
||||
final int expirationMonth;
|
||||
final int expirationYear;
|
||||
final String cvv;
|
||||
|
||||
PaymentCardRequestDto({
|
||||
required this.cardNumber,
|
||||
required this.cardHolder,
|
||||
required this.expirationMonth,
|
||||
required this.expirationYear,
|
||||
required this.cvv,
|
||||
});
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'cardNumber': cardNumber.replaceAll(' ', ''),
|
||||
'cardHolder': cardHolder,
|
||||
'expirationMonth': expirationMonth,
|
||||
'expirationYear': expirationYear,
|
||||
'cvv': cvv,
|
||||
};
|
||||
}
|
||||
}
|
||||
49
lib/data/models/payment_card_response_dto.dart
Normal file
49
lib/data/models/payment_card_response_dto.dart
Normal file
@@ -0,0 +1,49 @@
|
||||
import '../../domain/entities/payment_card.dart';
|
||||
|
||||
class PaymentCardResponseDto {
|
||||
final int id;
|
||||
final int clientId;
|
||||
final int expirationMonth;
|
||||
final int expirationYear;
|
||||
final String cardHolder;
|
||||
final String cardLastNumber;
|
||||
final String type;
|
||||
final bool isMain;
|
||||
|
||||
PaymentCardResponseDto({
|
||||
required this.id,
|
||||
required this.clientId,
|
||||
required this.expirationMonth,
|
||||
required this.expirationYear,
|
||||
required this.cardHolder,
|
||||
required this.cardLastNumber,
|
||||
required this.type,
|
||||
required this.isMain,
|
||||
});
|
||||
|
||||
factory PaymentCardResponseDto.fromJson(Map<String, dynamic> json) {
|
||||
return PaymentCardResponseDto(
|
||||
id: json['id'] as int,
|
||||
clientId: json['clientId'] as int,
|
||||
expirationMonth: json['expirationMonth'] as int,
|
||||
expirationYear: json['expirationYear'] as int,
|
||||
cardHolder: json['cardHolder'] as String,
|
||||
cardLastNumber: json['cardLastNumber'] as String,
|
||||
isMain: json['isMain'] as bool,
|
||||
type: json['type'] as String,
|
||||
);
|
||||
}
|
||||
|
||||
PaymentCard toEntity(String? fullCardNumber) {
|
||||
return PaymentCard(
|
||||
id: id,
|
||||
clientId: clientId,
|
||||
expirationMonth: expirationMonth,
|
||||
expirationYear: expirationYear,
|
||||
cardHolder: cardHolder,
|
||||
cardLastNumber: cardLastNumber,
|
||||
isMain: isMain,
|
||||
type: type,
|
||||
);
|
||||
}
|
||||
}
|
||||
21
lib/data/models/scooter_order_history_response.dart
Normal file
21
lib/data/models/scooter_order_history_response.dart
Normal file
@@ -0,0 +1,21 @@
|
||||
import '../../domain/entities/scooter_order.dart';
|
||||
import '../../domain/entities/pagination.dart';
|
||||
|
||||
class ScooterOrderHistoryResponse {
|
||||
final List<ScooterOrder> orders;
|
||||
final Pagination pagination;
|
||||
|
||||
ScooterOrderHistoryResponse({
|
||||
required this.orders,
|
||||
required this.pagination,
|
||||
});
|
||||
|
||||
factory ScooterOrderHistoryResponse.fromJson(Map<String, dynamic> json) {
|
||||
return ScooterOrderHistoryResponse(
|
||||
orders: (json['data'] as List<dynamic>)
|
||||
.map((e) => ScooterOrder.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
pagination: Pagination.fromJson(json['pagination']),
|
||||
);
|
||||
}
|
||||
}
|
||||
21
lib/data/models/scooters_response.dart
Normal file
21
lib/data/models/scooters_response.dart
Normal file
@@ -0,0 +1,21 @@
|
||||
import '../../domain/entities/pagination.dart';
|
||||
import '../../domain/entities/scooter.dart';
|
||||
|
||||
class ScootersResponse {
|
||||
final List<Scooter> scooters;
|
||||
final Pagination pagination;
|
||||
|
||||
ScootersResponse({
|
||||
required this.scooters,
|
||||
required this.pagination,
|
||||
});
|
||||
|
||||
factory ScootersResponse.fromJson(Map<String, dynamic> json) {
|
||||
return ScootersResponse(
|
||||
scooters: (json['data'] as List<dynamic>)
|
||||
.map((e) => Scooter.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
pagination: Pagination.fromJson(json['pagination']),
|
||||
);
|
||||
}
|
||||
}
|
||||
15
lib/data/models/subscriptions_response.dart
Normal file
15
lib/data/models/subscriptions_response.dart
Normal file
@@ -0,0 +1,15 @@
|
||||
import 'package:be_happy/domain/entities/subscription.dart';
|
||||
|
||||
class SubscriptionsResponse {
|
||||
final List<Subscription> subscriptions;
|
||||
|
||||
SubscriptionsResponse({required this.subscriptions});
|
||||
|
||||
factory SubscriptionsResponse.fromJson(Map<String, dynamic> json) {
|
||||
return SubscriptionsResponse(
|
||||
subscriptions: (json['data'] as List<dynamic>)
|
||||
.map((e) => Subscription.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
);
|
||||
}
|
||||
}
|
||||
15
lib/data/models/tariffs_response.dart
Normal file
15
lib/data/models/tariffs_response.dart
Normal file
@@ -0,0 +1,15 @@
|
||||
import 'package:be_happy/domain/entities/tariff.dart';
|
||||
|
||||
class TariffsResponse {
|
||||
final List<Tariff> tariffs;
|
||||
|
||||
TariffsResponse({required this.tariffs});
|
||||
|
||||
factory TariffsResponse.fromJson(Map<String, dynamic> json) {
|
||||
return TariffsResponse(
|
||||
tariffs: (json['data'] as List<dynamic>)
|
||||
.map((e) => Tariff.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
);
|
||||
}
|
||||
}
|
||||
22
lib/data/models/user_check_response_dto.dart
Normal file
22
lib/data/models/user_check_response_dto.dart
Normal file
@@ -0,0 +1,22 @@
|
||||
class UserCheckResponseDto {
|
||||
final bool success;
|
||||
final bool hasFine;
|
||||
final bool hasUnpaidOrder;
|
||||
final bool hasCard;
|
||||
|
||||
UserCheckResponseDto({
|
||||
required this.success,
|
||||
required this.hasFine,
|
||||
required this.hasUnpaidOrder,
|
||||
required this.hasCard,
|
||||
});
|
||||
|
||||
factory UserCheckResponseDto.fromJson(Map<String, dynamic> json) {
|
||||
return UserCheckResponseDto(
|
||||
success: json['success'] ?? false,
|
||||
hasFine: json['hasFine'] ?? false,
|
||||
hasUnpaidOrder: json['hasUnpaidOrder'] ?? false,
|
||||
hasCard: json['hasCard'] ?? false,
|
||||
);
|
||||
}
|
||||
}
|
||||
10
lib/data/models/verify_code_request_dto.dart
Normal file
10
lib/data/models/verify_code_request_dto.dart
Normal file
@@ -0,0 +1,10 @@
|
||||
class VerifyCodeRequestDto {
|
||||
final String code;
|
||||
final String token;
|
||||
|
||||
VerifyCodeRequestDto({required this.code, required this.token});
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {"code": code, "token": token};
|
||||
}
|
||||
}
|
||||
22
lib/data/models/zones_response.dart
Normal file
22
lib/data/models/zones_response.dart
Normal file
@@ -0,0 +1,22 @@
|
||||
import '../../domain/entities/pagination.dart';
|
||||
import '../../domain/entities/scooter.dart';
|
||||
import '../../domain/entities/zone.dart';
|
||||
|
||||
class ZonesResponse {
|
||||
final List<Zone> zones;
|
||||
final Pagination pagination;
|
||||
|
||||
ZonesResponse({
|
||||
required this.zones,
|
||||
required this.pagination,
|
||||
});
|
||||
|
||||
factory ZonesResponse.fromJson(Map<String, dynamic> json) {
|
||||
return ZonesResponse(
|
||||
zones: (json['data'] as List<dynamic>)
|
||||
.map((e) => Zone.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
pagination: Pagination.fromJson(json['pagination']),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user