import '../data/consts/payment_type.dart';
import '../sdk/gravity/gravity_helper.dart';
import '../utils/toast_util.dart';

class EventHandler {
  static const bool isShowToast = false;

  EventHandler._();

  static void report(String eventId, {Map<String, dynamic>? params}) {
    if (isShowToast) {
      if (params == null) {
        ToastUtil.show(eventId);
      } else {
        ToastUtil.show('$eventId ${params.toString()}');
      }
    }
    GravityHelper.report(eventId, params: params);
  }

  static void reportPay(
      int priceFen, String orderId, String itemName, int payWay) {
    if (isShowToast) {
      String? payWayStr;
      switch (payWay) {
        case PayMethod.alipay:
          payWayStr = '支付宝';
          break;
        case PayMethod.wechat:
          payWayStr = '微信';
          break;
      }
      ToastUtil.show(
          'PAY: 金额：$priceFen 订单号：$orderId 商品名：$itemName 支付方式：$payWayStr');
    }
    GravityHelper.reportPay(priceFen, orderId, itemName, payWay);
  }
}
