浏览代码

Integrate API to fetch public key of a user

Vishnu Mohandas 4 年之前
父节点
当前提交
00d9a8d201
共有 1 个文件被更改,包括 24 次插入0 次删除
  1. 24 0
      lib/services/user_service.dart

+ 24 - 0
lib/services/user_service.dart

@@ -47,6 +47,30 @@ class UserService {
     });
   }
 
+  Future<String> getPublicKey(BuildContext context, String email) async {
+    final dialog = createProgressDialog(context, "Searching for user...");
+    await dialog.show();
+    try {
+      final response = await _dio.get(
+        Configuration.instance.getHttpEndpoint() + "/users/public-key",
+        queryParameters: {
+          "email": email,
+        },
+        options: Options(
+          headers: {
+            "X-Auth-Token": Configuration.instance.getToken(),
+          },
+        ),
+      );
+      return response.data["publicKey"];
+    } on DioError catch (e) {
+      _logger.info(e);
+      return null;
+    } finally {
+      await dialog.hide();
+    }
+  }
+
   Future<void> getCredentials(BuildContext context, String ott) async {
     final dialog = createProgressDialog(context, "Please wait...");
     await dialog.show();