import 'package:fcs/domain/entities/discount.dart';
import 'package:fcs/domain/entities/payment_method.dart';
import 'package:fcs/domain/vo/message.dart';
import 'package:fcs/helpers/api_helper.dart';
import 'package:fcs/helpers/firebase_helper.dart';
import 'package:logging/logging.dart';

class CommonDataProvider {
  final log = Logger('CommonDataProvider');

  Future<void> createPaymentMethod(PaymentMethod paymentMethod) async {
    return await requestAPI("/payment_methods", "POST",
        payload: paymentMethod.toMap(), token: await getToken());
  }

  Future<void> updatePaymentMethod(PaymentMethod paymentMethod) async {
    return await requestAPI("/payment_methods", "PUT",
        payload: paymentMethod.toMap(), token: await getToken());
  }

  Future<void> deletePaymentMethod(String id) async {
    return await requestAPI("/payment_methods", "DELETE",
        payload: {"id": id}, token: await getToken());
  }

  Future<void> sendMessage(Message message) async {
    return await requestAPI("/messages", "POST",
        payload: message.toMap(), token: await getToken());
  }

  Future<void> seenMessage(String ownerID, bool seenByOwner) async {
    return await requestAPI("/messages/seen", "POST",
        payload: {"owner_id": ownerID, "seen_by_owner": seenByOwner},
        token: await getToken());
  }

  Future<void> createDiscount(Discount discount) async {
    return await requestAPI("/discounts", "POST",
        payload: discount.toMap(), token: await getToken());
  }

  Future<void> updateDiscount(Discount discount) async {
    return await requestAPI("/discounts", "PUT",
        payload: discount.toMap(), token: await getToken());
  }

  Future<void> deleteDiscount(String id) async {
    return await requestAPI("/discounts", "DELETE",
        payload: {"id": id}, token: await getToken());
  }
}
