feat: complete sell

This commit is contained in:
alzalia1 2025-08-15 14:48:27 +02:00
parent b4375fbaa2
commit bee5e05296
5 changed files with 144 additions and 38 deletions

View file

@ -310,6 +310,31 @@ class ApiClient {
}
}
Future<Result<void>> sellBooks(Map<String, double?> books) async {
final client = Client();
try {
final headers = await _getHeaders({"Content-Type": "application/json"});
debugPrint("\n\n\n\nMAP: $books\n\n\n\n");
final body = jsonEncode(books);
debugPrint("\n\n\n\nSENT: $body\n\n\n\n");
final response = await client.post(
Uri.parse("https://$apiBasePath/book_instance/sell/bulk"),
headers: headers,
body: body,
);
if (response.statusCode == 200) {
return Result.ok(response.statusCode);
} else {
throw "Unknown error";
}
} catch (e) {
debugPrint("\n\n\n\nERROR : ${e.toString()}\n\n\n\n");
return Result.error(Exception(e));
} finally {
client.close();
}
}
Future<Result<BookInstance>> sendBook(
Book book,
Owner owner,