feat(frontend): connect return flow to api
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import "../models/emprunt_response.dart";
|
||||
import "../models/emprunt_item.dart";
|
||||
import "api_client.dart";
|
||||
|
||||
/// Appels liés aux emprunts.
|
||||
@@ -23,4 +24,25 @@ class EmpruntService {
|
||||
final data = (reponse as Map<String, dynamic>)["data"] as Map<String, dynamic>;
|
||||
return EmpruntResponse.fromJson(data);
|
||||
}
|
||||
|
||||
static Future<List<EmpruntItem>> getMesEmprunts() async {
|
||||
final reponse = await ApiClient.get("/mes-emprunts");
|
||||
final data = (reponse as Map<String, dynamic>)["data"] as List<dynamic>;
|
||||
return data.map((json) => EmpruntItem.fromJson(json as Map<String, dynamic>)).toList();
|
||||
}
|
||||
|
||||
static Future<EmpruntResponse> restituerEmprunt({
|
||||
required int empruntId,
|
||||
required String commentaireRetour,
|
||||
required List<Map<String, dynamic>> elements,
|
||||
}) async {
|
||||
final reponse = await ApiClient.post("/emprunts/$empruntId/restitution", {
|
||||
"modeIdentification": "MAIL_ENSUP",
|
||||
if (commentaireRetour.trim().isNotEmpty) "commentaireRetour": commentaireRetour.trim(),
|
||||
"elements": elements,
|
||||
});
|
||||
|
||||
final data = (reponse as Map<String, dynamic>)["data"] as Map<String, dynamic>;
|
||||
return EmpruntResponse.fromJson(data);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user