fix: removed useless dependencies
This commit is contained in:
parent
981dce5bfe
commit
48bcf0b1f8
10 changed files with 5 additions and 37 deletions
|
|
@ -1,6 +1,5 @@
|
|||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
||||
import 'package:http/http.dart';
|
||||
import 'package:seshat/config/constants.dart';
|
||||
|
|
@ -50,17 +49,13 @@ class ApiClient {
|
|||
Uri.parse("https://$apiBasePath/book/ean/$ean"),
|
||||
headers: headers,
|
||||
);
|
||||
debugPrint("\n\n\n\nGOT : ${response.statusCode}\n\n\n\n");
|
||||
if (response.statusCode == 200) {
|
||||
debugPrint("\n\n\n\nWITH : ${response.body}\n\n\n\n");
|
||||
final json = jsonDecode(response.body);
|
||||
return Result.ok(Book.fromJSON(json));
|
||||
} else {
|
||||
debugPrintStack();
|
||||
return Result.error(Exception("The book was not found"));
|
||||
}
|
||||
} catch (e, stackTrace) {
|
||||
debugPrintStack(stackTrace: stackTrace);
|
||||
} catch (e) {
|
||||
return Result.error(Exception("API $e"));
|
||||
} finally {
|
||||
client.close();
|
||||
|
|
@ -88,7 +83,6 @@ class ApiClient {
|
|||
"owner_id": owner.id,
|
||||
"price": price,
|
||||
});
|
||||
debugPrint("\n\n\n\nSENDING : ${body}\n\n\n\n");
|
||||
final response = await client.post(
|
||||
Uri.parse("https://$apiBasePath/book_instance"),
|
||||
headers: headers,
|
||||
|
|
@ -96,15 +90,13 @@ class ApiClient {
|
|||
);
|
||||
if (response.statusCode == 201) {
|
||||
final json = jsonDecode(response.body);
|
||||
debugPrint("\n\n\n\nRECEIVED : ${json}\n\n\n\n");
|
||||
return Result.ok(BookInstance.fromJSON(json));
|
||||
} else if (response.statusCode == 403) {
|
||||
return Result.error(Exception("You don't own that book instance"));
|
||||
} else {
|
||||
return Result.error(Exception("Something wrong happened"));
|
||||
}
|
||||
} catch (e, stack) {
|
||||
debugPrintStack(stackTrace: stack);
|
||||
} catch (e) {
|
||||
return Result.error(Exception(e));
|
||||
} finally {
|
||||
client.close();
|
||||
|
|
|
|||
Reference in a new issue