-
Notifications
You must be signed in to change notification settings - Fork 60
Expand file tree
/
Copy pathStatementsQuery.cs
More file actions
100 lines (91 loc) · 3.18 KB
/
StatementsQuery.cs
File metadata and controls
100 lines (91 loc) · 3.18 KB
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
90
91
92
93
94
95
96
97
98
99
100
/*
Copyright 2014 Rustici Software
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
using System;
using System.Collections.Generic;
namespace TinCan
{
public class StatementsQuery
{
// TODO: put in common location
private const String ISODateTimeFormat = "o";
public Agent agent { get; set; }
public Uri verbId { get; set; }
private string _activityId;
public string activityId {
get { return _activityId; }
set
{
Uri uri = new Uri(value);
_activityId = value;
}
}
public Nullable<Guid> registration { get; set; }
public Nullable<Boolean> relatedActivities { get; set; }
public Nullable<Boolean> relatedAgents { get; set; }
public Nullable<DateTime> since { get; set; }
public Nullable<DateTime> until { get; set; }
public Nullable<Int32> limit { get; set; }
public StatementsQueryResultFormat format { get; set; }
public Nullable<Boolean> ascending { get; set; }
public StatementsQuery() {}
public Dictionary<String, String> ToParameterMap (TCAPIVersion version)
{
var result = new Dictionary<String, String>();
if (agent != null)
{
result.Add("agent", agent.ToJSON(version));
}
if (verbId != null)
{
result.Add("verb", verbId.AbsoluteUri);
}
if (activityId != null)
{
result.Add("activity", activityId);
}
if (registration != null)
{
result.Add("registration", registration.Value.ToString());
}
if (relatedActivities != null)
{
result.Add("related_activities", relatedActivities.Value.ToString());
}
if (relatedAgents != null)
{
result.Add("related_agents", relatedAgents.Value.ToString());
}
if (since != null)
{
result.Add("since", since.Value.ToString(ISODateTimeFormat));
}
if (until != null)
{
result.Add("until", until.Value.ToString(ISODateTimeFormat));
}
if (limit != null)
{
result.Add("limit", limit.ToString());
}
if (format != null)
{
result.Add("format", format.ToString());
}
if (ascending != null)
{
result.Add("ascending", ascending.Value.ToString());
}
return result;
}
}
}