35 lines
990 B
Dart
35 lines
990 B
Dart
import 'package:dio/dio.dart';
|
|
|
|
class InvoiceService {
|
|
final Dio dio;
|
|
InvoiceService(this.dio);
|
|
|
|
Future<Map<String, dynamic>> getAllInvoices() async {
|
|
try {
|
|
final res = await dio.get("/user/invoices");
|
|
return Map<String, dynamic>.from(res.data);
|
|
} catch (e) {
|
|
return {"success": false, "message": e.toString()};
|
|
}
|
|
}
|
|
|
|
Future<Map<String, dynamic>> getInstallments(int invoiceId) async {
|
|
try {
|
|
final res = await dio.get("/user/invoice/$invoiceId/installments");
|
|
return Map<String, dynamic>.from(res.data);
|
|
} catch (e) {
|
|
return {"success": false, "message": e.toString()};
|
|
}
|
|
}
|
|
|
|
/// 🔵 NEW FUNCTION — Fetch Full Invoice Details
|
|
Future<Map<String, dynamic>> getInvoiceDetails(int invoiceId) async {
|
|
try {
|
|
final res = await dio.get("/user/invoice/$invoiceId/details");
|
|
return Map<String, dynamic>.from(res.data);
|
|
} catch (e) {
|
|
return {"success": false, "message": e.toString()};
|
|
}
|
|
}
|
|
}
|