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());
  }

  Future<void> ship(FcsShipment fcsShipment) async {
    return await requestAPI("/fcs_shipments/ship", "PUT",
        payload: fcsShipment.toMap(), token: await getToken());
  }

  Future<String> reportFcsShipment(FcsShipment fcsShipment) async {
    dynamic data = await requestAPI("/fcs_shipments/report", "POST",
        payload: fcsShipment.toMap(), token: await getToken());
    return data["url"];
  }
}
