Initial commit
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
import 'package:cargocalculaterapp/features/home/data/models/comment_request.dart';
|
||||
import 'package:cargocalculaterapp/features/home/data/models/comment_response.dart';
|
||||
import 'package:cargocalculaterapp/features/home/data/models/notification_response.dart';
|
||||
import 'package:cargocalculaterapp/features/home/data/models/order_single_response.dart';
|
||||
import 'package:cargocalculaterapp/features/home/data/models/orders_list_response.dart';
|
||||
import 'package:cargocalculaterapp/features/home/data/models/read_notification_request.dart';
|
||||
import 'package:cargocalculaterapp/features/home/data/models/read_notification_response.dart';
|
||||
|
||||
import '../../models/banner_response.dart';
|
||||
|
||||
abstract class HomeRemoteDataSource {
|
||||
Future<OrdersListResponse> ordersList(Map<String, dynamic> request);
|
||||
|
||||
Future<OrderSingleResponse> orderSingle(String orderId);
|
||||
|
||||
Future<CommentResponse> comment(CommentRequest request);
|
||||
|
||||
Future<NotificationResponse> notification(Map<String, dynamic> request);
|
||||
|
||||
Future<ReadNotificationResponse> notificationRead(
|
||||
ReadNotificationRequest request,
|
||||
);
|
||||
|
||||
Future<List<BannerResponse>> bannersResponse();
|
||||
}
|
||||
@@ -0,0 +1,157 @@
|
||||
import 'package:cargocalculaterapp/features/home/data/models/banner_response.dart';
|
||||
import 'package:cargocalculaterapp/features/home/data/models/comment_request.dart';
|
||||
import 'package:cargocalculaterapp/features/home/data/models/comment_response.dart';
|
||||
import 'package:cargocalculaterapp/features/home/data/models/notification_response.dart';
|
||||
import 'package:cargocalculaterapp/features/home/data/models/order_single_response.dart';
|
||||
import 'package:cargocalculaterapp/features/home/data/models/orders_list_response.dart';
|
||||
import 'package:cargocalculaterapp/features/home/data/models/read_notification_request.dart';
|
||||
import 'package:cargocalculaterapp/features/home/data/models/read_notification_response.dart';
|
||||
import 'package:dio/dio.dart';
|
||||
import '../../../../../constants/constants.dart';
|
||||
import '../../../../../core/error/exceptions.dart';
|
||||
import '../../../../../core/local_source/local_source.dart';
|
||||
import '../../../../../injector_container.dart';
|
||||
import 'home_remote_data_source.dart';
|
||||
|
||||
class HomeRemoteDataSourceImpl extends HomeRemoteDataSource {
|
||||
final Dio dio;
|
||||
|
||||
HomeRemoteDataSourceImpl(this.dio);
|
||||
|
||||
@override
|
||||
Future<OrdersListResponse> ordersList(Map<String, dynamic> request) async {
|
||||
try {
|
||||
final Response response = await dio.get(
|
||||
Constants.baseUrl + Urls.orderList,
|
||||
options: DioConstants.options
|
||||
..headers = {
|
||||
"Authorization": "Bearer ${sl<LocalSource>().getAccessToken()}",
|
||||
},
|
||||
queryParameters: request,
|
||||
);
|
||||
if (response.statusCode == 200 || response.statusCode == 201) {
|
||||
return OrdersListResponse.fromJson(response.data);
|
||||
}
|
||||
throw ServerException.fromJson(response.data);
|
||||
} on DioException catch (e) {
|
||||
throw ServerException.fromJson(e.response?.data);
|
||||
} on FormatException {
|
||||
throw ServerException(message: Validations.someThingWentWrong);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<OrderSingleResponse> orderSingle(String orderId) async {
|
||||
try {
|
||||
final Response response = await dio.get(
|
||||
"${Constants.baseUrl}${Urls.orderList}/$orderId",
|
||||
options: DioConstants.options
|
||||
..headers = {
|
||||
"Authorization": "Bearer ${sl<LocalSource>().getAccessToken()}",
|
||||
},
|
||||
);
|
||||
if (response.statusCode == 200 || response.statusCode == 201) {
|
||||
return OrderSingleResponse.fromJson(response.data);
|
||||
}
|
||||
throw ServerException.fromJson(response.data);
|
||||
} on DioException catch (e) {
|
||||
throw ServerException.fromJson(e.response?.data);
|
||||
} on FormatException {
|
||||
throw ServerException(message: Validations.someThingWentWrong);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<CommentResponse> comment(CommentRequest request) async {
|
||||
try {
|
||||
final Response response = await dio.post(
|
||||
"${Constants.baseUrl}${Urls.comment}",
|
||||
options: DioConstants.options
|
||||
..headers = {
|
||||
"Authorization": "Bearer ${sl<LocalSource>().getAccessToken()}",
|
||||
},
|
||||
data: request,
|
||||
);
|
||||
if (response.statusCode == 200 || response.statusCode == 201) {
|
||||
return CommentResponse.fromJson(response.data);
|
||||
}
|
||||
throw ServerException.fromJson(response.data);
|
||||
} on DioException catch (e) {
|
||||
throw ServerException.fromJson(e.response?.data);
|
||||
} on FormatException {
|
||||
throw ServerException(message: Validations.someThingWentWrong);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<NotificationResponse> notification(
|
||||
Map<String, dynamic> request,
|
||||
) async {
|
||||
try {
|
||||
final Response response = await dio.get(
|
||||
"${Constants.baseUrl}${Urls.notification}",
|
||||
options: DioConstants.options
|
||||
..headers = {
|
||||
"Authorization": "Bearer ${sl<LocalSource>().getAccessToken()}",
|
||||
},
|
||||
queryParameters: request,
|
||||
);
|
||||
if (response.statusCode == 200 || response.statusCode == 201) {
|
||||
return NotificationResponse.fromJson(response.data);
|
||||
}
|
||||
throw ServerException.fromJson(response.data);
|
||||
} on DioException catch (e) {
|
||||
throw ServerException.fromJson(e.response?.data);
|
||||
} on FormatException {
|
||||
throw ServerException(message: Validations.someThingWentWrong);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<ReadNotificationResponse> notificationRead(
|
||||
ReadNotificationRequest request,
|
||||
) async {
|
||||
try {
|
||||
final Response response = await dio.put(
|
||||
"${Constants.baseUrl}${Urls.notificationRead}",
|
||||
options: DioConstants.options
|
||||
..headers = {
|
||||
"Authorization": "Bearer ${sl<LocalSource>().getAccessToken()}",
|
||||
},
|
||||
data: request,
|
||||
);
|
||||
if (response.statusCode == 200 || response.statusCode == 201) {
|
||||
return ReadNotificationResponse.fromJson(response.data);
|
||||
}
|
||||
throw ServerException.fromJson(response.data);
|
||||
} on DioException catch (e) {
|
||||
throw ServerException.fromJson(e.response?.data);
|
||||
} on FormatException {
|
||||
throw ServerException(message: Validations.someThingWentWrong);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<List<BannerResponse>> bannersResponse() async {
|
||||
try {
|
||||
final Response response = await dio.get(
|
||||
"${Constants.baseUrl}${Urls.banners}",
|
||||
options: DioConstants.options
|
||||
..headers = {
|
||||
"Authorization": "Bearer ${sl<LocalSource>().getAccessToken()}",
|
||||
},
|
||||
);
|
||||
if (response.statusCode == 200 || response.statusCode == 201) {
|
||||
final List<BannerResponse> images = (response.data as List)
|
||||
.map((json) => BannerResponse.fromJson(json))
|
||||
.toList();
|
||||
return images;
|
||||
}
|
||||
throw ServerException.fromJson(response.data);
|
||||
} on DioException catch (e) {
|
||||
throw ServerException.fromJson(e.response?.data);
|
||||
} on FormatException {
|
||||
throw ServerException(message: Validations.someThingWentWrong);
|
||||
}
|
||||
}
|
||||
}
|
||||
27
lib/features/home/data/models/banner_response.dart
Normal file
27
lib/features/home/data/models/banner_response.dart
Normal file
@@ -0,0 +1,27 @@
|
||||
class BannerResponse {
|
||||
BannerResponse({this.id, this.image, this.createdAt, this.updatedAt, this.v});
|
||||
|
||||
BannerResponse.fromJson(dynamic json) {
|
||||
id = json['_id'];
|
||||
image = json['image'];
|
||||
createdAt = json['createdAt'];
|
||||
updatedAt = json['updatedAt'];
|
||||
v = json['__v'];
|
||||
}
|
||||
|
||||
String? id;
|
||||
String? image;
|
||||
String? createdAt;
|
||||
String? updatedAt;
|
||||
int? v;
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final map = <String, dynamic>{};
|
||||
map['_id'] = id;
|
||||
map['image'] = image;
|
||||
map['createdAt'] = createdAt;
|
||||
map['updatedAt'] = updatedAt;
|
||||
map['__v'] = v;
|
||||
return map;
|
||||
}
|
||||
}
|
||||
24
lib/features/home/data/models/comment_request.dart
Normal file
24
lib/features/home/data/models/comment_request.dart
Normal file
@@ -0,0 +1,24 @@
|
||||
class CommentRequest {
|
||||
CommentRequest({
|
||||
this.message,
|
||||
this.rate,
|
||||
this.orderNumber,});
|
||||
|
||||
CommentRequest.fromJson(dynamic json) {
|
||||
message = json['message'];
|
||||
rate = json['rate'];
|
||||
orderNumber = json['order_number'];
|
||||
}
|
||||
String? message;
|
||||
int? rate;
|
||||
String? orderNumber;
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final map = <String, dynamic>{};
|
||||
map['message'] = message;
|
||||
map['rate'] = rate;
|
||||
map['order_number'] = orderNumber;
|
||||
return map;
|
||||
}
|
||||
|
||||
}
|
||||
44
lib/features/home/data/models/comment_response.dart
Normal file
44
lib/features/home/data/models/comment_response.dart
Normal file
@@ -0,0 +1,44 @@
|
||||
class CommentResponse {
|
||||
CommentResponse({
|
||||
this.message,
|
||||
this.rate,
|
||||
this.userUcode,
|
||||
this.orderNumber,
|
||||
this.id,
|
||||
this.createdAt,
|
||||
this.updatedAt,
|
||||
this.v,});
|
||||
|
||||
CommentResponse.fromJson(dynamic json) {
|
||||
message = json['message'];
|
||||
rate = json['rate'];
|
||||
userUcode = json['user_ucode'];
|
||||
orderNumber = json['order_number'];
|
||||
id = json['_id'];
|
||||
createdAt = json['createdAt'];
|
||||
updatedAt = json['updatedAt'];
|
||||
v = json['__v'];
|
||||
}
|
||||
String? message;
|
||||
int? rate;
|
||||
String? userUcode;
|
||||
String? orderNumber;
|
||||
String? id;
|
||||
String? createdAt;
|
||||
String? updatedAt;
|
||||
int? v;
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final map = <String, dynamic>{};
|
||||
map['message'] = message;
|
||||
map['rate'] = rate;
|
||||
map['user_ucode'] = userUcode;
|
||||
map['order_number'] = orderNumber;
|
||||
map['_id'] = id;
|
||||
map['createdAt'] = createdAt;
|
||||
map['updatedAt'] = updatedAt;
|
||||
map['__v'] = v;
|
||||
return map;
|
||||
}
|
||||
|
||||
}
|
||||
79
lib/features/home/data/models/notification_response.dart
Normal file
79
lib/features/home/data/models/notification_response.dart
Normal file
@@ -0,0 +1,79 @@
|
||||
import 'package:cargocalculaterapp/core/models/name.dart';
|
||||
|
||||
class NotificationResponse {
|
||||
NotificationResponse({this.notifications, this.totalCount});
|
||||
|
||||
NotificationResponse.fromJson(dynamic json) {
|
||||
if (json['notifications'] != null) {
|
||||
notifications = [];
|
||||
json['notifications'].forEach((v) {
|
||||
notifications?.add(Notifications.fromJson(v));
|
||||
});
|
||||
}
|
||||
totalCount = json['totalCount'];
|
||||
}
|
||||
|
||||
List<Notifications>? notifications;
|
||||
int? totalCount;
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final map = <String, dynamic>{};
|
||||
if (notifications != null) {
|
||||
map['notifications'] = notifications?.map((v) => v.toJson()).toList();
|
||||
}
|
||||
map['totalCount'] = totalCount;
|
||||
return map;
|
||||
}
|
||||
}
|
||||
|
||||
class Notifications {
|
||||
Notifications({
|
||||
this.id,
|
||||
this.userUcode,
|
||||
this.orderNumber,
|
||||
this.text,
|
||||
this.status,
|
||||
this.isRead,
|
||||
this.createdAt,
|
||||
this.updatedAt,
|
||||
this.v,
|
||||
});
|
||||
|
||||
Notifications.fromJson(dynamic json) {
|
||||
id = json['_id'];
|
||||
userUcode = json['user_ucode'];
|
||||
orderNumber = json['order_number'];
|
||||
text = json['text'] != null ? Name.fromJson(json['text']) : null;
|
||||
status = json['status'];
|
||||
isRead = json['is_read'];
|
||||
createdAt = json['createdAt'];
|
||||
updatedAt = json['updatedAt'];
|
||||
v = json['__v'];
|
||||
}
|
||||
|
||||
String? id;
|
||||
String? userUcode;
|
||||
String? orderNumber;
|
||||
Name? text;
|
||||
String? status;
|
||||
bool? isRead;
|
||||
String? createdAt;
|
||||
String? updatedAt;
|
||||
int? v;
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final map = <String, dynamic>{};
|
||||
map['_id'] = id;
|
||||
map['user_ucode'] = userUcode;
|
||||
map['order_number'] = orderNumber;
|
||||
if (text != null) {
|
||||
map['text'] = text?.toJson();
|
||||
}
|
||||
map['status'] = status;
|
||||
map['is_read'] = isRead;
|
||||
map['createdAt'] = createdAt;
|
||||
map['updatedAt'] = updatedAt;
|
||||
map['__v'] = v;
|
||||
return map;
|
||||
}
|
||||
}
|
||||
145
lib/features/home/data/models/order_single_response.dart
Normal file
145
lib/features/home/data/models/order_single_response.dart
Normal file
@@ -0,0 +1,145 @@
|
||||
import 'package:cargocalculaterapp/core/models/name.dart';
|
||||
|
||||
class OrderSingleResponse {
|
||||
OrderSingleResponse({
|
||||
this.id,
|
||||
this.userUcode,
|
||||
this.phoneNumber,
|
||||
this.gmail,
|
||||
this.quantity,
|
||||
this.nameUz,
|
||||
this.nameRu,
|
||||
this.nameZh,
|
||||
this.weight,
|
||||
this.m3,
|
||||
this.averageWeightKg,
|
||||
this.wharehouseUz,
|
||||
this.wharehouseRu,
|
||||
this.wharehouseZh,
|
||||
this.deliveryPrice,
|
||||
this.shipmentId,
|
||||
this.leadId,
|
||||
this.status,
|
||||
this.partiallyArrived,
|
||||
this.fullArrived,
|
||||
this.orderNumber,
|
||||
this.createdAt,
|
||||
this.updatedAt,
|
||||
this.v,
|
||||
this.arrivalDate,
|
||||
this.images,
|
||||
});
|
||||
|
||||
OrderSingleResponse.fromJson(dynamic json) {
|
||||
userUcode = json['user_ucode'];
|
||||
phoneNumber = json['phone_number'];
|
||||
gmail = json['gmail'];
|
||||
quantity = json['quantity'];
|
||||
nameUz = json['nameUz'];
|
||||
nameRu = json['nameRu'];
|
||||
nameZh = json['nameZh'];
|
||||
weight = json['weight'];
|
||||
m3 = json['m3'];
|
||||
averageWeightKg = json['average_weight_kg'];
|
||||
wharehouseUz = json['wharehouseUz'];
|
||||
wharehouseRu = json['wharehouseRu'];
|
||||
wharehouseZh = json['wharehouseZh'];
|
||||
deliveryPrice = json['delivery_price'];
|
||||
shipmentId = json['shipment_id'];
|
||||
leadId = json['lead_id'];
|
||||
status = json['status'] != null ? Status.fromJson(json['status']) : null;
|
||||
partiallyArrived = json['partially_arrived'];
|
||||
fullArrived = json['full_arrived'];
|
||||
orderNumber = json['order_number'];
|
||||
createdAt = json['createdAt'];
|
||||
updatedAt = json['updatedAt'];
|
||||
v = json['__v'];
|
||||
id = json['id'];
|
||||
arrivalDate = json['arrival_date'];
|
||||
images = json['images'] != null ? json['images'].cast<String>() : [];
|
||||
}
|
||||
|
||||
String? userUcode;
|
||||
String? phoneNumber;
|
||||
String? gmail;
|
||||
int? quantity;
|
||||
String? nameUz;
|
||||
String? nameRu;
|
||||
String? nameZh;
|
||||
String? weight;
|
||||
String? m3;
|
||||
String? averageWeightKg;
|
||||
String? wharehouseUz;
|
||||
String? wharehouseRu;
|
||||
String? wharehouseZh;
|
||||
String? deliveryPrice;
|
||||
String? shipmentId;
|
||||
String? leadId;
|
||||
Status? status;
|
||||
bool? partiallyArrived;
|
||||
bool? fullArrived;
|
||||
String? orderNumber;
|
||||
String? createdAt;
|
||||
String? updatedAt;
|
||||
int? v;
|
||||
String? id;
|
||||
String? arrivalDate;
|
||||
List<String>? images;
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final map = <String, dynamic>{};
|
||||
map['user_ucode'] = userUcode;
|
||||
map['phone_number'] = phoneNumber;
|
||||
map['gmail'] = gmail;
|
||||
map['quantity'] = quantity;
|
||||
map['nameUz'] = nameUz;
|
||||
map['nameRu'] = nameRu;
|
||||
map['nameZh'] = nameZh;
|
||||
map['weight'] = weight;
|
||||
map['m3'] = m3;
|
||||
map['average_weight_kg'] = averageWeightKg;
|
||||
map['wharehouseUz'] = wharehouseUz;
|
||||
map['wharehouseRu'] = wharehouseRu;
|
||||
map['wharehouseZh'] = wharehouseZh;
|
||||
map['delivery_price'] = deliveryPrice;
|
||||
map['shipment_id'] = shipmentId;
|
||||
map['lead_id'] = leadId;
|
||||
if (status != null) {
|
||||
map['status'] = status?.toJson();
|
||||
}
|
||||
map['partially_arrived'] = partiallyArrived;
|
||||
map['full_arrived'] = fullArrived;
|
||||
map['order_number'] = orderNumber;
|
||||
map['createdAt'] = createdAt;
|
||||
map['updatedAt'] = updatedAt;
|
||||
map['__v'] = v;
|
||||
map['id'] = id;
|
||||
map['arrival_date'] = arrivalDate;
|
||||
map['images'] = images;
|
||||
return map;
|
||||
}
|
||||
}
|
||||
|
||||
class Status {
|
||||
Status({this.code, this.translations});
|
||||
|
||||
Status.fromJson(dynamic json) {
|
||||
code = json['code'];
|
||||
translations =
|
||||
json['translations'] != null
|
||||
? Name.fromJson(json['translations'])
|
||||
: null;
|
||||
}
|
||||
|
||||
String? code;
|
||||
Name? translations;
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final map = <String, dynamic>{};
|
||||
map['code'] = code;
|
||||
if (translations != null) {
|
||||
map['translations'] = translations?.toJson();
|
||||
}
|
||||
return map;
|
||||
}
|
||||
}
|
||||
160
lib/features/home/data/models/orders_list_response.dart
Normal file
160
lib/features/home/data/models/orders_list_response.dart
Normal file
@@ -0,0 +1,160 @@
|
||||
import '../../../../core/models/name.dart';
|
||||
|
||||
class OrdersListResponse {
|
||||
OrdersListResponse({this.totalCount, this.data});
|
||||
|
||||
OrdersListResponse.fromJson(dynamic json) {
|
||||
totalCount = json['totalCount'];
|
||||
if (json['data'] != null) {
|
||||
data = [];
|
||||
json['data'].forEach((v) {
|
||||
data?.add(Data.fromJson(v));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
int? totalCount;
|
||||
List<Data>? data;
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final map = <String, dynamic>{};
|
||||
map['totalCount'] = totalCount;
|
||||
if (data != null) {
|
||||
map['data'] = data?.map((v) => v.toJson()).toList();
|
||||
}
|
||||
return map;
|
||||
}
|
||||
}
|
||||
|
||||
class Data {
|
||||
Data({
|
||||
this.id,
|
||||
this.userUcode,
|
||||
this.phoneNumber,
|
||||
this.gmail,
|
||||
this.quantity,
|
||||
this.nameUz,
|
||||
this.nameRu,
|
||||
this.nameZh,
|
||||
this.size,
|
||||
this.wharehouseUz,
|
||||
this.wharehouseRu,
|
||||
this.wharehouseZh,
|
||||
this.deliveryPrice,
|
||||
this.shipmentId,
|
||||
this.leadId,
|
||||
this.status,
|
||||
this.partiallyArrived,
|
||||
this.fullArrived,
|
||||
this.orderNumber,
|
||||
this.createdAt,
|
||||
this.updatedAt,
|
||||
this.v,
|
||||
this.arrivalDate,
|
||||
});
|
||||
|
||||
Data.fromJson(dynamic json) {
|
||||
userUcode = json['user_ucode'];
|
||||
phoneNumber = json['phone_number'];
|
||||
gmail = json['gmail'];
|
||||
quantity = json['quantity'];
|
||||
nameUz = json['nameUz'];
|
||||
nameRu = json['nameRu'];
|
||||
nameZh = json['nameZh'];
|
||||
size = json['size'];
|
||||
wharehouseUz = json['wharehouseUz'];
|
||||
wharehouseRu = json['wharehouseRu'];
|
||||
wharehouseZh = json['wharehouseZh'];
|
||||
deliveryPrice = json['delivery_price'];
|
||||
shipmentId = json['shipment_id'];
|
||||
leadId = json['lead_id'];
|
||||
status = json['status'] != null ? Status.fromJson(json['status']) : null;
|
||||
partiallyArrived = json['partially_arrived'];
|
||||
fullArrived = json['full_arrived'];
|
||||
orderNumber = json['order_number'];
|
||||
createdAt = json['createdAt'];
|
||||
updatedAt = json['updatedAt'];
|
||||
v = json['__v'];
|
||||
id = json['id'];
|
||||
arrivalDate = json['arrival_date'];
|
||||
}
|
||||
|
||||
String? userUcode;
|
||||
String? phoneNumber;
|
||||
String? gmail;
|
||||
int? quantity;
|
||||
String? nameUz;
|
||||
String? nameRu;
|
||||
String? nameZh;
|
||||
String? size;
|
||||
String? wharehouseUz;
|
||||
String? wharehouseRu;
|
||||
String? wharehouseZh;
|
||||
String? deliveryPrice;
|
||||
String? shipmentId;
|
||||
String? leadId;
|
||||
Status? status;
|
||||
bool? partiallyArrived;
|
||||
bool? fullArrived;
|
||||
String? orderNumber;
|
||||
String? createdAt;
|
||||
String? updatedAt;
|
||||
int? v;
|
||||
String? id;
|
||||
String? arrivalDate;
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final map = <String, dynamic>{};
|
||||
map['_id'] = id;
|
||||
map['user_ucode'] = userUcode;
|
||||
map['phone_number'] = phoneNumber;
|
||||
map['gmail'] = gmail;
|
||||
map['quantity'] = quantity;
|
||||
map['nameUz'] = nameUz;
|
||||
map['nameRu'] = nameRu;
|
||||
map['nameZh'] = nameZh;
|
||||
map['size'] = size;
|
||||
map['wharehouseUz'] = wharehouseUz;
|
||||
map['wharehouseRu'] = wharehouseRu;
|
||||
map['wharehouseZh'] = wharehouseZh;
|
||||
map['delivery_price'] = deliveryPrice;
|
||||
map['shipment_id'] = shipmentId;
|
||||
map['lead_id'] = leadId;
|
||||
if (status != null) {
|
||||
map['status'] = status?.toJson();
|
||||
}
|
||||
map['partially_arrived'] = partiallyArrived;
|
||||
map['full_arrived'] = fullArrived;
|
||||
map['order_number'] = orderNumber;
|
||||
map['createdAt'] = createdAt;
|
||||
map['updatedAt'] = updatedAt;
|
||||
map['__v'] = v;
|
||||
map['id'] = id;
|
||||
map['arrival_date'] = arrivalDate;
|
||||
return map;
|
||||
}
|
||||
}
|
||||
|
||||
class Status {
|
||||
Status({this.code, this.translations});
|
||||
|
||||
Status.fromJson(dynamic json) {
|
||||
code = json['code'];
|
||||
translations =
|
||||
json['translations'] != null
|
||||
? Name.fromJson(json['translations'])
|
||||
: null;
|
||||
}
|
||||
|
||||
String? code;
|
||||
Name? translations;
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final map = <String, dynamic>{};
|
||||
map['code'] = code;
|
||||
if (translations != null) {
|
||||
map['translations'] = translations?.toJson();
|
||||
}
|
||||
return map;
|
||||
}
|
||||
}
|
||||
16
lib/features/home/data/models/read_notification_request.dart
Normal file
16
lib/features/home/data/models/read_notification_request.dart
Normal file
@@ -0,0 +1,16 @@
|
||||
class ReadNotificationRequest {
|
||||
ReadNotificationRequest({
|
||||
this.notificationIds,});
|
||||
|
||||
ReadNotificationRequest.fromJson(dynamic json) {
|
||||
notificationIds = json['notification_ids'] != null ? json['notification_ids'].cast<String>() : [];
|
||||
}
|
||||
List<String>? notificationIds;
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final map = <String, dynamic>{};
|
||||
map['notification_ids'] = notificationIds;
|
||||
return map;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
class ReadNotificationResponse {
|
||||
ReadNotificationResponse({
|
||||
this.message,});
|
||||
|
||||
ReadNotificationResponse.fromJson(dynamic json) {
|
||||
message = json['message'];
|
||||
}
|
||||
String? message;
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final map = <String, dynamic>{};
|
||||
map['message'] = message;
|
||||
return map;
|
||||
}
|
||||
|
||||
}
|
||||
88
lib/features/home/data/repository/home_repository_impl.dart
Normal file
88
lib/features/home/data/repository/home_repository_impl.dart
Normal file
@@ -0,0 +1,88 @@
|
||||
import 'package:cargocalculaterapp/core/error/failure.dart';
|
||||
import 'package:cargocalculaterapp/features/home/data/models/banner_response.dart';
|
||||
import 'package:cargocalculaterapp/features/home/data/models/comment_request.dart';
|
||||
import 'package:cargocalculaterapp/features/home/data/models/comment_response.dart';
|
||||
import 'package:cargocalculaterapp/features/home/data/models/notification_response.dart';
|
||||
import 'package:cargocalculaterapp/features/home/data/models/order_single_response.dart';
|
||||
import 'package:cargocalculaterapp/features/home/data/models/orders_list_response.dart';
|
||||
import 'package:cargocalculaterapp/features/home/data/models/read_notification_request.dart';
|
||||
import 'package:cargocalculaterapp/features/home/data/models/read_notification_response.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import '../../domain/repository/home_repository.dart';
|
||||
import '../data_source/remote/home_remote_data_source.dart';
|
||||
|
||||
class HomeRepositoryImpl extends HomeRepository {
|
||||
final HomeRemoteDataSource remoteDataSource;
|
||||
|
||||
HomeRepositoryImpl(this.remoteDataSource);
|
||||
|
||||
@override
|
||||
Future<Either<Failure, OrdersListResponse>> ordersList(
|
||||
Map<String, dynamic> request,
|
||||
) async {
|
||||
try {
|
||||
final response = await remoteDataSource.ordersList(request);
|
||||
return Right(response);
|
||||
} catch (e) {
|
||||
return Left(ServerFailure(message: e.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Either<Failure, OrderSingleResponse>> orderSingle(
|
||||
String orderId,
|
||||
) async {
|
||||
try {
|
||||
final response = await remoteDataSource.orderSingle(orderId);
|
||||
return Right(response);
|
||||
} catch (e) {
|
||||
return Left(ServerFailure(message: e.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Either<Failure, CommentResponse>> comment(
|
||||
CommentRequest request,
|
||||
) async {
|
||||
try {
|
||||
final response = await remoteDataSource.comment(request);
|
||||
return Right(response);
|
||||
} catch (e) {
|
||||
return Left(ServerFailure(message: e.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Either<Failure, NotificationResponse>> notification(
|
||||
Map<String, dynamic> request,
|
||||
) async {
|
||||
try {
|
||||
final response = await remoteDataSource.notification(request);
|
||||
return Right(response);
|
||||
} catch (e) {
|
||||
return Left(ServerFailure(message: e.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Either<Failure, ReadNotificationResponse>> notificationRead(
|
||||
ReadNotificationRequest request,
|
||||
) async {
|
||||
try {
|
||||
final response = await remoteDataSource.notificationRead(request);
|
||||
return Right(response);
|
||||
} catch (e) {
|
||||
return Left(ServerFailure(message: e.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Either<Failure, List<BannerResponse>>> bannersGet() async {
|
||||
try {
|
||||
final response = await remoteDataSource.bannersResponse();
|
||||
return Right(response);
|
||||
} catch (e) {
|
||||
return Left(ServerFailure(message: e.toString()));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user