2
2
// Licensed under the MIT License.
3
3
4
4
using Microsoft . Agents . Core . Models ;
5
+ using System . Net ;
5
6
6
7
namespace Microsoft . Agents . Builder . App . AdaptiveCards
7
8
{
@@ -13,15 +14,15 @@ public static class AdaptiveCardInvokeResponseFactory
13
14
/// <summary>
14
15
/// Returns response with type "application/vnd.microsoft.card.adaptive".
15
16
/// </summary>
16
- /// <param name="adaptiveCard ">An Adaptive Card .</param>
17
+ /// <param name="adaptiveCardJson ">An AdaptiveCard JSON value .</param>
17
18
/// <returns>The response that includes an Adaptive Card that the client should display.</returns>
18
- public static AdaptiveCardInvokeResponse AdaptiveCard ( AdaptiveCard adaptiveCard )
19
+ public static AdaptiveCardInvokeResponse AdaptiveCard ( string adaptiveCardJson )
19
20
{
20
21
return new AdaptiveCardInvokeResponse
21
22
{
22
23
StatusCode = 200 ,
23
24
Type = "application/vnd.microsoft.card.adaptive" ,
24
- Value = adaptiveCard
25
+ Value = adaptiveCardJson
25
26
} ;
26
27
}
27
28
@@ -39,5 +40,52 @@ public static AdaptiveCardInvokeResponse Message(string message)
39
40
Value = message
40
41
} ;
41
42
}
43
+
44
+ /// <summary>
45
+ /// Creates an Error of type "BadRequest" AdaptiveCardInvokeResponse.
46
+ /// </summary>
47
+ /// <param name="message"></param>
48
+ public static AdaptiveCardInvokeResponse BadRequest ( string message )
49
+ {
50
+ return Error ( HttpStatusCode . BadRequest , "BadRequest" , message ) ;
51
+ }
52
+
53
+ /// <summary>
54
+ /// Creates an Error of type "NotSupported" AdaptiveCardInvokeResponse.
55
+ /// </summary>
56
+ /// <param name="message"></param>
57
+ public static AdaptiveCardInvokeResponse NotSupported ( string message )
58
+ {
59
+ return Error ( HttpStatusCode . BadRequest , "NotSupported" , message ) ;
60
+ }
61
+
62
+ /// <summary>
63
+ /// Creates an Error of type InternalError AdaptiveCardInvokeResponse.
64
+ /// </summary>
65
+ /// <param name="message"></param>
66
+ public static AdaptiveCardInvokeResponse InternalError ( string message )
67
+ {
68
+ return Error ( HttpStatusCode . InternalServerError , HttpStatusCode . InternalServerError . ToString ( ) , message ) ;
69
+ }
70
+
71
+ /// <summary>
72
+ /// Creates an Error AdaptiveCardInvokeResponse.
73
+ /// </summary>
74
+ /// <param name="message"></param>
75
+ /// <param name="statusCode">Defaults to HttpStatusCode.BadRequest.</param>
76
+ /// <param name="code">Defaults to HttpStatusCode.ToString()</param>
77
+ public static AdaptiveCardInvokeResponse Error ( HttpStatusCode statusCode , string code , string message )
78
+ {
79
+ return new AdaptiveCardInvokeResponse ( )
80
+ {
81
+ StatusCode = ( int ) statusCode ,
82
+ Type = "application/vnd.microsoft.error" ,
83
+ Value = new Error ( )
84
+ {
85
+ Code = code ?? statusCode . ToString ( ) ,
86
+ Message = message
87
+ }
88
+ } ;
89
+ }
42
90
}
43
- }
91
+ }
0 commit comments