3
3
namespace SKIT . FlurlHttpClient . Wechat . OpenAI
4
4
{
5
5
/// <summary>
6
- /// 为 <see cref="WechatOpenAIClient "/> 提供回调通知事件的扩展方法。
6
+ /// 为 <see cref="WechatChatbotClient "/> 提供回调通知事件的扩展方法。
7
7
/// </summary>
8
- public static partial class WechatOpenAIClientEventExtensions
8
+ public static partial class WechatChatbotClientEventExtensions
9
9
{
10
10
/// <summary>
11
- /// <para>从 XML 反序列化得到 <see cref="WechatOpenAIEvent "/> 对象。</para>
11
+ /// <para>从 XML 反序列化得到 <see cref="WechatChatbotEvent "/> 对象。</para>
12
12
/// </summary>
13
13
/// <typeparam name="TEvent"></typeparam>
14
14
/// <param name="client"></param>
15
15
/// <param name="webhookXml"></param>
16
16
/// <returns></returns>
17
- public static TEvent DeserializeEventFromXml < TEvent > ( this WechatOpenAIClient client , string webhookXml )
18
- where TEvent : WechatOpenAIEvent , new ( )
17
+ public static TEvent DeserializeEventFromXml < TEvent > ( this WechatChatbotClient client , string webhookXml )
18
+ where TEvent : WechatChatbotEvent , new ( )
19
19
{
20
20
return InnerDeserializeEventFromXml < TEvent > ( client , webhookXml ) ;
21
21
}
22
22
23
23
/// <summary>
24
- /// <para>从 XML 反序列化得到 <see cref="WechatOpenAIEvent "/> 对象。</para>
24
+ /// <para>从 XML 反序列化得到 <see cref="WechatChatbotEvent "/> 对象。</para>
25
25
/// </summary>
26
26
/// <param name="client"></param>
27
27
/// <param name="webhookXml"></param>
28
28
/// <returns></returns>
29
- public static WechatOpenAIEvent DeserializeEventFromXml ( this WechatOpenAIClient client , string webhookXml )
29
+ public static WechatChatbotEvent DeserializeEventFromXml ( this WechatChatbotClient client , string webhookXml )
30
30
{
31
- return InnerDeserializeEventFromXml < WechatOpenAIEvent > ( client , webhookXml ) ;
31
+ return InnerDeserializeEventFromXml < WechatChatbotEvent > ( client , webhookXml ) ;
32
32
}
33
33
34
34
/// <summary>
35
- /// 将 <see cref="WechatOpenAIEvent "/> 对象序列化成 XML。
35
+ /// 将 <see cref="WechatChatbotEvent "/> 对象序列化成 XML。
36
36
/// </summary>
37
37
/// <typeparam name="TEvent"></typeparam>
38
38
/// <param name="client"></param>
39
39
/// <param name="webhookEvent"></param>
40
40
/// <returns></returns>
41
- public static string SerializeEventToXml < TEvent > ( this WechatOpenAIClient client , TEvent webhookEvent )
42
- where TEvent : WechatOpenAIEvent , new ( )
41
+ public static string SerializeEventToXml < TEvent > ( this WechatChatbotClient client , TEvent webhookEvent )
42
+ where TEvent : WechatChatbotEvent , new ( )
43
43
{
44
44
string xml ;
45
45
@@ -49,13 +49,13 @@ public static string SerializeEventToXml<TEvent>(this WechatOpenAIClient client,
49
49
}
50
50
catch ( Exception ex )
51
51
{
52
- throw new WechatOpenAIException ( "Failed to serialize event data. Please see the inner exception for more details." , ex ) ;
52
+ throw new WechatChatbotException ( "Failed to serialize event data. Please see the inner exception for more details." , ex ) ;
53
53
}
54
54
55
55
if ( string . IsNullOrEmpty ( client . Credentials . EncodingAESKey ) )
56
- throw new WechatOpenAIException ( "Failed to encrypt event data, because the push encoding AES key is not set." ) ;
56
+ throw new WechatChatbotException ( "Failed to encrypt event data, because the push encoding AES key is not set." ) ;
57
57
if ( string . IsNullOrEmpty ( client . Credentials . Token ) )
58
- throw new WechatOpenAIException ( "Failed to encrypt event data, because the push token is not set." ) ;
58
+ throw new WechatChatbotException ( "Failed to encrypt event data, because the push token is not set." ) ;
59
59
60
60
try
61
61
{
@@ -69,36 +69,36 @@ public static string SerializeEventToXml<TEvent>(this WechatOpenAIClient client,
69
69
}
70
70
catch ( Exception ex )
71
71
{
72
- throw new WechatOpenAIException ( "Failed to encrypt event data. Please see the inner exception for more details." , ex ) ;
72
+ throw new WechatChatbotException ( "Failed to encrypt event data. Please see the inner exception for more details." , ex ) ;
73
73
}
74
74
75
75
return xml ;
76
76
}
77
77
}
78
78
79
- partial class WechatOpenAIClientEventExtensions
79
+ partial class WechatChatbotClientEventExtensions
80
80
{
81
- private static TEvent InnerDeserializeEventFromXml < TEvent > ( this WechatOpenAIClient client , string webhookXml )
82
- where TEvent : WechatOpenAIEvent
81
+ private static TEvent InnerDeserializeEventFromXml < TEvent > ( this WechatChatbotClient client , string webhookXml )
82
+ where TEvent : WechatChatbotEvent
83
83
{
84
84
if ( client is null ) throw new ArgumentNullException ( nameof ( client ) ) ;
85
85
if ( webhookXml is null ) throw new ArgumentNullException ( webhookXml ) ;
86
86
87
87
try
88
88
{
89
89
if ( ! Utilities . WxMsgCryptor . TryParseXml ( webhookXml , out string ? encryptedXml ) )
90
- throw new WechatOpenAIException ( "Failed to decrypt event data, because of the encrypted data is empty." ) ;
90
+ throw new WechatChatbotException ( "Failed to decrypt event data, because of the encrypted data is empty." ) ;
91
91
92
92
webhookXml = Utilities . WxMsgCryptor . AESDecrypt ( cipherText : encryptedXml ! , encodingAESKey : client . Credentials . EncodingAESKey ! , out _ ) ;
93
93
return Utilities . XmlHelper . Deserialize < TEvent > ( webhookXml ) ;
94
94
}
95
- catch ( WechatOpenAIException )
95
+ catch ( WechatChatbotException )
96
96
{
97
97
throw ;
98
98
}
99
99
catch ( Exception ex )
100
100
{
101
- throw new WechatOpenAIException ( "Failed to deserialize event data. Please see the inner exception for more details." , ex ) ;
101
+ throw new WechatChatbotException ( "Failed to deserialize event data. Please see the inner exception for more details." , ex ) ;
102
102
}
103
103
}
104
104
}
0 commit comments