Quellcode durchsuchen

調整DocAI API回傳值

姜青儀 vor 9 Monaten
Ursprung
Commit
6740e883bc
1 geänderte Dateien mit 9 neuen und 14 gelöschten Zeilen
  1. 9 14
      DocAI/DocAI.cs

+ 9 - 14
DocAI/DocAI.cs

@@ -53,23 +53,21 @@ namespace KdanCommon.DocAI
             _httpClient.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", accessToken);
         }
 
-        public async Task VerifyUser()
+        public async Task<VerifyUserResponse> VerifyUser()
         {
-            var content = new MultipartFormDataContent();
-            var result = await _httpClient.PostAsync(_verifyUserUri, content);
+            VerifyUserResponse response = null;
+            var result = await _httpClient.PostAsync(_verifyUserUri, new MultipartFormDataContent());
             if (result.StatusCode == System.Net.HttpStatusCode.OK)
             {
                 var jsonString = await result.Content.ReadAsStringAsync();
-                var response = JsonTool.DeserializeJSON<VerifyUserResponse>(jsonString);
-                if (response != null)
-                {
-
-                }
+                response = JsonTool.DeserializeJSON<VerifyUserResponse>(jsonString);
             }
+            return response;
         }
 
-        public async Task RedactInfoExtract(StorageFile file, string redactInfo, string docType, string pageRange = null, string redactCustomInfo = null)
+        public async Task<RedactInfoExtractResponse> RedactInfoExtract(StorageFile file, string redactInfo, string docType, string pageRange = null, string redactCustomInfo = null)
         {
+            RedactInfoExtractResponse response = null;
             using (var fileStream = await file.OpenStreamForReadAsync())
             {
                 var content = new MultipartFormDataContent();
@@ -91,13 +89,10 @@ namespace KdanCommon.DocAI
                 if (result.StatusCode == System.Net.HttpStatusCode.OK)
                 {
                     var jsonString = await result.Content.ReadAsStringAsync();
-                    var response = JsonTool.DeserializeJSON<RedactInfoExtractResponse>(jsonString);
-                    if (response != null)
-                    {
-                      
-                    }
+                    response = JsonTool.DeserializeJSON<RedactInfoExtractResponse>(jsonString);
                 }
             }
+            return response;
         }
 
         #endregion