v1.0.4 webapi fixes

This commit is contained in:
Tibor Bossanyi
2023-02-13 19:56:15 +01:00
parent 65e9daa273
commit 0f58f893e6
20 changed files with 199 additions and 14 deletions
+4 -4
View File
@@ -71,7 +71,7 @@ class APIClient with Common, Logging {
return webClient.post(endPoint, body);
}
final url = Cache().getBaseUrl() + endPoint;
trace(" ------------ http/post body $body - url: $url ");
log(" ------------ http/post body $body - url: $url ");
try {
String authToken = Cache().getAuthToken();
if (authToken.isEmpty) {
@@ -91,7 +91,7 @@ class APIClient with Common, Logging {
request.write(body);
HttpClientResponse result = await request.close();
client.close();
trace(" ------------post response code: ${result.statusCode}");
log(" ------------post response code: ${result.statusCode}");
if (result.statusCode == 200) {
return await result.transform(utf8.decoder).join();
} else if (result.statusCode == 404) {
@@ -115,7 +115,7 @@ class APIClient with Common, Logging {
}
final url = Cache().getBaseUrl() + endPoint + param;
try {
trace("-------- API get $url");
log("-------- API get $url");
String authToken = Cache().getAuthToken();
if (authToken.isEmpty) {
var responseJson = await authenticateUser(Cache.username, Cache.password);
@@ -132,7 +132,7 @@ class APIClient with Common, Logging {
request.write("");
HttpClientResponse result = await request.close();
client.close();
trace(" ------------get response code: ${result.statusCode}");
log(" ------------get response code: ${result.statusCode}");
if (result.statusCode == 200) {
return await result.transform(utf8.decoder).join();
} else if (result.statusCode == 404) {
+5 -5
View File
@@ -43,7 +43,7 @@ class APIWebClient with Common, Logging {
log("Authentication status: ${result.statusCode}, response: $response");
final data = jsonDecode(response);
return data;
} catch (exception) {
} on Exception catch (exception) {
log(exception.toString());
try {
await Sentry.captureException(exception);
@@ -57,7 +57,7 @@ class APIWebClient with Common, Logging {
Future<String> post(String endPoint, String body) async {
final url = Cache().getBaseUrl() + endPoint;
trace(" ------------ http/post body $body - url: $url ");
log(" ------------ http/post body $body - url: $url ");
try {
String authToken = Cache().getAuthToken();
if (authToken.isEmpty) {
@@ -70,7 +70,7 @@ class APIWebClient with Common, Logging {
"Content-Type": "application/json",
"Authorization": 'Bearer $authToken',
});
trace(" ------------post response code: ${result.statusCode}");
log(" ------------post response code: ${result.statusCode}");
if (result.statusCode == 200) {
return result.body;
} else if (result.statusCode == 404) {
@@ -90,7 +90,7 @@ class APIWebClient with Common, Logging {
Future<String> get(String endPoint, String param) async {
final url = Cache().getBaseUrl() + endPoint + param;
try {
trace("-------- API get $url");
log("-------- API get $url");
String authToken = Cache().getAuthToken();
if (authToken.isEmpty) {
var responseJson = await authenticateUser(Cache.username, Cache.password);
@@ -103,7 +103,7 @@ class APIWebClient with Common, Logging {
"Authorization": 'Bearer $authToken',
});
trace(" ------------get response code: ${result.statusCode}");
log(" ------------get response code: ${result.statusCode}");
if (result.statusCode == 200) {
return result.body;
} else if (result.statusCode == 404) {