diff --git a/README.md b/README.md index a52938a..ffb0f14 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,9 @@ Workout Test and Diet 4 You Common Util Functions +### Version 1.0.26 + +- no more webapi + ### Version 1.0.25 - http get utf8 diff --git a/lib/service/api.dart b/lib/service/api.dart index a88a708..41b32cc 100644 --- a/lib/service/api.dart +++ b/lib/service/api.dart @@ -21,7 +21,7 @@ class APIClient with Common, Logging { } dynamic authenticateUser(String email, String password) async { - if ( kIsWeb ) { + if (kIsWeb) { APIWebClient webClient = APIWebClient(); return webClient.authenticateUser(email, password); } @@ -31,15 +31,12 @@ class APIClient with Common, Logging { try { var uri = Uri.parse(url); - HttpClient client = HttpClient(); + HttpClient client = HttpClient(); final HttpClientRequest request = await client.postUrl(uri); request.headers.contentType = ContentType('application', 'json', charset: 'utf-8'); request.headers.set('Authorization', '1'); - final body = jsonEncode({ - 'username': email, - 'password': password - }); + final body = jsonEncode({'username': email, 'password': password}); request.write(body); HttpClientResponse result = await request.close(); @@ -48,7 +45,7 @@ class APIClient with Common, Logging { log("authentication response: ${result.statusCode} with URL: $url"); throw Exception("Authentication error: ${result.statusCode}"); } - + String response = await result.transform(utf8.decoder).join(); log("Authentication status: ${result.statusCode}, response: $response"); final data = jsonDecode(response); @@ -66,10 +63,10 @@ class APIClient with Common, Logging { } Future post(String endPoint, String body) async { - if ( kIsWeb ) { + /*if ( kIsWeb ) { APIWebClient webClient = APIWebClient(); return webClient.post(endPoint, body); - } + }*/ final url = Cache().getBaseUrl() + endPoint; log(" ------------ http/post body $body - url: $url "); try { @@ -99,7 +96,7 @@ class APIClient with Common, Logging { } else { throw Exception("Network Error, please try again later"); } - } on NotFoundException catch(e) { + } on NotFoundException catch (e) { throw NotFoundException(message: "Not Found ${e.message}"); } on Exception catch (e) { log("Post Exception: $e"); @@ -109,10 +106,10 @@ class APIClient with Common, Logging { } Future get(String endPoint, String param) async { - if ( kIsWeb ) { + /*if ( kIsWeb ) { APIWebClient webClient = APIWebClient(); return webClient.get(endPoint, param); - } + }*/ final url = Cache().getBaseUrl() + endPoint + param; try { log("-------- API get $url"); @@ -140,7 +137,7 @@ class APIClient with Common, Logging { } else { throw Exception("Network Error, please try again later"); } - } on NotFoundException catch(e) { + } on NotFoundException catch (e) { throw NotFoundException(message: "Not Found ${e.message}"); } on Exception catch (e) { log("Post Exception: $e"); diff --git a/pubspec.yaml b/pubspec.yaml index 891cf34..e84f4d1 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: workouttest_util description: Workout Test app and web functions. -version: 1.0.25 +version: 1.0.26 environment: sdk: ">=2.18.6 <3.0.0"