add paginator
This commit is contained in:
43
lib/data/provider/shipment_data_provider.dart
Normal file
43
lib/data/provider/shipment_data_provider.dart
Normal file
@@ -0,0 +1,43 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:fcs/domain/entities/shipment.dart';
|
||||
import 'package:fcs/helpers/api_helper.dart';
|
||||
import 'package:fcs/helpers/firebase_helper.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
|
||||
class ShipmentDataProvider {
|
||||
final log = Logger('ShipmentDataProvider');
|
||||
|
||||
static final ShipmentDataProvider instance = ShipmentDataProvider._();
|
||||
ShipmentDataProvider._();
|
||||
|
||||
Future<void> createShipment(Shipment shipment) async {
|
||||
return await requestAPI("/shipments", "POST",
|
||||
payload: shipment.toMap(), token: await getToken());
|
||||
}
|
||||
|
||||
Future<void> updateShipment(Shipment shipment) async {
|
||||
return await requestAPI("/shipments", "PUT",
|
||||
payload: shipment.toMap(), token: await getToken());
|
||||
}
|
||||
|
||||
Future<void> cancelShipment(Shipment shipment) async {
|
||||
return await requestAPI("/shipment_cancel", "PUT",
|
||||
payload: shipment.toMap(), token: await getToken());
|
||||
}
|
||||
|
||||
Future<void> confirmShipment(Shipment shipment) async {
|
||||
return await requestAPI("/shipment_confirm", "PUT",
|
||||
payload: shipment.toMap(), token: await getToken());
|
||||
}
|
||||
|
||||
Future<void> pickupShipment(Shipment shipment) async {
|
||||
return await requestAPI("/shipment_pickup", "PUT",
|
||||
payload: shipment.toMap(), token: await getToken());
|
||||
}
|
||||
|
||||
Future<void> receiveShipment(Shipment shipment) async {
|
||||
return await requestAPI("/shipment_receive", "PUT",
|
||||
payload: shipment.toMap(), token: await getToken());
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import 'package:fcs/data/provider/delivery_address_data_provider.dart';
|
||||
import 'package:fcs/data/provider/fcs_shipment_data_provider.dart';
|
||||
import 'package:fcs/data/provider/package_data_provider.dart';
|
||||
import 'package:fcs/data/provider/rate_data_provider.dart';
|
||||
import 'package:fcs/data/provider/shipment_data_provider.dart';
|
||||
import 'package:fcs/data/provider/user_data_provider.dart';
|
||||
import 'package:fcs/data/services/delivery_address_imp.dart';
|
||||
import 'package:fcs/data/services/delivery_address_service.dart';
|
||||
@@ -11,6 +12,8 @@ import 'package:fcs/data/services/fcs_shipment_imp.dart';
|
||||
import 'package:fcs/data/services/fcs_shipment_service.dart';
|
||||
import 'package:fcs/data/services/rate_imp.dart';
|
||||
import 'package:fcs/data/services/rate_service.dart';
|
||||
import 'package:fcs/data/services/shipment_imp.dart';
|
||||
import 'package:fcs/data/services/shipment_service.dart';
|
||||
|
||||
import 'auth_imp.dart';
|
||||
import 'auth_service.dart';
|
||||
@@ -34,6 +37,7 @@ class Services {
|
||||
FcsShipmentService _fcsShipmentService;
|
||||
DeliveryAddressService _deliveryAddressService;
|
||||
RateService _rateService;
|
||||
ShipmentService _shipmentService;
|
||||
Services._() {
|
||||
_authService = AuthServiceImp(
|
||||
authFb: AuthFb.instance,
|
||||
@@ -52,6 +56,9 @@ class Services {
|
||||
deliveryAddressDataProvider: DeliveryAddressDataProvider());
|
||||
_rateService = RateServiceImp(
|
||||
rateDataProvider: RateDataProvider.instance, connectivity: null);
|
||||
_shipmentService = ShipmentServiceImp(
|
||||
shipmentDataProvider: ShipmentDataProvider.instance,
|
||||
connectivity: null);
|
||||
}
|
||||
|
||||
AuthService get authService => _authService;
|
||||
@@ -62,4 +69,5 @@ class Services {
|
||||
FcsShipmentService get fcsShipmentService => _fcsShipmentService;
|
||||
DeliveryAddressService get deliveryAddressService => _deliveryAddressService;
|
||||
RateService get rateService => _rateService;
|
||||
ShipmentService get shipmentService => _shipmentService;
|
||||
}
|
||||
|
||||
52
lib/data/services/shipment_imp.dart
Normal file
52
lib/data/services/shipment_imp.dart
Normal file
@@ -0,0 +1,52 @@
|
||||
import 'package:fcs/data/provider/rate_data_provider.dart';
|
||||
import 'package:fcs/data/provider/shipment_data_provider.dart';
|
||||
import 'package:fcs/data/services/shipment_service.dart';
|
||||
import 'package:fcs/domain/entities/cargo_type.dart';
|
||||
import 'package:fcs/domain/entities/connectivity.dart';
|
||||
import 'package:fcs/domain/entities/discount_by_weight.dart';
|
||||
import 'package:fcs/domain/entities/custom_duty.dart';
|
||||
import 'package:fcs/domain/entities/rate.dart';
|
||||
import 'package:fcs/domain/entities/shipment.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'rate_service.dart';
|
||||
|
||||
class ShipmentServiceImp implements ShipmentService {
|
||||
ShipmentServiceImp({
|
||||
@required this.shipmentDataProvider,
|
||||
@required this.connectivity,
|
||||
});
|
||||
|
||||
final Connectivity connectivity;
|
||||
final ShipmentDataProvider shipmentDataProvider;
|
||||
|
||||
@override
|
||||
Future<void> cancelShipment(Shipment shipment) {
|
||||
return shipmentDataProvider.cancelShipment(shipment);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> confirmShipment(Shipment shipment) {
|
||||
return shipmentDataProvider.confirmShipment(shipment);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> createShipment(Shipment shipment) {
|
||||
return shipmentDataProvider.createShipment(shipment);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> pickupShipment(Shipment shipment) {
|
||||
return shipmentDataProvider.pickupShipment(shipment);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> receiveShipment(Shipment shipment) {
|
||||
return shipmentDataProvider.receiveShipment(shipment);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> updateShipment(Shipment shipment) {
|
||||
return shipmentDataProvider.updateShipment(shipment);
|
||||
}
|
||||
}
|
||||
@@ -1,23 +1,10 @@
|
||||
import 'package:fcs/domain/entities/cargo_type.dart';
|
||||
import 'package:fcs/domain/entities/custom_duty.dart';
|
||||
import 'package:fcs/domain/entities/discount_by_weight.dart';
|
||||
import 'package:fcs/domain/entities/shipment.dart';
|
||||
import 'package:fcs/domain/entities/rate.dart';
|
||||
|
||||
abstract class RateService {
|
||||
Stream<Rate> getRateStream();
|
||||
|
||||
abstract class ShipmentService {
|
||||
Future<void> createShipment(Shipment shipment);
|
||||
|
||||
Future<void> createCargoType(CargoType cargoType);
|
||||
Future<void> updateCargoType(CargoType cargoType);
|
||||
Future<void> deleteCargoType(String id);
|
||||
|
||||
Future<void> createCustomDuty(CustomDuty customDuty);
|
||||
Future<void> updateCustomDuty(CustomDuty customDuty);
|
||||
Future<void> deleteCustomDuty(String id);
|
||||
|
||||
Future<void> createDiscountByWeight(DiscountByWeight discountByWeight);
|
||||
Future<void> updateDiscountByWeight(DiscountByWeight discountByWeight);
|
||||
Future<void> deleteDiscountByWeight(String id);
|
||||
Future<void> updateShipment(Shipment shipment);
|
||||
Future<void> cancelShipment(Shipment shipment);
|
||||
Future<void> confirmShipment(Shipment shipment);
|
||||
Future<void> pickupShipment(Shipment shipment);
|
||||
Future<void> receiveShipment(Shipment shipment);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user