import 'package:cheminova/models/oder_place_model.dart';

import '../utils/common_api_service.dart';
import '../utils/show_snackbar.dart';

class GetOrderPlacedServcie{
  Future<List<PlacedOrderModel>?> getPlacedOrder() async {
    try {
      String url;

        url = "/api/get-placed-order-pd?id=66cc7869f02b935094127a27";

      final response = await commonApiService<List<PlacedOrderModel>>(
        method: "GET",
        url: url,
        fromJson: (json) {
          if (json['plcaedOrders'] != null) {
            final List<PlacedOrderModel> products = (json['plcaedOrders'] as List)
                .map((productJson) => PlacedOrderModel.fromJson(productJson as Map<String, dynamic>))
                .toList();
            return products;
          } else {
            return [];
          }
        },
      );
      return response;
    } catch (e) {
      showSnackbar(e.toString());

      return null;
    }
  }
}

