diff --git a/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientEventExtensions.cs b/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientEventExtensions.cs index d0016662..f18f8be5 100644 --- a/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientEventExtensions.cs +++ b/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientEventExtensions.cs @@ -21,7 +21,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Api if (client == null) throw new ArgumentNullException(nameof(client)); if (string.IsNullOrEmpty(callbackJson)) throw new ArgumentNullException(callbackJson); - return client.JsonSerializer.Deserialize(callbackJson); + return client.FlurlJsonSerializer.Deserialize(callbackJson); } /// diff --git a/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteCardInvoiceExtensions.cs b/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteCardInvoiceExtensions.cs index 11026ee9..62484578 100644 --- a/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteCardInvoiceExtensions.cs +++ b/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteCardInvoiceExtensions.cs @@ -180,7 +180,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Api if (request is null) throw new ArgumentNullException(nameof(request)); if (string.IsNullOrEmpty(request.AppId)) - request.AppId = client.AppId; + request.AppId = client.WechatAppId; if (request.CardExtra != null && string.IsNullOrEmpty(request.CardExtra.Nonce)) request.CardExtra.Nonce = Guid.NewGuid().ToString("N"); diff --git a/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteCgibinComponentExtensions.cs b/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteCgibinComponentExtensions.cs index 9b87e9d1..c3597a3d 100644 --- a/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteCgibinComponentExtensions.cs +++ b/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteCgibinComponentExtensions.cs @@ -25,10 +25,10 @@ namespace SKIT.FlurlHttpClient.Wechat.Api if (request is null) throw new ArgumentNullException(nameof(request)); if (string.IsNullOrEmpty(request.ComponentAppId)) - request.ComponentAppId = client.AppId; + request.ComponentAppId = client.WechatAppId; if (string.IsNullOrEmpty(request.ComponentSecret)) - request.ComponentSecret = client.AppSecret; + request.ComponentSecret = client.WechatAppSecret; IFlurlRequest flurlReq = client .CreateRequest(HttpMethod.Post, "cgi-bin", "component", "api_start_push_ticket") @@ -51,10 +51,10 @@ namespace SKIT.FlurlHttpClient.Wechat.Api if (request is null) throw new ArgumentNullException(nameof(request)); if (string.IsNullOrEmpty(request.ComponentAppId)) - request.ComponentAppId = client.AppId; + request.ComponentAppId = client.WechatAppId; if (string.IsNullOrEmpty(request.ComponentSecret)) - request.ComponentSecret = client.AppSecret; + request.ComponentSecret = client.WechatAppSecret; IFlurlRequest flurlReq = client .CreateRequest(HttpMethod.Post, "cgi-bin", "component", "api_component_token") @@ -77,7 +77,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Api if (request is null) throw new ArgumentNullException(nameof(request)); if (string.IsNullOrEmpty(request.ComponentAppId)) - request.ComponentAppId = client.AppId; + request.ComponentAppId = client.WechatAppId; IFlurlRequest flurlReq = client .CreateRequest(HttpMethod.Post, "cgi-bin", "component", "api_create_preauthcode") @@ -101,7 +101,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Api if (request is null) throw new ArgumentNullException(nameof(request)); if (string.IsNullOrEmpty(request.ComponentAppId)) - request.ComponentAppId = client.AppId; + request.ComponentAppId = client.WechatAppId; IFlurlRequest flurlReq = client .CreateRequest(HttpMethod.Post, "cgi-bin", "component", "api_query_auth") @@ -125,7 +125,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Api if (request is null) throw new ArgumentNullException(nameof(request)); if (string.IsNullOrEmpty(request.ComponentAppId)) - request.ComponentAppId = client.AppId; + request.ComponentAppId = client.WechatAppId; IFlurlRequest flurlReq = client .CreateRequest(HttpMethod.Post, "cgi-bin", "component", "api_authorizer_token") @@ -149,7 +149,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Api if (request is null) throw new ArgumentNullException(nameof(request)); if (string.IsNullOrEmpty(request.ComponentAppId)) - request.ComponentAppId = client.AppId; + request.ComponentAppId = client.WechatAppId; IFlurlRequest flurlReq = client .CreateRequest(HttpMethod.Post, "cgi-bin", "component", "api_get_authorizer_info") @@ -173,7 +173,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Api if (request is null) throw new ArgumentNullException(nameof(request)); if (string.IsNullOrEmpty(request.ComponentAppId)) - request.ComponentAppId = client.AppId; + request.ComponentAppId = client.WechatAppId; IFlurlRequest flurlReq = client .CreateRequest(HttpMethod.Post, "cgi-bin", "component", "api_get_authorizer_list") @@ -197,7 +197,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Api if (request is null) throw new ArgumentNullException(nameof(request)); if (string.IsNullOrEmpty(request.ComponentAppId)) - request.ComponentAppId = client.AppId; + request.ComponentAppId = client.WechatAppId; IFlurlRequest flurlReq = client .CreateRequest(HttpMethod.Post, "cgi-bin", "component", "api_get_authorizer_option") @@ -221,7 +221,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Api if (request is null) throw new ArgumentNullException(nameof(request)); if (string.IsNullOrEmpty(request.ComponentAppId)) - request.ComponentAppId = client.AppId; + request.ComponentAppId = client.WechatAppId; IFlurlRequest flurlReq = client .CreateRequest(HttpMethod.Post, "cgi-bin", "component", "api_set_authorizer_option") diff --git a/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteCgibinExpressExtensions.cs b/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteCgibinExpressExtensions.cs index fcdd04b3..22df329a 100644 --- a/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteCgibinExpressExtensions.cs +++ b/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteCgibinExpressExtensions.cs @@ -19,12 +19,12 @@ namespace SKIT.FlurlHttpClient.Wechat.Api if (string.IsNullOrEmpty(request.ShopId)) { - request.ShopId = client.ImmeDeliveryAppKey; + request.ShopId = client.WechatImmeDeliveryAppKey; } if (string.IsNullOrEmpty(request.DeliverySignature)) { - string plainText = $"{request.ShopId}{request.ShopOrderId}{client.ImmeDeliveryAppSecret}"; + string plainText = $"{request.ShopId}{request.ShopOrderId}{client.WechatImmeDeliveryAppSecret}"; request.DeliverySignature = Security.SHA1Utility.Hash(plainText).ToLower(); } diff --git a/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteCgibinExtensions.cs b/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteCgibinExtensions.cs index 948d9f6a..326f7bab 100644 --- a/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteCgibinExtensions.cs +++ b/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteCgibinExtensions.cs @@ -30,8 +30,8 @@ namespace SKIT.FlurlHttpClient.Wechat.Api .CreateRequest(HttpMethod.Get, "cgi-bin", "token") .SetOptions(request) .SetQueryParam("grant_type", request.GrantType) - .SetQueryParam("appid", client.AppId) - .SetQueryParam("secret", client.AppSecret); + .SetQueryParam("appid", client.WechatAppId) + .SetQueryParam("secret", client.WechatAppSecret); return await client.SendRequestAsync(flurlReq, cancellationToken: cancellationToken); } @@ -116,7 +116,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Api if (request is null) throw new ArgumentNullException(nameof(request)); if (string.IsNullOrEmpty(request.AppId)) - request.AppId = client.AppId; + request.AppId = client.WechatAppId; IFlurlRequest flurlReq = client .CreateRequest(HttpMethod.Post, "cgi-bin", "clear_quota") diff --git a/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteCgibinMaterialExtensions.cs b/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteCgibinMaterialExtensions.cs index 0345d87e..b62248f5 100644 --- a/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteCgibinMaterialExtensions.cs +++ b/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteCgibinMaterialExtensions.cs @@ -83,7 +83,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Api string boundary = "--BOUNDARY--" + DateTimeOffset.Now.Ticks.ToString("x"); using var fileContent = new ByteArrayContent(request.FileBytes ?? new byte[0]); - using var descContent = new ByteArrayContent(Encoding.UTF8.GetBytes(client.JsonSerializer.Serialize(request))); + using var descContent = new ByteArrayContent(Encoding.UTF8.GetBytes(client.FlurlJsonSerializer.Serialize(request))); using var httpContent = new MultipartFormDataContent(boundary); httpContent.Add(fileContent, "\"media\"", "\"" + request.FileName + "\""); httpContent.Headers.ContentType = MediaTypeHeaderValue.Parse("multipart/form-data; boundary=" + boundary); diff --git a/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteCgibinMidasExtensions.cs b/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteCgibinMidasExtensions.cs index 28d662cb..4e09a5dd 100644 --- a/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteCgibinMidasExtensions.cs +++ b/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteCgibinMidasExtensions.cs @@ -22,7 +22,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Api if (string.IsNullOrEmpty(request.AppId)) { - request.AppId = client.AppId; + request.AppId = client.WechatAppId; } if (!request.Timestamp.HasValue) @@ -46,8 +46,8 @@ namespace SKIT.FlurlHttpClient.Wechat.Api string plainText = string.Join("&", paramMap.Select(e => $"{e.Key}={e.Value}")) + $"&org_loc={reqLoc}" + $"&method={method.ToUpper()}" - + $"&secret={client.MidasAppKey}"; - request.Signature = Security.HMACSHA256Utility.Hash(client.MidasAppKey ?? string.Empty, plainText).ToLower(); + + $"&secret={client.WechatMidasAppKey}"; + request.Signature = Security.HMACSHA256Utility.Hash(client.WechatMidasAppKey ?? string.Empty, plainText).ToLower(); } return request; diff --git a/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteNontaxExtensions.cs b/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteNontaxExtensions.cs index 37b92c1f..7c11ea37 100644 --- a/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteNontaxExtensions.cs +++ b/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteNontaxExtensions.cs @@ -72,7 +72,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Api if (request is null) throw new ArgumentNullException(nameof(request)); if (string.IsNullOrEmpty(request.AppId)) - request.AppId = client.AppId; + request.AppId = client.WechatAppId; IFlurlRequest flurlReq = client .CreateRequest(HttpMethod.Post, "nontax", "insertbill") @@ -97,7 +97,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Api if (request is null) throw new ArgumentNullException(nameof(request)); if (string.IsNullOrEmpty(request.AppId)) - request.AppId = client.AppId; + request.AppId = client.WechatAppId; IFlurlRequest flurlReq = client .CreateRequest(HttpMethod.Post, "nontax", "queryfee") @@ -121,7 +121,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Api if (request is null) throw new ArgumentNullException(nameof(request)); if (string.IsNullOrEmpty(request.AppId)) - request.AppId = client.AppId; + request.AppId = client.WechatAppId; IFlurlRequest flurlReq = client .CreateRequest(HttpMethod.Post, "nontax", "unifiedorder") @@ -145,7 +145,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Api if (request is null) throw new ArgumentNullException(nameof(request)); if (string.IsNullOrEmpty(request.AppId)) - request.AppId = client.AppId; + request.AppId = client.WechatAppId; IFlurlRequest flurlReq = client .CreateRequest(HttpMethod.Post, "nontax", "getorder") @@ -169,7 +169,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Api if (request is null) throw new ArgumentNullException(nameof(request)); if (string.IsNullOrEmpty(request.AppId)) - request.AppId = client.AppId; + request.AppId = client.WechatAppId; IFlurlRequest flurlReq = client .CreateRequest(HttpMethod.Post, "nontax", "refund") @@ -193,7 +193,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Api if (request is null) throw new ArgumentNullException(nameof(request)); if (string.IsNullOrEmpty(request.AppId)) - request.AppId = client.AppId; + request.AppId = client.WechatAppId; IFlurlRequest flurlReq = client .CreateRequest(HttpMethod.Post, "nontax", "downloadbill") @@ -217,7 +217,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Api if (request is null) throw new ArgumentNullException(nameof(request)); if (string.IsNullOrEmpty(request.AppId)) - request.AppId = client.AppId; + request.AppId = client.WechatAppId; IFlurlRequest flurlReq = client .CreateRequest(HttpMethod.Post, "nontax", "notifyinconsistentorder") @@ -241,7 +241,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Api if (request is null) throw new ArgumentNullException(nameof(request)); if (string.IsNullOrEmpty(request.AppId)) - request.AppId = client.AppId; + request.AppId = client.WechatAppId; IFlurlRequest flurlReq = client .CreateRequest(HttpMethod.Post, "nontax", "mocknotification") @@ -265,7 +265,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Api if (request is null) throw new ArgumentNullException(nameof(request)); if (string.IsNullOrEmpty(request.AppId)) - request.AppId = client.AppId; + request.AppId = client.WechatAppId; IFlurlRequest flurlReq = client .CreateRequest(HttpMethod.Post, "nontax", "mockqueryfee") @@ -289,7 +289,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Api if (request is null) throw new ArgumentNullException(nameof(request)); if (string.IsNullOrEmpty(request.AppId)) - request.AppId = client.AppId; + request.AppId = client.WechatAppId; IFlurlRequest flurlReq = client .CreateRequest(HttpMethod.Post, "nontax", "micropay") @@ -313,7 +313,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Api if (request is null) throw new ArgumentNullException(nameof(request)); if (string.IsNullOrEmpty(request.AppId)) - request.AppId = client.AppId; + request.AppId = client.WechatAppId; IFlurlRequest flurlReq = client .CreateRequest(HttpMethod.Post, "nontax", "getorderlist") diff --git a/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteProductExtensions.cs b/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteProductExtensions.cs index 8513ab59..883b626f 100644 --- a/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteProductExtensions.cs +++ b/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteProductExtensions.cs @@ -114,7 +114,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Api if (request is null) throw new ArgumentNullException(nameof(request)); if (string.IsNullOrEmpty(request.AppId)) - request.AppId = client.AppId; + request.AppId = client.WechatAppId; IFlurlRequest flurlReq = client .CreateRequest(HttpMethod.Post, "product", "register", "submit_merchantinfo") @@ -138,7 +138,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Api if (request is null) throw new ArgumentNullException(nameof(request)); if (string.IsNullOrEmpty(request.AppId)) - request.AppId = client.AppId; + request.AppId = client.WechatAppId; IFlurlRequest flurlReq = client .CreateRequest(HttpMethod.Post, "product", "register", "submit_basicinfo") diff --git a/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteSemanticExtensions.cs b/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteSemanticExtensions.cs index 65d753d4..27ebd418 100644 --- a/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteSemanticExtensions.cs +++ b/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteSemanticExtensions.cs @@ -28,7 +28,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Api if (request is null) throw new ArgumentNullException(nameof(request)); if (string.IsNullOrEmpty(request.AppId)) - request.AppId = client.AppId; + request.AppId = client.WechatAppId; IFlurlRequest flurlReq = client .CreateRequest(HttpMethod.Post, "semantic", "semproxy", "search") diff --git a/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteSnsExtensions.cs b/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteSnsExtensions.cs index c73b185b..1d42d399 100644 --- a/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteSnsExtensions.cs +++ b/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteSnsExtensions.cs @@ -30,8 +30,8 @@ namespace SKIT.FlurlHttpClient.Wechat.Api .CreateRequest(HttpMethod.Get, "sns", "oauth2", "access_token") .SetOptions(request) .SetQueryParam("grant_type", request.GrantType) - .SetQueryParam("appid", client.AppId) - .SetQueryParam("secret", client.AppSecret) + .SetQueryParam("appid", client.WechatAppId) + .SetQueryParam("secret", client.WechatAppSecret) .SetQueryParam("code", request.Code); return await client.SendRequestAsync(flurlReq, cancellationToken: cancellationToken); @@ -56,7 +56,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Api .CreateRequest(HttpMethod.Get, "sns", "oauth2", "refresh_token") .SetOptions(request) .SetQueryParam("grant_type", request.GrantType) - .SetQueryParam("appid", client.AppId) + .SetQueryParam("appid", client.WechatAppId) .SetQueryParam("refresh_token", request.RefreshToken); return await client.SendRequestAsync(flurlReq, cancellationToken: cancellationToken); @@ -129,8 +129,8 @@ namespace SKIT.FlurlHttpClient.Wechat.Api .CreateRequest(HttpMethod.Get, "sns", "jscode2session") .SetOptions(request) .SetQueryParam("grant_type", request.GrantType) - .SetQueryParam("appid", client.AppId) - .SetQueryParam("secret", client.AppSecret) + .SetQueryParam("appid", client.WechatAppId) + .SetQueryParam("secret", client.WechatAppSecret) .SetQueryParam("js_code", request.JsCode); return await client.SendRequestAsync(flurlReq, cancellationToken: cancellationToken); @@ -151,7 +151,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Api if (request is null) throw new ArgumentNullException(nameof(request)); if (string.IsNullOrEmpty(request.ComponentAppId)) - request.ComponentAppId = client.AppId; + request.ComponentAppId = client.WechatAppId; IFlurlRequest flurlReq = client .CreateRequest(HttpMethod.Get, "sns", "component", "jscode2session") diff --git a/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteWxaBusinessExtensions.cs b/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteWxaBusinessExtensions.cs index 75983ea7..48a4d6b3 100644 --- a/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteWxaBusinessExtensions.cs +++ b/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteWxaBusinessExtensions.cs @@ -26,7 +26,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Api if (request is null) throw new ArgumentNullException(nameof(request)); if (string.IsNullOrEmpty(request.AppId)) - request.AppId = client.AppId; + request.AppId = client.WechatAppId; IFlurlRequest flurlReq = client .CreateRequest(HttpMethod.Post, "wxa", "business", "getpayfororder") diff --git a/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteWxaExtensions.cs b/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteWxaExtensions.cs index d54374f5..150485b8 100644 --- a/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteWxaExtensions.cs +++ b/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteWxaExtensions.cs @@ -416,7 +416,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Api if (request is null) throw new ArgumentNullException(nameof(request)); if (string.IsNullOrEmpty(request.AppId)) - request.AppId = client.AppId; + request.AppId = client.WechatAppId; IFlurlRequest flurlReq = client .CreateRequest(HttpMethod.Post, "wxa", "getuserriskrank") diff --git a/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientParameterExtensions.cs b/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientParameterExtensions.cs index dc51cee0..3b024f9c 100644 --- a/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientParameterExtensions.cs +++ b/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientParameterExtensions.cs @@ -37,7 +37,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Api return new ReadOnlyDictionary(new Dictionary() { - { "appId", client.AppId }, + { "appId", client.WechatAppId }, { "timestamp", timestamp }, { "nonceStr", nonce }, { "signature", sign } @@ -63,7 +63,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Api SortedSet sortedParams = new SortedSet(); sortedParams.Add(cardType); sortedParams.Add(timestamp); - sortedParams.Add(client.AppId); + sortedParams.Add(client.WechatAppId); sortedParams.Add(nonce); sortedParams.Add(wxcardTicket); string cardSign = Security.SHA1Utility.Hash(string.Join(string.Empty, sortedParams)).ToLower(); diff --git a/src/SKIT.FlurlHttpClient.Wechat.Api/WechatApiClient.cs b/src/SKIT.FlurlHttpClient.Wechat.Api/WechatApiClient.cs index 0b796025..d117f208 100644 --- a/src/SKIT.FlurlHttpClient.Wechat.Api/WechatApiClient.cs +++ b/src/SKIT.FlurlHttpClient.Wechat.Api/WechatApiClient.cs @@ -20,34 +20,34 @@ namespace SKIT.FlurlHttpClient.Wechat.Api /// /// 获取当前客户端使用的微信 AppId。 /// - public string AppId { get; } + public string WechatAppId { get; } /// /// 获取当前客户端使用的微信 AppSecret。 /// - internal string AppSecret { get; } + internal string WechatAppSecret { get; } /// /// 获取当前客户端使用的即时配送公司帐号 AppKey(用于即使配送相关接口的请求签名)。 /// - internal string? ImmeDeliveryAppKey { get; } + internal string? WechatImmeDeliveryAppKey { get; } /// /// 获取当前客户端使用的即时配送公司帐号 AppSecret(用于即使配送相关接口的请求签名)。 /// - internal string? ImmeDeliveryAppSecret { get; } + internal string? WechatImmeDeliveryAppSecret { get; } /// /// 获取或设置米大师平台 AppKey(用于虚拟支付相关接口的请求签名)。 /// - internal string? MidasAppKey { get; } + internal string? WechatMidasAppKey { get; } /// /// 获取当前客户端使用的 JSON 序列化器。 /// - internal ISerializer JsonSerializer + internal ISerializer FlurlJsonSerializer { - get { return ProxyFlurlClient.Settings?.JsonSerializer ?? new FlurlNewtonsoftJsonSerializer(); } + get { return FlurlClient.Settings?.JsonSerializer ?? new FlurlNewtonsoftJsonSerializer(); } } /// @@ -59,14 +59,14 @@ namespace SKIT.FlurlHttpClient.Wechat.Api { if (options == null) throw new ArgumentNullException(nameof(options)); - AppId = options.AppId; - AppSecret = options.AppSecret; - ImmeDeliveryAppKey = options.ImmeDeliveryAppKey; - ImmeDeliveryAppSecret = options.ImmeDeliveryAppSecret; - MidasAppKey = options.MidasAppKey; + WechatAppId = options.AppId; + WechatAppSecret = options.AppSecret; + WechatImmeDeliveryAppKey = options.ImmeDeliveryAppKey; + WechatImmeDeliveryAppSecret = options.ImmeDeliveryAppSecret; + WechatMidasAppKey = options.MidasAppKey; - ProxyFlurlClient.BaseUrl = options.Endpoints ?? WechatApiEndpoints.DEFAULT; - ProxyFlurlClient.WithTimeout(TimeSpan.FromMilliseconds(options.Timeout)); + FlurlClient.BaseUrl = options.Endpoints ?? WechatApiEndpoints.DEFAULT; + FlurlClient.WithTimeout(TimeSpan.FromMilliseconds(options.Timeout)); } /// @@ -83,17 +83,17 @@ namespace SKIT.FlurlHttpClient.Wechat.Api /// 异步发起请求。 /// /// - /// + /// /// /// /// - public async Task SendRequestAsync(IFlurlRequest request, HttpContent? content = null, CancellationToken cancellationToken = default) + public async Task SendRequestAsync(IFlurlRequest flurlRequest, HttpContent? content = null, CancellationToken cancellationToken = default) where T : WechatApiResponse, new() { try { - using IFlurlResponse response = await base.SendRequestAsync(request, content, cancellationToken).ConfigureAwait(false); - return await GetResposneAsync(response).ConfigureAwait(false); + using IFlurlResponse flurlResponse = await base.SendRequestAsync(flurlRequest, content, cancellationToken).ConfigureAwait(false); + return await GetResposneAsync(flurlResponse).ConfigureAwait(false); } catch (FlurlHttpException ex) { @@ -105,17 +105,17 @@ namespace SKIT.FlurlHttpClient.Wechat.Api /// 异步发起请求。 /// /// - /// + /// /// /// /// - public async Task SendRequestWithJsonAsync(IFlurlRequest request, object? data = null, CancellationToken cancellationToken = default) + public async Task SendRequestWithJsonAsync(IFlurlRequest flurlRequest, object? data = null, CancellationToken cancellationToken = default) where T : WechatApiResponse, new() { try { - using IFlurlResponse response = await base.SendRequestWithJsonAsync(request, data, cancellationToken).ConfigureAwait(false); - return await GetResposneAsync(response).ConfigureAwait(false); + using IFlurlResponse flurlResponse = await base.SendRequestWithJsonAsync(flurlRequest, data, cancellationToken).ConfigureAwait(false); + return await GetResposneAsync(flurlResponse).ConfigureAwait(false); } catch (FlurlHttpException ex) { @@ -123,25 +123,25 @@ namespace SKIT.FlurlHttpClient.Wechat.Api } } - private async Task GetResposneAsync(IFlurlResponse response) + private async Task GetResposneAsync(IFlurlResponse flurlResponse) where T : WechatApiResponse, new() { - string contentType = response.Headers.GetAll("Content-Type").FirstOrDefault() ?? string.Empty; + string contentType = flurlResponse.Headers.GetAll("Content-Type").FirstOrDefault() ?? string.Empty; bool contentTypeIsNotJson = - (response.StatusCode != (int)HttpStatusCode.OK) || + (flurlResponse.StatusCode != (int)HttpStatusCode.OK) || (!contentType.StartsWith("application/json") && !contentType.StartsWith("text/json") && !contentType.StartsWith("text/plain")); - T result = contentTypeIsNotJson ? new T() : await response.GetJsonAsync().ConfigureAwait(false); - result.RawStatus = response.StatusCode; + T result = contentTypeIsNotJson ? new T() : await flurlResponse.GetJsonAsync().ConfigureAwait(false); + result.RawStatus = flurlResponse.StatusCode; result.RawHeaders = new ReadOnlyDictionary( - response.Headers + flurlResponse.Headers .GroupBy(e => e.Name) .ToDictionary( k => k.Key, v => string.Join(", ", v.Select(e => e.Value)) ) ); - result.RawBytes = await response.ResponseMessage.Content.ReadAsByteArrayAsync().ConfigureAwait(false); + result.RawBytes = await flurlResponse.ResponseMessage.Content.ReadAsByteArrayAsync().ConfigureAwait(false); return result; } }