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

  Future<void> deliver(Carton carton) async {
    return await requestAPI("/cartons/deliver", "PUT",
        payload: carton.toMap(), token: await getToken());
  }
}
