feat(frontend): connect borrow flow to api
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
import "../models/emprunt_response.dart";
|
||||
import "api_client.dart";
|
||||
|
||||
/// Appels liés aux emprunts.
|
||||
class EmpruntService {
|
||||
EmpruntService._();
|
||||
|
||||
static const int posteEmpruntId = 1;
|
||||
|
||||
static Future<EmpruntResponse> creerEmprunt({
|
||||
required int materielId,
|
||||
required String commentaireDepart,
|
||||
required List<Map<String, dynamic>> elements,
|
||||
}) async {
|
||||
final reponse = await ApiClient.post("/emprunts", {
|
||||
"materielId": materielId,
|
||||
"posteEmpruntId": posteEmpruntId,
|
||||
"modeIdentification": "MAIL_ENSUP",
|
||||
if (commentaireDepart.trim().isNotEmpty) "commentaireDepart": commentaireDepart.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