xf 1 year ago
parent
commit
b198419c5a

+ 3 - 1
src/Hotline.Api.Sdk/HotlineAuthenticator.cs

@@ -7,7 +7,7 @@ namespace Hotline.Api.Sdk;
 
 
 public class HotlineAuthenticator : AuthenticatorBase
 public class HotlineAuthenticator : AuthenticatorBase
 {
 {
-    private readonly string _tokenKey = "Bearer";
+    private readonly string _tokenKey = "Authorization";
     private readonly string _baseUrl;
     private readonly string _baseUrl;
     private readonly string _apiKey;
     private readonly string _apiKey;
     private readonly string _apiSecret;
     private readonly string _apiSecret;
@@ -44,6 +44,8 @@ public class HotlineAuthenticator : AuthenticatorBase
             if (string.IsNullOrEmpty(token))
             if (string.IsNullOrEmpty(token))
                 throw new HttpRequestException("热线服务授权失败");
                 throw new HttpRequestException("热线服务授权失败");
 
 
+            if (!token.StartsWith("Bearer"))
+                token = "Bearer " + token;
             return token;
             return token;
             //var response = await client.GetAsync(request, cancellationToken);
             //var response = await client.GetAsync(request, cancellationToken);
             //if (!response.IsSuccessful)
             //if (!response.IsSuccessful)

+ 19 - 5
src/Hotline.Api.Sdk/HotlineClient.cs

@@ -20,8 +20,15 @@ public class HotlineClient : IHotlineClient, IDisposable
         TRequest request, CancellationToken cancellationToken)
         TRequest request, CancellationToken cancellationToken)
         where TRequest : class
         where TRequest : class
     {
     {
-        var req = new RestRequest(path, httpMethod)
-            .AddJsonBody(request);
+        var req = new RestRequest(path, httpMethod);
+        if (httpMethod is Method.Get)
+        {
+            req.AddObject(request);
+        }
+        else
+        {
+            req.AddJsonBody(request);
+        }
 
 
         try
         try
         {
         {
@@ -39,11 +46,18 @@ public class HotlineClient : IHotlineClient, IDisposable
     }
     }
 
 
     public async Task<ApiResponse> ExecuteAsync<TRequest>(string path, Method httpMethod, TRequest request,
     public async Task<ApiResponse> ExecuteAsync<TRequest>(string path, Method httpMethod, TRequest request,
-        CancellationToken cancellationToken) 
+        CancellationToken cancellationToken)
         where TRequest : class
         where TRequest : class
     {
     {
-        var req = new RestRequest(path, httpMethod)
-            .AddJsonBody(request);
+        var req = new RestRequest(path, httpMethod);
+        if (httpMethod is Method.Get)
+        {
+            req.AddObject(request);
+        }
+        else
+        {
+            req.AddJsonBody(request);
+        }
 
 
         try
         try
         {
         {

+ 12 - 1
src/Hotline.Api.Sdk/Order/IHotlineClient.Order.cs

@@ -11,7 +11,18 @@ namespace Hotline.Api.Sdk
 {
 {
     public partial interface IHotlineClient
     public partial interface IHotlineClient
     {
     {
+        /// <summary>
+        /// 省延期结果
+        /// </summary>
         public Task<ApiResponse> DelayProvinceResultAsync(DelayProvinceResultDto request, CancellationToken cancellationToken) =>
         public Task<ApiResponse> DelayProvinceResultAsync(DelayProvinceResultDto request, CancellationToken cancellationToken) =>
-            ExecuteAsync<DelayProvinceResultDto>("api/v1/Order/delay/province/result", Method.Post, request, cancellationToken);
+            ExecuteAsync("api/v1/Order/delay/province/result", Method.Post, request, cancellationToken);
+
+        /// <summary>
+        /// 新增工单
+        /// </summary>
+        public Task<ApiResponse<string>> AddOrderAsync(AddOrderDto request, CancellationToken cancellationToken) =>
+            ExecuteAsync<AddOrderDto, string>("api/v1/Order", Method.Post, request, cancellationToken);
+
+
     }
     }
 }
 }