2020-10-16 10:58:31 +06:30
|
|
|
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 {
|
2020-10-18 02:38:46 +06:30
|
|
|
return await requestAPI("/shipments/cancel", "PUT",
|
2020-10-16 10:58:31 +06:30
|
|
|
payload: shipment.toMap(), token: await getToken());
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-19 05:13:49 +06:30
|
|
|
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());
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-16 10:58:31 +06:30
|
|
|
Future<void> confirmShipment(Shipment shipment) async {
|
2020-10-19 05:13:49 +06:30
|
|
|
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",
|
2020-10-16 10:58:31 +06:30
|
|
|
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());
|
|
|
|
|
}
|
|
|
|
|
}
|