add shipments
This commit is contained in:
28
lib/data/provider/carton_data_provider.dart
Normal file
28
lib/data/provider/carton_data_provider.dart
Normal file
@@ -0,0 +1,28 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:fcs/domain/entities/carton.dart';
|
||||
import 'package:fcs/helpers/api_helper.dart';
|
||||
import 'package:fcs/helpers/firebase_helper.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
|
||||
class CartonDataProvider {
|
||||
final log = Logger('CartonDataProvider');
|
||||
|
||||
static final CartonDataProvider instance = CartonDataProvider._();
|
||||
CartonDataProvider._();
|
||||
|
||||
Future<void> createCarton(Carton carton) async {
|
||||
return await requestAPI("/cartons", "POST",
|
||||
payload: carton.toMap(), token: await getToken());
|
||||
}
|
||||
|
||||
Future<void> updateCarton(Carton carton) async {
|
||||
return await requestAPI("/cartons", "PUT",
|
||||
payload: carton.toMap(), token: await getToken());
|
||||
}
|
||||
|
||||
Future<void> deleteCarton(Carton carton) async {
|
||||
return await requestAPI("/cartons", "DELETE",
|
||||
payload: carton.toMap(), token: await getToken());
|
||||
}
|
||||
}
|
||||
@@ -20,4 +20,9 @@ class FcsShipmentDataProvider {
|
||||
return await requestAPI("/fcs_shipments", "DELETE",
|
||||
payload: fcsShipment.toMap(), token: await getToken());
|
||||
}
|
||||
|
||||
Future<void> ship(FcsShipment fcsShipment) async {
|
||||
return await requestAPI("/fcs_shipments/ship", "PUT",
|
||||
payload: fcsShipment.toMap(), token: await getToken());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,8 +26,43 @@ class ShipmentDataProvider {
|
||||
payload: shipment.toMap(), token: await getToken());
|
||||
}
|
||||
|
||||
Future<void> assignShipment(Shipment shipment) async {
|
||||
return await requestAPI("/shipments/assign", "PUT",
|
||||
payload: shipment.toMap(), token: await getToken());
|
||||
}
|
||||
|
||||
Future<void> completeAssignShipment(Shipment shipment) async {
|
||||
return await requestAPI("/shipments/assign/complete", "PUT",
|
||||
payload: shipment.toMap(), token: await getToken());
|
||||
}
|
||||
|
||||
Future<void> completePickupShipment(Shipment shipment) async {
|
||||
return await requestAPI("/shipments/pickup/complete", "PUT",
|
||||
payload: shipment.toMap(), token: await getToken());
|
||||
}
|
||||
|
||||
Future<void> packShipment(Shipment shipment) async {
|
||||
return await requestAPI("/shipments/pack", "PUT",
|
||||
payload: shipment.toMap(), token: await getToken());
|
||||
}
|
||||
|
||||
Future<void> completePackShipment(Shipment shipment) async {
|
||||
return await requestAPI("/shipments/pack/complete", "PUT",
|
||||
payload: shipment.toMap(), token: await getToken());
|
||||
}
|
||||
|
||||
Future<void> confirmShipment(Shipment shipment) async {
|
||||
return await requestAPI("/shipment_confirm", "PUT",
|
||||
return await requestAPI("/shipments/confirm", "PUT",
|
||||
payload: shipment.toMap(), token: await getToken());
|
||||
}
|
||||
|
||||
Future<void> completeConfirmShipment(Shipment shipment) async {
|
||||
return await requestAPI("/shipments/confirm/complete", "PUT",
|
||||
payload: shipment.toMap(), token: await getToken());
|
||||
}
|
||||
|
||||
Future<void> completeReceiveShipment(Shipment shipment) async {
|
||||
return await requestAPI("/shipments/receive/complete", "PUT",
|
||||
payload: shipment.toMap(), token: await getToken());
|
||||
}
|
||||
|
||||
|
||||
31
lib/data/services/carton_imp.dart
Normal file
31
lib/data/services/carton_imp.dart
Normal file
@@ -0,0 +1,31 @@
|
||||
import 'package:fcs/data/provider/carton_data_provider.dart';
|
||||
import 'package:fcs/domain/entities/carton.dart';
|
||||
import 'package:fcs/domain/entities/connectivity.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'carton_service.dart';
|
||||
|
||||
class CartonServiceImp implements CartonService {
|
||||
CartonServiceImp({
|
||||
@required this.cartonDataProvider,
|
||||
@required this.connectivity,
|
||||
});
|
||||
|
||||
final Connectivity connectivity;
|
||||
final CartonDataProvider cartonDataProvider;
|
||||
|
||||
@override
|
||||
Future<void> createCarton(Carton carton) {
|
||||
return cartonDataProvider.createCarton(carton);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> deleteCarton(Carton carton) {
|
||||
return cartonDataProvider.deleteCarton(carton);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> updateCarton(Carton carton) {
|
||||
return cartonDataProvider.updateCarton(carton);
|
||||
}
|
||||
}
|
||||
7
lib/data/services/carton_service.dart
Normal file
7
lib/data/services/carton_service.dart
Normal file
@@ -0,0 +1,7 @@
|
||||
import 'package:fcs/domain/entities/carton.dart';
|
||||
|
||||
abstract class CartonService {
|
||||
Future<void> createCarton(Carton carton);
|
||||
Future<void> updateCarton(Carton carton);
|
||||
Future<void> deleteCarton(Carton carton);
|
||||
}
|
||||
@@ -28,4 +28,9 @@ class FcsShipmentServiceImp implements FcsShipmentService {
|
||||
Future<void> deleteFcsShipment(FcsShipment fcsShipment) {
|
||||
return shipmentDataProvider.deleteFcsShipment(fcsShipment);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> ship(FcsShipment fcsShipment) {
|
||||
return shipmentDataProvider.ship(fcsShipment);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,4 +4,5 @@ abstract class FcsShipmentService {
|
||||
Future<void> createFcsShipment(FcsShipment fcsShipment);
|
||||
Future<void> updateFcsShipment(FcsShipment fcsShipment);
|
||||
Future<void> deleteFcsShipment(FcsShipment fcsShipment);
|
||||
Future<void> ship(FcsShipment fcsShipment);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'package:fcs/data/provider/auth_fb.dart';
|
||||
import 'package:fcs/data/provider/carton_data_provider.dart';
|
||||
import 'package:fcs/data/provider/common_data_provider.dart';
|
||||
import 'package:fcs/data/provider/delivery_address_data_provider.dart';
|
||||
import 'package:fcs/data/provider/fcs_shipment_data_provider.dart';
|
||||
@@ -6,6 +7,8 @@ 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/carton_imp.dart';
|
||||
import 'package:fcs/data/services/carton_service.dart';
|
||||
import 'package:fcs/data/services/delivery_address_imp.dart';
|
||||
import 'package:fcs/data/services/delivery_address_service.dart';
|
||||
import 'package:fcs/data/services/fcs_shipment_imp.dart';
|
||||
@@ -38,6 +41,7 @@ class Services {
|
||||
DeliveryAddressService _deliveryAddressService;
|
||||
RateService _rateService;
|
||||
ShipmentService _shipmentService;
|
||||
CartonService _cartonService;
|
||||
Services._() {
|
||||
_authService = AuthServiceImp(
|
||||
authFb: AuthFb.instance,
|
||||
@@ -59,6 +63,8 @@ class Services {
|
||||
_shipmentService = ShipmentServiceImp(
|
||||
shipmentDataProvider: ShipmentDataProvider.instance,
|
||||
connectivity: null);
|
||||
_cartonService = CartonServiceImp(
|
||||
cartonDataProvider: CartonDataProvider.instance, connectivity: null);
|
||||
}
|
||||
|
||||
AuthService get authService => _authService;
|
||||
@@ -70,4 +76,5 @@ class Services {
|
||||
DeliveryAddressService get deliveryAddressService => _deliveryAddressService;
|
||||
RateService get rateService => _rateService;
|
||||
ShipmentService get shipmentService => _shipmentService;
|
||||
CartonService get cartonService => _cartonService;
|
||||
}
|
||||
|
||||
@@ -1,16 +1,9 @@
|
||||
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,
|
||||
@@ -49,4 +42,39 @@ class ShipmentServiceImp implements ShipmentService {
|
||||
Future<void> updateShipment(Shipment shipment) {
|
||||
return shipmentDataProvider.updateShipment(shipment);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> assignShipment(Shipment shipment) {
|
||||
return shipmentDataProvider.assignShipment(shipment);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> completeAssignShipment(Shipment shipment) {
|
||||
return shipmentDataProvider.completeAssignShipment(shipment);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> completePickupShipment(Shipment shipment) {
|
||||
return shipmentDataProvider.completePickupShipment(shipment);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> completePackShipment(Shipment shipment) {
|
||||
return shipmentDataProvider.completePackShipment(shipment);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> packShipment(Shipment shipment) {
|
||||
return shipmentDataProvider.packShipment(shipment);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> completeConfirmShipment(Shipment shipment) {
|
||||
return shipmentDataProvider.completeConfirmShipment(shipment);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> completeReceiveShipment(Shipment shipment) {
|
||||
return shipmentDataProvider.completeReceiveShipment(shipment);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,13 @@ abstract class ShipmentService {
|
||||
Future<void> updateShipment(Shipment shipment);
|
||||
Future<void> cancelShipment(Shipment shipment);
|
||||
Future<void> confirmShipment(Shipment shipment);
|
||||
Future<void> completeConfirmShipment(Shipment shipment);
|
||||
Future<void> completeReceiveShipment(Shipment shipment);
|
||||
Future<void> pickupShipment(Shipment shipment);
|
||||
Future<void> receiveShipment(Shipment shipment);
|
||||
Future<void> assignShipment(Shipment shipment);
|
||||
Future<void> completeAssignShipment(Shipment shipment);
|
||||
Future<void> completePickupShipment(Shipment shipment);
|
||||
Future<void> packShipment(Shipment shipment);
|
||||
Future<void> completePackShipment(Shipment shipment);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user