Files
kent_logistics_app/lib/services/invoice_service.dart
divya abdar 9faf983b95 Your changes
2025-12-11 18:36:11 +05:30

60 lines
1.8 KiB
Dart

import 'package:dio/dio.dart';
class InvoiceService {
final Dio dio;
InvoiceService(this.dio);
// -------------------------------------------------------
// ⭐ GET ALL INVOICES
// -------------------------------------------------------
Future<Map<String, dynamic>> getAllInvoices() async {
try {
final res = await dio.get("/user/invoices");
print("🔵 ALL INVOICES RESPONSE:");
print(res.data);
return Map<String, dynamic>.from(res.data);
} catch (e) {
print("❌ ERROR (All Invoices): $e");
return {"success": false, "message": e.toString()};
}
}
// -------------------------------------------------------
// ⭐ GET INSTALLMENTS
// -------------------------------------------------------
Future<Map<String, dynamic>> getInstallments(int invoiceId) async {
try {
final res =
await dio.get("/user/invoice/$invoiceId/installments");
print("🔵 INSTALLMENTS RESPONSE:");
print(res.data);
return Map<String, dynamic>.from(res.data);
} catch (e) {
print("❌ ERROR (Installments): $e");
return {"success": false, "message": e.toString()};
}
}
// -------------------------------------------------------
// ⭐ GET FULL INVOICE DETAILS (PRINT JSON HERE)
// -------------------------------------------------------
Future<Map<String, dynamic>> getInvoiceDetails(int invoiceId) async {
try {
final res = await dio.get("/user/invoice/$invoiceId/details");
print("👇👇👇 INVOICE API RESPONSE START 👇👇👇");
print(res.data); // <-- THIS IS WHAT YOU NEED
print("👆👆👆 INVOICE API RESPONSE END 👆👆👆");
return Map<String, dynamic>.from(res.data);
} catch (e) {
print("❌ ERROR (Invoice Details): $e");
return {"success": false, "message": e.toString()};
}
}
}