add fcs shipment service
This commit is contained in:
23
lib/data/provider/fcs_shipment_data_provider.dart
Normal file
23
lib/data/provider/fcs_shipment_data_provider.dart
Normal file
@@ -0,0 +1,23 @@
|
||||
import 'package:fcs/domain/entities/fcs_shipment.dart';
|
||||
import 'package:fcs/helpers/api_helper.dart';
|
||||
import 'package:fcs/helpers/firebase_helper.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
|
||||
class FcsShipmentDataProvider {
|
||||
final log = Logger('FcsShipmentDataProvider');
|
||||
|
||||
Future<void> createFcsShipment(FcsShipment fcsShipment) async {
|
||||
return await requestAPI("/fcs_shipments", "POST",
|
||||
payload: fcsShipment.toMap(), token: await getToken());
|
||||
}
|
||||
|
||||
Future<void> updateFcsShipment(FcsShipment fcsShipment) async {
|
||||
return await requestAPI("/fcs_shipments", "PUT",
|
||||
payload: fcsShipment.toMap(), token: await getToken());
|
||||
}
|
||||
|
||||
Future<void> deleteFcsShipment(FcsShipment fcsShipment) async {
|
||||
return await requestAPI("/fcs_shipments", "DELETE",
|
||||
payload: fcsShipment.toMap(), token: await getToken());
|
||||
}
|
||||
}
|
||||
31
lib/data/services/fcs_shipment_imp.dart
Normal file
31
lib/data/services/fcs_shipment_imp.dart
Normal file
@@ -0,0 +1,31 @@
|
||||
import 'package:fcs/data/provider/fcs_shipment_data_provider.dart';
|
||||
import 'package:fcs/domain/entities/connectivity.dart';
|
||||
import 'package:fcs/domain/entities/fcs_shipment.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'fcs_shipment_service.dart';
|
||||
|
||||
class FcsShipmentServiceImp implements FcsShipmentService {
|
||||
FcsShipmentServiceImp({
|
||||
@required this.connectivity,
|
||||
@required this.shipmentDataProvider,
|
||||
});
|
||||
|
||||
final Connectivity connectivity;
|
||||
final FcsShipmentDataProvider shipmentDataProvider;
|
||||
|
||||
@override
|
||||
Future<void> createFcsShipment(FcsShipment fcsShipment) {
|
||||
return shipmentDataProvider.createFcsShipment(fcsShipment);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> updateFcsShipment(FcsShipment fcsShipment) {
|
||||
return shipmentDataProvider.updateFcsShipment(fcsShipment);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> deleteFcsShipment(FcsShipment fcsShipment) {
|
||||
return shipmentDataProvider.deleteFcsShipment(fcsShipment);
|
||||
}
|
||||
}
|
||||
7
lib/data/services/fcs_shipment_service.dart
Normal file
7
lib/data/services/fcs_shipment_service.dart
Normal file
@@ -0,0 +1,7 @@
|
||||
import 'package:fcs/domain/entities/fcs_shipment.dart';
|
||||
|
||||
abstract class FcsShipmentService {
|
||||
Future<void> createFcsShipment(FcsShipment fcsShipment);
|
||||
Future<void> updateFcsShipment(FcsShipment fcsShipment);
|
||||
Future<void> deleteFcsShipment(FcsShipment fcsShipment);
|
||||
}
|
||||
@@ -1,7 +1,10 @@
|
||||
import 'package:fcs/data/provider/auth_fb.dart';
|
||||
import 'package:fcs/data/provider/common_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/user_data_provider.dart';
|
||||
import 'package:fcs/data/services/fcs_shipment_imp.dart';
|
||||
import 'package:fcs/data/services/fcs_shipment_service.dart';
|
||||
|
||||
import 'auth_imp.dart';
|
||||
import 'auth_service.dart';
|
||||
@@ -22,6 +25,7 @@ class Services {
|
||||
PackageService _packageService;
|
||||
MessagingService _messagingService;
|
||||
CommonService _commonService;
|
||||
FcsShipmentService _fcsShipmentService;
|
||||
Services._() {
|
||||
_authService = AuthServiceImp(
|
||||
authFb: AuthFb.instance,
|
||||
@@ -33,6 +37,8 @@ class Services {
|
||||
_packageService = PackageServiceImp(
|
||||
connectivity: null, packageDataProvider: PackageDataProvider());
|
||||
_commonService = CommonServiceImp(commonDataProvider: CommonDataProvider());
|
||||
_fcsShipmentService = FcsShipmentServiceImp(
|
||||
connectivity: null, shipmentDataProvider: FcsShipmentDataProvider());
|
||||
}
|
||||
|
||||
AuthService get authService => _authService;
|
||||
@@ -40,4 +46,5 @@ class Services {
|
||||
MessagingService get messagingService => _messagingService;
|
||||
PackageService get packageService => _packageService;
|
||||
CommonService get commonService => _commonService;
|
||||
FcsShipmentService get fcsShipmentService => _fcsShipmentService;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
class FcsShipment {
|
||||
String id;
|
||||
DateTime shipDate;
|
||||
String shipmentNumber;
|
||||
DateTime cutoffDate;
|
||||
@@ -11,7 +12,8 @@ class FcsShipment {
|
||||
String status;
|
||||
String remark;
|
||||
FcsShipment(
|
||||
{this.shipDate,
|
||||
{this.id,
|
||||
this.shipDate,
|
||||
this.shipmentNumber,
|
||||
this.cutoffDate,
|
||||
this.shipType,
|
||||
@@ -22,4 +24,21 @@ class FcsShipment {
|
||||
this.port,
|
||||
this.destination,
|
||||
this.remark});
|
||||
|
||||
Map<String, dynamic> toMap() {
|
||||
return {
|
||||
"id": id,
|
||||
'shipment_date': shipDate?.toUtc()?.toIso8601String(),
|
||||
'shipment_number': shipmentNumber,
|
||||
'cutoff_date': cutoffDate?.toUtc()?.toIso8601String(),
|
||||
'shipment_type': shipType,
|
||||
'arrival_date': arrivalDate?.toUtc()?.toIso8601String(),
|
||||
'departure_date': departureDate?.toUtc()?.toIso8601String(),
|
||||
'consignee': consignee,
|
||||
'port': port,
|
||||
'destination': destination,
|
||||
'status': status,
|
||||
'remark': remark,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user