diff --git a/loc_chain_app/lib/util/requests.dart b/loc_chain_app/lib/util/requests.dart new file mode 100644 index 0000000..96f329b --- /dev/null +++ b/loc_chain_app/lib/util/requests.dart @@ -0,0 +1,32 @@ +import 'dart:convert'; +import 'dart:html'; +import 'dart:io'; +import 'package:http/http.dart' as http; + +import 'package:loc_chain_app/util/transaction_manager.dart'; + +String baseUrl = 'http://loc.glmdev.tech:8000/'; + +Future postEncounter(EncounterTransaction encounter) async { + var payload = jsonEncode(encounter); + var url = Uri.parse('http://loc.glmdev.tech:8000/api/v1/encounter'); + return await http.post( + url, + headers: { + 'Content-Type': 'application/json', + }, + body: payload, + ); +} + +Future postExposure(ExposureTransaction exposure) async { + var payload = jsonEncode(exposure); + var url = Uri.parse('http://loc.glmdev.tech:8000/api/v1/exposure'); + return await http.post( + url, + headers: { + 'Content-Type': 'application/json', + }, + body: payload, + ); +} diff --git a/loc_chain_app/pubspec.lock b/loc_chain_app/pubspec.lock index 8c6eb02..86671eb 100644 --- a/loc_chain_app/pubspec.lock +++ b/loc_chain_app/pubspec.lock @@ -121,6 +121,20 @@ packages: description: flutter source: sdk version: "0.0.0" + http: + dependency: "direct main" + description: + name: http + url: "https://pub.dartlang.org" + source: hosted + version: "0.13.1" + http_parser: + dependency: transitive + description: + name: http_parser + url: "https://pub.dartlang.org" + source: hosted + version: "4.0.0" js: dependency: transitive description: @@ -205,6 +219,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.0.0" + pedantic: + dependency: transitive + description: + name: pedantic + url: "https://pub.dartlang.org" + source: hosted + version: "1.11.0" platform: dependency: transitive description: diff --git a/loc_chain_app/pubspec.yaml b/loc_chain_app/pubspec.yaml index 4397387..92bb535 100644 --- a/loc_chain_app/pubspec.yaml +++ b/loc_chain_app/pubspec.yaml @@ -36,6 +36,7 @@ dependencies: flutter_udid: ^2.0.0 loading_animations: ^2.2.0 openpgp: ^2.0.0-nullsafety.0 + http: ^0.13.1 dev_dependencies: flutter_test: