Skip to content

Commit

Permalink
docs: 完善文档
Browse files Browse the repository at this point in the history
  • Loading branch information
fudiwei committed Feb 18, 2024
1 parent 3b1859d commit ac941b4
Show file tree
Hide file tree
Showing 15 changed files with 41 additions and 41 deletions.
4 changes: 2 additions & 2 deletions docs/Push/Advanced_IHttpClientFactory.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
## 如何在 ASP.NET Core 中与 `IHttpClientFactory` 集成?
## 如何与 `IHttpClientFactory` 集成?

---

本功能来自于公共组件,请参阅公共组件下的相关文档:

> [《SKIT.FlurlHttpClient FAQ:如何在 ASP.NET Core 中与 IHttpClientFactory 集成?》](https://github.com/fudiwei/DotNetCore.SKIT.FlurlHttpClient/blob/main/docs/FAQ_IHttpClientFactory.md)
> [《SKIT.FlurlHttpClient FAQ:如何与 IHttpClientFactory 集成?》](https://github.com/fudiwei/DotNetCore.SKIT.FlurlHttpClient/blob/main/docs/README.md)
---

Expand Down
2 changes: 1 addition & 1 deletion docs/Push/Advanced_Interceptor.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

本功能来自于公共组件,请参阅公共组件下的相关文档:

> [《SKIT.FlurlHttpClient FAQ:如何使用拦截器?》](https://github.com/fudiwei/DotNetCore.SKIT.FlurlHttpClient/blob/main/docs/FAQ_Interceptor.md)
> [《SKIT.FlurlHttpClient FAQ:如何使用拦截器?》](https://github.com/fudiwei/DotNetCore.SKIT.FlurlHttpClient/blob/main/docs/README.md)
---

Expand Down
2 changes: 1 addition & 1 deletion docs/Push/Advanced_JsonSerializer.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

本功能来自于公共组件,请参阅公共组件下的相关文档:

> [《SKIT.FlurlHttpClient FAQ:如何指定 JSON 序列化器?》](https://github.com/fudiwei/DotNetCore.SKIT.FlurlHttpClient/blob/main/docs/FAQ_JsonSerializer.md)
> [《SKIT.FlurlHttpClient FAQ:如何指定 JSON 序列化器?》](https://github.com/fudiwei/DotNetCore.SKIT.FlurlHttpClient/blob/main/docs/README.md)
---

Expand Down
6 changes: 3 additions & 3 deletions docs/Push/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ var options = new BaiduPushClientOptions()
ApiKey = "百度云推送 API KEY",
SecretKey = "百度云推送 Secret Key"
};
var client = new BaiduPushClient(options);
var client = BaiduPushClientBuilder.Create(options).Build();
```

### 请求 & 响应:
Expand Down Expand Up @@ -75,13 +75,13 @@ else

## 基础用法

- [如何快速找到需要调用的 API 模型类名 / 方法名?](./Basic_ModelDefinition.md)
- [如何快速找到需要调用的 API 模型类名 / 方法名?](./Basic_ModelDefinition.md)

---

## 高级技巧

- [如何在 ASP.NET Core 中与 `IHttpClientFactory` 集成?](./Advanced_IHttpClientFactory.md)
- [如何与 `IHttpClientFactory` 集成?](./Advanced_IHttpClientFactory.md)

- [如何指定 JSON 序列化器?](./Advanced_JsonSerializer.md)

Expand Down
4 changes: 2 additions & 2 deletions docs/SmartApp/Advanced_IHttpClientFactory.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
## 如何在 ASP.NET Core 中与 `IHttpClientFactory` 集成?
## 如何与 `IHttpClientFactory` 集成?

---

本功能来自于公共组件,请参阅公共组件下的相关文档:

> [《SKIT.FlurlHttpClient FAQ:如何在 ASP.NET Core 中与 IHttpClientFactory 集成?》](https://github.com/fudiwei/DotNetCore.SKIT.FlurlHttpClient/blob/main/docs/FAQ_IHttpClientFactory.md)
> [《SKIT.FlurlHttpClient FAQ:如何与 IHttpClientFactory 集成?》](https://github.com/fudiwei/DotNetCore.SKIT.FlurlHttpClient/blob/main/docs/README.md)
---

Expand Down
2 changes: 1 addition & 1 deletion docs/SmartApp/Advanced_Interceptor.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

本功能来自于公共组件,请参阅公共组件下的相关文档:

> [《SKIT.FlurlHttpClient FAQ:如何使用拦截器?》](https://github.com/fudiwei/DotNetCore.SKIT.FlurlHttpClient/blob/main/docs/FAQ_Interceptor.md)
> [《SKIT.FlurlHttpClient FAQ:如何使用拦截器?》](https://github.com/fudiwei/DotNetCore.SKIT.FlurlHttpClient/blob/main/docs/README.md)
---

Expand Down
2 changes: 1 addition & 1 deletion docs/SmartApp/Advanced_JsonSerializer.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

本功能来自于公共组件,请参阅公共组件下的相关文档:

> [《SKIT.FlurlHttpClient FAQ:如何指定 JSON 序列化器?》](https://github.com/fudiwei/DotNetCore.SKIT.FlurlHttpClient/blob/main/docs/FAQ_JsonSerializer.md)
> [《SKIT.FlurlHttpClient FAQ:如何指定 JSON 序列化器?》](https://github.com/fudiwei/DotNetCore.SKIT.FlurlHttpClient/blob/main/docs/README.md)
---

Expand Down
18 changes: 9 additions & 9 deletions docs/SmartApp/Basic_EventDeserialization.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@

```csharp
/* 如果是 JSON 格式的通知内容,以 text 事件为例 */
string callbackJson = "{ ... }";
var callbackModel = client.DeserializeEventFromJson<Events.TextMessageEvent>(callbackJson);
string webhookJson = "{ ... }";
var webhookModel = client.DeserializeEventFromJson<Events.TextMessageEvent>(webhookJson);

/* 如果是 XML 格式的通知内容,以 text 事件为例 */
string callbackXml = "<xml> ... </xml>";
var callbackModel = client.DeserializeEventFromXml<Events.TextMessageEvent>(callbackXml);
string webhookXml = "<xml> ... </xml>";
var webhookModel = client.DeserializeEventFromXml<Events.TextMessageEvent>(webhookXml);
```

完整的回调通知模型定义可以参考项目目录下的 _src/SKIT.FlurlHttpClient.Baidu.SmartApp/SDK/OpenApi/Events__src/SKIT.FlurlHttpClient.Baidu.SmartApp/SDK/ThirdParty/Events_ 目录。
完整的回调通知模型定义可以参考项目目录下的 _src/SKIT.FlurlHttpClient.Baidu.SmartApp/ExtendedSDK/OpenApi/Events__src/SKIT.FlurlHttpClient.Baidu.SmartApp/ExtendedSDK/ThirdParty/Events_ 目录。

---

Expand All @@ -27,21 +27,21 @@ var callbackModel = client.DeserializeEventFromXml<Events.TextMessageEvent>(call
一种是利用 `System.Xml.Linq`

```csharp
XDocument xDoc = XDocument.Parse(callbackXml);
XDocument xDoc = XDocument.Parse(webhookXml);
string msgType = xDoc.Root?.Element("MsgType")?.Value?.ToUpper();
```

另一种是利用本库的扩展方法:

```csharp
BaiduSmartAppOpenApiEvent eventModel = client.DeserializeEventFromXml(callbackXml);
BaiduSmartAppOpenApiEvent eventModel = client.DeserializeEventFromXml(webhookXml);
string msgType = eventModel.MessageType?.ToUpper();

switch (msgType)
{
case "TEXT":
{
var callbackModel = client.DeserializeEventFromXml<Events.TextMessageEvent>(callbackXml);
var webhookModel = client.DeserializeEventFromXml<Events.TextMessageEvent>(webhookXml);
}
break;
// 省略其他情况
Expand All @@ -65,5 +65,5 @@ var options = new BaiduSmartAppOpenApiClientOptions()
PushToken = "Token",
PushEncodingAESKey = "EncodingAESKey"
};
var client = new BaiduSmartAppOpenApiClient(options);
var client = BaiduSmartAppOpenApiClientBuilder.Create(options).Build();
```
10 changes: 5 additions & 5 deletions docs/SmartApp/Basic_EventSignatureVerification.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,18 @@ var client = new BaiduSmartAppOpenApiClient(options);

/* 验证百度小程序服务器 */
bool ret = client.VerifyEventSignatureForEcho(
callbackTimestamp: "百度小程序回调通知中的 timestamp 字段",
callbackNonce: "百度小程序回调通知中的 nonce 字段",
callbackSignature: "百度小程序回调通知中的 signature 字段"
webhookTimestamp: "百度小程序回调通知中的 timestamp 字段",
webhookNonce: "百度小程序回调通知中的 nonce 字段",
webhookSignature: "百度小程序回调通知中的 signature 字段"
);

/* 验证安全模式下 XML 消息的签名 */
bool ret = client.VerifyEventSignatureFromXml(
callbackXml: "百度小程序发来的通知内容,形如:<xml><Encrypt>...</Encrypt></xml>"
webhookXml: "百度小程序发来的通知内容,形如:<xml><Encrypt>...</Encrypt></xml>"
);

/* 验证安全模式下 JSON 消息的签名 */
bool ret = client.VerifyEventSignatureFromJson(
callbackJson: "百度小程序发来的通知内容,形如:{\"Encrypt\":\"...\"}"
webhookJson: "百度小程序发来的通知内容,形如:{\"Encrypt\":\"...\"}"
);
```
2 changes: 1 addition & 1 deletion docs/SmartApp/Basic_ModelDefinition.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

再有,每个对象的命名与官方文档的接口地址大体保持一致。例如刚刚提到的推送模板消息,它的接口地址是 `[POST] /rest/2.0/smartapp/template/send`,将其中的反斜杠去掉、忽略固定段“/2.0/smartapp/”、并以大驼峰命名法的方式调整它,就可以得到前文提到的几个对象了。如果路由中带有版本信息,那么版本号一般都在结尾处,例如接口 `[POST] /rest/2.0/smartapp/riskDetection/v2/syncCheckText` 对应的是 `RestRiskDetectionSyncCheckTextV2`

完整的模型定义可以参考项目目录下的 _src/SKIT.FlurlHttpClient.Baidu.SmartApp/SDK/OpenApi/Models__src/SKIT.FlurlHttpClient.Baidu.SmartApp/SDK/ThirdParty/Models_ 目录。
完整的模型定义可以参考项目目录下的 _src/SKIT.FlurlHttpClient.Baidu.SmartApp/ExtendedSDK/OpenApi/Models__src/SKIT.FlurlHttpClient.Baidu.SmartApp/ExtendedSDK/ThirdParty/Models_ 目录。

---

Expand Down
16 changes: 8 additions & 8 deletions docs/SmartApp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

```csharp
/* 以服务端 OpenAPI 为例 */
using SKIT.FlurlHttpClient.Baidu.SmartApp.SDK.OpenApi;
using SKIT.FlurlHttpClient.Baidu.SmartApp.ExtendedSDK.OpenApi;

var options = new BaiduSmartAppOpenApiClientOptions()
{
Expand All @@ -40,12 +40,12 @@ var options = new BaiduSmartAppOpenApiClientOptions()
AppSecret = "百度小程序 AppSecret",
PaymentServiceAppKey = "百度收银台相关服务 AppKey,不用则不填"
};
var client = new BaiduSmartAppOpenApiClient(options);
var client = BaiduSmartAppOpenApiClientBuilder.Create(options).Build();



/* 以第三方平台 OpenAPI 为例 */
using SKIT.FlurlHttpClient.Baidu.SmartApp.SDK.ThirdParty;
using SKIT.FlurlHttpClient.Baidu.SmartApp.ExtendedSDK.ThirdParty;

var options = new BaiduSmartAppThirdPartyClientOptions()
{
Expand All @@ -54,16 +54,16 @@ var options = new BaiduSmartAppThirdPartyClientOptions()
AppSecret = "百度小程序 AppSecret",
PaymentServiceAppKey = "百度收银台相关服务 AppKey,不用则不填"
};
var client = new BaiduSmartAppThirdPartyClient(options);
var client = BaiduSmartAppThirdPartyClientBuilder.Create(options).Build();
```

### 请求 & 响应:

```csharp
using SKIT.FlurlHttpClient.Baidu.SmartApp;
using SKIT.FlurlHttpClient.Baidu.SmartApp.SDK.OpenApi.Models;
using SKIT.FlurlHttpClient.Baidu.SmartApp.ExtendedSDK.OpenApi.Models;

/* 以获取小程序二维码短链接口为例 */
/* 以服务端 OpenAPI 获取小程序二维码短链接口为例 */
var request = new RestQrcodeGetV2Request()
{
PagePath = "/pages/index",
Expand All @@ -85,7 +85,7 @@ else

## 基础用法

- [如何快速找到需要调用的 API 模型类名 / 方法名?](./Basic_ModelDefinition.md)
- [如何快速找到需要调用的 API 模型类名 / 方法名?](./Basic_ModelDefinition.md)

- [如何解析回调通知事件?](./Basic_EventDeserialization.md)

Expand All @@ -95,7 +95,7 @@ else

## 高级技巧

- [如何在 ASP.NET Core 中与 `IHttpClientFactory` 集成?](./Advanced_IHttpClientFactory.md)
- [如何与 `IHttpClientFactory` 集成?](./Advanced_IHttpClientFactory.md)

- [如何指定 JSON 序列化器?](./Advanced_JsonSerializer.md)

Expand Down
4 changes: 2 additions & 2 deletions docs/Translate/Advanced_IHttpClientFactory.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
## 如何在 ASP.NET Core 中与 `IHttpClientFactory` 集成?
## 如何与 `IHttpClientFactory` 集成?

---

本功能来自于公共组件,请参阅公共组件下的相关文档:

> [《SKIT.FlurlHttpClient FAQ:如何在 ASP.NET Core 中与 IHttpClientFactory 集成?》](https://github.com/fudiwei/DotNetCore.SKIT.FlurlHttpClient/blob/main/docs/FAQ_IHttpClientFactory.md)
> [《SKIT.FlurlHttpClient FAQ:如何与 IHttpClientFactory 集成?》](https://github.com/fudiwei/DotNetCore.SKIT.FlurlHttpClient/blob/main/docs/README.md)
---

Expand Down
2 changes: 1 addition & 1 deletion docs/Translate/Advanced_Interceptor.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

本功能来自于公共组件,请参阅公共组件下的相关文档:

> [《SKIT.FlurlHttpClient FAQ:如何使用拦截器?》](https://github.com/fudiwei/DotNetCore.SKIT.FlurlHttpClient/blob/main/docs/FAQ_Interceptor.md)
> [《SKIT.FlurlHttpClient FAQ:如何使用拦截器?》](https://github.com/fudiwei/DotNetCore.SKIT.FlurlHttpClient/blob/main/docs/README.md)
---

Expand Down
2 changes: 1 addition & 1 deletion docs/Translate/Advanced_JsonSerializer.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

本功能来自于公共组件,请参阅公共组件下的相关文档:

> [《SKIT.FlurlHttpClient FAQ:如何指定 JSON 序列化器?》](https://github.com/fudiwei/DotNetCore.SKIT.FlurlHttpClient/blob/main/docs/FAQ_JsonSerializer.md)
> [《SKIT.FlurlHttpClient FAQ:如何指定 JSON 序列化器?》](https://github.com/fudiwei/DotNetCore.SKIT.FlurlHttpClient/blob/main/docs/README.md)
---

Expand Down
6 changes: 3 additions & 3 deletions docs/Translate/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ var options = new BaiduTranslateClientOptions()
AppId = "百度翻译 AppId",
AppSecret = "百度翻译 AppSecret"
};
var client = new BaiduTranslateClient(options);
var client = BaiduTranslateClientBuilder.Create(options).Build();
```

### 请求 & 响应:
Expand Down Expand Up @@ -68,13 +68,13 @@ else

## 基础用法

- [如何快速找到需要调用的 API 模型类名 / 方法名?](./Basic_ModelDefinition.md)
- [如何快速找到需要调用的 API 模型类名 / 方法名?](./Basic_ModelDefinition.md)

---

## 高级技巧

- [如何在 ASP.NET Core 中与 `IHttpClientFactory` 集成?](./Advanced_IHttpClientFactory.md)
- [如何与 `IHttpClientFactory` 集成?](./Advanced_IHttpClientFactory.md)

- [如何指定 JSON 序列化器?](./Advanced_JsonSerializer.md)

Expand Down

0 comments on commit ac941b4

Please sign in to comment.