This repository was archived by the owner on Jan 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathPocketAction.cs
More file actions
140 lines (125 loc) · 3.28 KB
/
PocketAction.cs
File metadata and controls
140 lines (125 loc) · 3.28 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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
namespace PocketSharp.Models
{
/// <summary>
/// All parameters which can be passed for a send action
/// </summary>
[DataContract]
public class PocketAction
{
/// <summary>
/// Gets or sets the action.
/// </summary>
/// <value>
/// The action.
/// </value>
[DataMember(Name = "action")]
public string Action { get; set; }
/// <summary>
/// Gets or sets the PocketItem ID.
/// </summary>
/// <value>
/// The ID.
/// </value>
[DataMember(Name = "item_id")]
public string ID { get; set; }
/// <summary>
/// Gets or sets the URI (for adding a new item).
/// </summary>
/// <value>
/// The URI.
/// </value>
[DataMember(Name = "url")]
public Uri Uri { get; set; }
/// <summary>
/// Gets or sets the Title (for adding a new item).
/// </summary>
/// <value>
/// The Title.
/// </value>
[DataMember(Name = "title")]
public string Title { get; set; }
/// <summary>
/// Gets or sets the associated Tweet ID.
/// </summary>
/// <value>
/// The Tweet ID.
/// </value>
[DataMember(Name = "ref_id")]
public string TweetID { get; set; }
/// <summary>
/// Gets or sets the time.
/// </summary>
/// <value>
/// The time.
/// </value>
[DataMember(Name = "time")]
public DateTime? Time { get; set; }
// specific params
/// <summary>
/// Gets or sets the tags.
/// </summary>
/// <value>
/// The tags.
/// </value>
[DataMember(Name = "tags")]
public string[] Tags { get; set; }
/// <summary>
/// Gets or sets the old tag.
/// </summary>
/// <value>
/// The old tag.
/// </value>
[DataMember(Name = "old_tag")]
public string OldTag { get; set; }
/// <summary>
/// Gets or sets the new tag.
/// </summary>
/// <value>
/// The new tag.
/// </value>
[DataMember(Name = "new_tag")]
public string NewTag { get; set; }
/// <summary>
/// Gets or sets the tag.
/// </summary>
/// <value>
/// The old tag.
/// </value>
[DataMember(Name = "tag")]
public string Tag { get; set; }
/// <summary>
/// Converts this instance to a parameter list.
/// </summary>
/// <returns></returns>
internal Dictionary<string, object> Convert()
{
Dictionary<string, object> parameters = new Dictionary<string, object>
{
{ "action", Action }
};
if (!String.IsNullOrEmpty(ID) && ID != "0")
parameters.Add("item_id", ID.ToString());
if (Time != null)
parameters.Add("time", Time != null ? Utilities.GetUnixTimestamp(Time).ToString() : null);
if (Tags != null)
parameters.Add("tags", Tags);
if (OldTag != null)
parameters.Add("old_tag", OldTag);
if (NewTag != null)
parameters.Add("new_tag", NewTag);
if (Tag != null)
parameters.Add("tag", Tag);
if (!String.IsNullOrEmpty(Title))
parameters.Add("title", Title);
if (!String.IsNullOrEmpty(TweetID))
parameters.Add("ref_id", TweetID);
if (Uri != null)
parameters.Add("url", Uri.OriginalString);
return parameters;
}
}
}