-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathRoomExtensions.cs
89 lines (85 loc) · 2.26 KB
/
RoomExtensions.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
87
88
89
namespace Cisco.Spark
{
/// <summary>
/// Supported Room Types.
/// </summary>
public enum RoomType
{
Direct,
Group,
Unsupported
}
/// <summary>
/// Extensions for RoomType to/from API representations.
/// </summary>
public static class RoomTypeExtensions
{
/// <summary>
/// Gets the API representation of a RoomType.
/// </summary>
/// <param name="type"></param>
/// <returns></returns>
public static string ToApi(this RoomType type)
{
switch (type)
{
case RoomType.Direct:
return "direct";
case RoomType.Group:
return "group";
default:
return "";
}
}
/// <summary>
/// Converts a API representation of a Room's type to a RoomType.
/// </summary>
/// <param name="type"></param>
/// <returns></returns>
public static RoomType FromApi(string type)
{
switch (type)
{
case "direct":
return RoomType.Direct;
case "group":
return RoomType.Group;
default:
UnityEngine.Debug.LogWarning("Unsupported Room Type detected");
return RoomType.Unsupported;
}
}
}
/// <summary>
/// Room sorting options.
/// </summary>
public enum SortBy
{
ID,
LastActivity,
Created,
None
}
public static class SortByExtensions
{
/// <summary>
/// Gets the API representation of a SortBy argument.
/// </summary>
/// <param name="type">The Sortby argument.</param>
/// <returns>The string representation.</returns>
public static string ToApi(this SortBy type)
{
switch (type)
{
case SortBy.ID:
return "id";
case SortBy.LastActivity:
return "lastactivity";
case SortBy.Created:
return "created";
default:
return "";
}
}
}
}