-
Notifications
You must be signed in to change notification settings - Fork 23
/
ConnectionRequestResult.cs
86 lines (76 loc) · 2.34 KB
/
ConnectionRequestResult.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
using Microsoft.Bot.Schema;
using Newtonsoft.Json;
using System;
using Underscore.Bot.MessageRouting.Models;
namespace Underscore.Bot.MessageRouting.Results
{
/// <summary>
/// The connection request result type:
/// - Created: Connection request successfully created and added into the data store,
/// - AlreadyExists: A connection request for the requestor already exists,
/// - NotSetup: No aggregation channel or portal available (no-one to accept/reject the request),
/// - Rejected: The request was rejected,
/// - Error: Generic error, see the error message.
///
/// Note: Accepted requests are provided with connection result instead of this class.
/// </summary>
public enum ConnectionRequestResultType
{
Created = 0,
AlreadyExists,
NotSetup,
Rejected,
Error
};
[Serializable]
public class ConnectionRequestResult : AbstractMessageRouterResult
{
public ConnectionRequestResultType Type
{
get;
set;
}
/// <summary>
/// The connection request associated with this result.
/// </summary>
public ConnectionRequest ConnectionRequest
{
get;
set;
}
/// <summary>
/// If this result of type 'Rejected', this property can contain the user,
/// who rejected the request.
/// </summary>
public ConversationReference Rejecter
{
get;
set;
}
public ConnectionRequestResult() : base()
{
}
public static ConnectionRequestResult FromJson(string resultAsJsonString)
{
ConnectionRequestResult connectionRequestResult = null;
try
{
connectionRequestResult =
JsonConvert.DeserializeObject<ConnectionRequestResult>(resultAsJsonString);
}
catch (Exception e)
{
System.Diagnostics.Debug.WriteLine($"Failed to deserialize from JSON: {e.Message}");
}
return connectionRequestResult;
}
public override string ToJson()
{
return JsonConvert.SerializeObject(this);
}
public override string ToString()
{
return ToJson();
}
}
}