瀏覽代碼

調整DocAI API回傳值

姜青儀 8 月之前
父節點
當前提交
6740e883bc
共有 1 個文件被更改,包括 9 次插入14 次删除
  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