@beauraines/rtm-api 1.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +285 -0
- package/config.js +22 -0
- package/docs/RTMClient.html +2798 -0
- package/docs/RTMError.html +1029 -0
- package/docs/RTMList.html +966 -0
- package/docs/RTMResponse.html +868 -0
- package/docs/RTMSuccess.html +337 -0
- package/docs/RTMTask.html +2461 -0
- package/docs/RTMUser.html +6761 -0
- package/docs/client_auth.js.html +123 -0
- package/docs/client_index.js.html +241 -0
- package/docs/client_user.js.html +170 -0
- package/docs/global.html +386 -0
- package/docs/index.html +305 -0
- package/docs/list_index.js.html +159 -0
- package/docs/response_error.js.html +172 -0
- package/docs/response_response.js.html +160 -0
- package/docs/response_success.js.html +104 -0
- package/docs/scripts/linenumber.js +25 -0
- package/docs/scripts/prettify/Apache-License-2.0.txt +202 -0
- package/docs/scripts/prettify/lang-css.js +2 -0
- package/docs/scripts/prettify/prettify.js +28 -0
- package/docs/styles/jsdoc.css +664 -0
- package/docs/styles/prettify.css +79 -0
- package/docs/task_helper.js.html +531 -0
- package/docs/task_index.js.html +304 -0
- package/docs/user_index.js.html +347 -0
- package/docs/user_lists.js.html +208 -0
- package/docs/user_tasks.js.html +703 -0
- package/jsdoc.json +13 -0
- package/package.json +33 -0
- package/src/client/auth.js +65 -0
- package/src/client/index.js +182 -0
- package/src/client/user.js +112 -0
- package/src/list/helper.js +131 -0
- package/src/list/index.js +101 -0
- package/src/response/error.js +114 -0
- package/src/response/index.js +8 -0
- package/src/response/parse.js +51 -0
- package/src/response/response.js +102 -0
- package/src/response/success.js +46 -0
- package/src/task/helper.js +469 -0
- package/src/task/index.js +264 -0
- package/src/user/index.js +288 -0
- package/src/user/lists.js +150 -0
- package/src/user/tasks.js +708 -0
- package/src/utils/auth.js +188 -0
- package/src/utils/fetch.js +67 -0
- package/src/utils/get.js +247 -0
- package/src/utils/sign.js +93 -0
- package/src/utils/taskIds.js +188 -0
|
@@ -0,0 +1,703 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<title>user/tasks.js - Documentation</title>
|
|
6
|
+
|
|
7
|
+
<script src="scripts/prettify/prettify.js"></script>
|
|
8
|
+
<script src="scripts/prettify/lang-css.js"></script>
|
|
9
|
+
<!--[if lt IE 9]>
|
|
10
|
+
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
|
11
|
+
<![endif]-->
|
|
12
|
+
<link type="text/css" rel="stylesheet" href="styles/prettify.css">
|
|
13
|
+
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
|
|
14
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
15
|
+
</head>
|
|
16
|
+
<body>
|
|
17
|
+
|
|
18
|
+
<input type="checkbox" id="nav-trigger" class="nav-trigger" />
|
|
19
|
+
<label for="nav-trigger" class="navicon-button x">
|
|
20
|
+
<div class="navicon"></div>
|
|
21
|
+
</label>
|
|
22
|
+
|
|
23
|
+
<label for="nav-trigger" class="overlay"></label>
|
|
24
|
+
|
|
25
|
+
<nav>
|
|
26
|
+
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="RTMClient.html">RTMClient</a><ul class='methods'><li data-type='method'><a href="RTMClient.html#get">get</a></li><li data-type='method'><a href="RTMClient.html#~auth/getAuthToken">auth/getAuthToken</a></li><li data-type='method'><a href="RTMClient.html#~auth/getAuthUrl">auth/getAuthUrl</a></li><li data-type='method'><a href="RTMClient.html#~auth/verifyAuthToken">auth/verifyAuthToken</a></li><li data-type='method'><a href="RTMClient.html#~user/create">user/create</a></li><li data-type='method'><a href="RTMClient.html#~user/export">user/export</a></li><li data-type='method'><a href="RTMClient.html#~user/exportToString">user/exportToString</a></li><li data-type='method'><a href="RTMClient.html#~user/import">user/import</a></li><li data-type='method'><a href="RTMClient.html#~user/importFromString">user/importFromString</a></li></ul></li><li><a href="RTMError.html">RTMError</a><ul class='methods'><li data-type='method'><a href="RTMError.html#.networkError">networkError</a></li><li data-type='method'><a href="RTMError.html#.rateLimitError">rateLimitError</a></li><li data-type='method'><a href="RTMError.html#.referenceError">referenceError</a></li><li data-type='method'><a href="RTMError.html#.responseError">responseError</a></li><li data-type='method'><a href="RTMError.html#.serverError">serverError</a></li><li data-type='method'><a href="RTMError.html#toString">toString</a></li></ul></li><li><a href="RTMList.html">RTMList</a></li><li><a href="RTMResponse.html">RTMResponse</a><ul class='methods'><li data-type='method'><a href="RTMResponse.html#has">has</a></li><li data-type='method'><a href="RTMResponse.html#toString">toString</a></li></ul></li><li><a href="RTMSuccess.html">RTMSuccess</a><ul class='methods'><li data-type='method'><a href="RTMSuccess.html#toString">toString</a></li></ul></li><li><a href="RTMTask.html">RTMTask</a></li><li><a href="RTMUser.html">RTMUser</a><ul class='methods'><li data-type='method'><a href="RTMUser.html#clearTaskIndexCache">clearTaskIndexCache</a></li><li data-type='method'><a href="RTMUser.html#get">get</a></li><li data-type='method'><a href="RTMUser.html#verifyAuthToken">verifyAuthToken</a></li><li data-type='method'><a href="RTMUser.html#~lists/add">lists/add</a></li><li data-type='method'><a href="RTMUser.html#~lists/archive">lists/archive</a></li><li data-type='method'><a href="RTMUser.html#~lists/get">lists/get</a></li><li data-type='method'><a href="RTMUser.html#~lists/remove">lists/remove</a></li><li data-type='method'><a href="RTMUser.html#~lists/rename">lists/rename</a></li><li data-type='method'><a href="RTMUser.html#~tasks/add">tasks/add</a></li><li data-type='method'><a href="RTMUser.html#~tasks/addNotes">tasks/addNotes</a></li><li data-type='method'><a href="RTMUser.html#~tasks/addTags">tasks/addTags</a></li><li data-type='method'><a href="RTMUser.html#~tasks/complete">tasks/complete</a></li><li data-type='method'><a href="RTMUser.html#~tasks/decreasePriority">tasks/decreasePriority</a></li><li data-type='method'><a href="RTMUser.html#~tasks/get">tasks/get</a></li><li data-type='method'><a href="RTMUser.html#~tasks/getTask">tasks/getTask</a></li><li data-type='method'><a href="RTMUser.html#~tasks/increasePriority">tasks/increasePriority</a></li><li data-type='method'><a href="RTMUser.html#~tasks/move">tasks/move</a></li><li data-type='method'><a href="RTMUser.html#~tasks/postpone">tasks/postpone</a></li><li data-type='method'><a href="RTMUser.html#~tasks/priority">tasks/priority</a></li><li data-type='method'><a href="RTMUser.html#~tasks/remove">tasks/remove</a></li><li data-type='method'><a href="RTMUser.html#~tasks/removeTags">tasks/removeTags</a></li><li data-type='method'><a href="RTMUser.html#~tasks/setDueDate">tasks/setDueDate</a></li><li data-type='method'><a href="RTMUser.html#~tasks/setName">tasks/setName</a></li><li data-type='method'><a href="RTMUser.html#~tasks/setURL">tasks/setURL</a></li><li data-type='method'><a href="RTMUser.html#~tasks/uncomplete">tasks/uncomplete</a></li></ul></li></ul><h3>Global</h3><ul><li><a href="global.html#setStartDate">setStartDate</a></li></ul>
|
|
27
|
+
</nav>
|
|
28
|
+
|
|
29
|
+
<div id="main">
|
|
30
|
+
|
|
31
|
+
<h1 class="page-title">user/tasks.js</h1>
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
<section>
|
|
40
|
+
<article>
|
|
41
|
+
<pre class="prettyprint source linenums"><code>'use strict';
|
|
42
|
+
|
|
43
|
+
const _tasks = require('../task/helper.js');
|
|
44
|
+
const _lists = require('../list/helper.js');
|
|
45
|
+
const taskIds = require('../utils/taskIds.js');
|
|
46
|
+
const errors = require('../response/error.js');
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* This module returns the RTM Tasks-related functions for the RTMUser
|
|
50
|
+
* @param {RTMUser} user The RTM User instance
|
|
51
|
+
* @returns {{get: function, add:function, remove: function, complete: function, uncomplete: function, addTags: function, removeTags: function, priority: function, decreasePriority: function, increasePriority: function, move: function, setDueDate: function, postpone: function, setName: function}}
|
|
52
|
+
* @private
|
|
53
|
+
*/
|
|
54
|
+
module.exports = function(user) {
|
|
55
|
+
let rtn = {};
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Get the list of RTM Tasks for this User.
|
|
59
|
+
* @param {string} [filter] Tasks Filter (RTM Advanced Search Syntax)
|
|
60
|
+
* @param {function} callback Callback function(err, tasks)
|
|
61
|
+
* @param {RTMError} callback.err RTM API Error Response, if encountered
|
|
62
|
+
* @param {RTMTask[]} callback.tasks List of User's RTM Tasks
|
|
63
|
+
* @function RTMUser~tasks/get
|
|
64
|
+
*/
|
|
65
|
+
rtn.get = function(filter, callback) {
|
|
66
|
+
if ( callback === undefined && typeof filter === 'function' ) {
|
|
67
|
+
callback = filter;
|
|
68
|
+
filter = "";
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// Callback counters
|
|
72
|
+
let count = 0;
|
|
73
|
+
let calls = 2;
|
|
74
|
+
let returned = false;
|
|
75
|
+
|
|
76
|
+
// Lists and Tasks
|
|
77
|
+
let LISTS = {};
|
|
78
|
+
let TASKS = [];
|
|
79
|
+
|
|
80
|
+
// Update the User's Lists and Tasks
|
|
81
|
+
_lists.get(user, function(err, lists) {
|
|
82
|
+
if ( lists ) {
|
|
83
|
+
for ( let i = 0; i < lists.length; i++ ) {
|
|
84
|
+
LISTS[lists[i].id] = lists[i];
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
_tasksUpdateCallback(err);
|
|
88
|
+
});
|
|
89
|
+
_tasks.get(user, filter, function(err, tasks) {
|
|
90
|
+
TASKS = tasks;
|
|
91
|
+
_tasksUpdateCallback(err);
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
// Callback for each of list and task updates
|
|
95
|
+
function _tasksUpdateCallback(err) {
|
|
96
|
+
count++;
|
|
97
|
+
if ( !returned ) {
|
|
98
|
+
if ( err ) {
|
|
99
|
+
returned = true;
|
|
100
|
+
return callback(err);
|
|
101
|
+
}
|
|
102
|
+
else if ( count === calls ) {
|
|
103
|
+
returned = true;
|
|
104
|
+
_parseTasks();
|
|
105
|
+
return callback(null, TASKS);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// Add the List to each Task
|
|
111
|
+
function _parseTasks() {
|
|
112
|
+
for ( let i = 0; i < TASKS.length; i++ ) {
|
|
113
|
+
let list = LISTS[TASKS[i].list_id];
|
|
114
|
+
if ( list === undefined ) {
|
|
115
|
+
list = {
|
|
116
|
+
id: TASKS[i].list_id,
|
|
117
|
+
name: "List #" + TASKS[i].list_id
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
TASKS[i]._list = list;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Get the RTMTask specified by its index
|
|
127
|
+
* @param {int} index Task Index
|
|
128
|
+
* @param {function} callback Callback function(err, task)
|
|
129
|
+
* @param {RTMError} callback.err RTM API Error Response, if encountered
|
|
130
|
+
* @param {RTMTask} callback.task Matching RTM Task
|
|
131
|
+
* @function RTMUser~tasks/getTask
|
|
132
|
+
*/
|
|
133
|
+
rtn.getTask = function(index, callback) {
|
|
134
|
+
|
|
135
|
+
// Get Task Info
|
|
136
|
+
_getTaskInfo(index, function(err, listId, taskSeriesId, taskId) {
|
|
137
|
+
if ( err ) {
|
|
138
|
+
return callback(err);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// Get Task From API
|
|
142
|
+
user.tasks.get(function(err, tasks) {
|
|
143
|
+
if ( err ) {
|
|
144
|
+
return callback(err);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// Find Matching Task
|
|
148
|
+
let found = false;
|
|
149
|
+
for ( let i = 0; i < tasks.length; i++ ) {
|
|
150
|
+
if ( !found && tasks[i].task_id === taskId ) {
|
|
151
|
+
found = true;
|
|
152
|
+
return callback(null, tasks[i]);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// Task Not Found
|
|
157
|
+
if ( !found ) {
|
|
158
|
+
return callback(errors.referenceError());
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Add a new RTM Task for this User
|
|
169
|
+
* @param {string} name Task Name (can include 'Smart Add' syntax)
|
|
170
|
+
* @param {object} [props] Task Properties
|
|
171
|
+
* @param {string} props.due Task Due Date (RTM supported date format)
|
|
172
|
+
* @param {int} props.priority Task Priority (1, 2, 3)
|
|
173
|
+
* @param {string} props.list Task List Name
|
|
174
|
+
* @param {string[]} props.tags Task Tags
|
|
175
|
+
* @param {string} props.location Task Location Name
|
|
176
|
+
* @param {string} props.start Task Start Date (RTM supported date format)
|
|
177
|
+
* @param {string} props.repeat Task Repeat Format (RTM supported repeat format)
|
|
178
|
+
* @param {string} props.estimate Task Time Estimate (RTM supported time estimate format)
|
|
179
|
+
* @param {string} props.to Contact Name to give Task to (existing contact or email address)
|
|
180
|
+
* @param {string} props.url Task Reference URL
|
|
181
|
+
* @param {string} props.note Task Note
|
|
182
|
+
* @param {function} callback Callback function(err)
|
|
183
|
+
* @param {RTMError} callback.err RTM API Error Response, if encountered
|
|
184
|
+
* @function RTMUser~tasks/add
|
|
185
|
+
*/
|
|
186
|
+
rtn.add = function(name, props, callback) {
|
|
187
|
+
if ( callback === undefined && typeof props === 'function' ) {
|
|
188
|
+
callback = props;
|
|
189
|
+
props = {};
|
|
190
|
+
}
|
|
191
|
+
return _tasks.add(name, props, user, callback);
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Mark the specified Task as complete
|
|
196
|
+
* @param {int} index Task Index
|
|
197
|
+
* @param {function} callback Callback function(err)
|
|
198
|
+
* @param {RTMError} callback.err RTM API Error Response, if encountered
|
|
199
|
+
* @function RTMUser~tasks/complete
|
|
200
|
+
*/
|
|
201
|
+
rtn.complete = function(index, callback) {
|
|
202
|
+
|
|
203
|
+
// Get the Task
|
|
204
|
+
_getTaskInfo(index, function(err, listId, taskSeriesId, taskId) {
|
|
205
|
+
if ( err ) {
|
|
206
|
+
return callback(err);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
// Complete the Task
|
|
210
|
+
return _tasks.complete(
|
|
211
|
+
listId,
|
|
212
|
+
taskSeriesId,
|
|
213
|
+
taskId,
|
|
214
|
+
user,
|
|
215
|
+
callback
|
|
216
|
+
);
|
|
217
|
+
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Mark the specified Task as NOT complete
|
|
224
|
+
* @param {int} index Task Index
|
|
225
|
+
* @param {function} callback Callback function(err)
|
|
226
|
+
* @param {RTMError} callback.err RTM API Error Response, if encountered
|
|
227
|
+
* @function RTMUser~tasks/uncomplete
|
|
228
|
+
*/
|
|
229
|
+
rtn.uncomplete = function(index, callback) {
|
|
230
|
+
|
|
231
|
+
// Get the Task
|
|
232
|
+
_getTaskInfo(index, function(err, listId, taskSeriesId, taskId) {
|
|
233
|
+
if ( err ) {
|
|
234
|
+
return callback(err);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
// Complete the Task
|
|
238
|
+
return _tasks.uncomplete(
|
|
239
|
+
listId,
|
|
240
|
+
taskSeriesId,
|
|
241
|
+
taskId,
|
|
242
|
+
user,
|
|
243
|
+
callback
|
|
244
|
+
);
|
|
245
|
+
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
};
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* Set the priority of the specified Task
|
|
252
|
+
* @param {int} index Task Index
|
|
253
|
+
* @param {int} priority Task Priority
|
|
254
|
+
* @param {function} callback Callback function(err)
|
|
255
|
+
* @param {RTMError} callback.err RTM API Error Response, if encountered
|
|
256
|
+
* @function RTMUser~tasks/priority
|
|
257
|
+
*/
|
|
258
|
+
rtn.priority = function(index, priority, callback) {
|
|
259
|
+
|
|
260
|
+
// Get the Task
|
|
261
|
+
_getTaskInfo(index, function(err, listId, taskSeriesId, taskId) {
|
|
262
|
+
if ( err ) {
|
|
263
|
+
return callback(err);
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
// Set the Priority
|
|
267
|
+
return _tasks.priority(
|
|
268
|
+
listId,
|
|
269
|
+
taskSeriesId,
|
|
270
|
+
taskId,
|
|
271
|
+
priority,
|
|
272
|
+
user,
|
|
273
|
+
callback
|
|
274
|
+
);
|
|
275
|
+
|
|
276
|
+
});
|
|
277
|
+
|
|
278
|
+
};
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* Add the specified tag(s) to the Task
|
|
282
|
+
* @param {int} index Task Index
|
|
283
|
+
* @param {string|string[]} tags Tag(s) to add to task
|
|
284
|
+
* @param {function} callback Callback function(err)
|
|
285
|
+
* @param {RTMError} callback.err RTM API Error Response, if encountered
|
|
286
|
+
* @function RTMUser~tasks/addTags
|
|
287
|
+
*/
|
|
288
|
+
rtn.addTags = function(index, tags, callback) {
|
|
289
|
+
|
|
290
|
+
// Make sure tags is an array
|
|
291
|
+
if ( !Array.isArray(tags) ) {
|
|
292
|
+
tags = [tags];
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
// Get the Task
|
|
296
|
+
_getTaskInfo(index, function(err, listId, taskSeriesId, taskId) {
|
|
297
|
+
if ( err ) {
|
|
298
|
+
return callback(err);
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
// Add the Tags
|
|
302
|
+
return _tasks.addTags(
|
|
303
|
+
listId,
|
|
304
|
+
taskSeriesId,
|
|
305
|
+
taskId,
|
|
306
|
+
tags,
|
|
307
|
+
user,
|
|
308
|
+
callback
|
|
309
|
+
);
|
|
310
|
+
|
|
311
|
+
});
|
|
312
|
+
|
|
313
|
+
};
|
|
314
|
+
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* Add the specified note to the Task
|
|
318
|
+
* @param {int} index Task Index
|
|
319
|
+
* @param {string} title Title of the Note
|
|
320
|
+
* @param {string|string[]} notes Note(s) to add to task
|
|
321
|
+
* @param {function} callback Callback function(err)
|
|
322
|
+
* @param {RTMError} callback.err RTM API Error Response, if encountered
|
|
323
|
+
* @function RTMUser~tasks/addNotes
|
|
324
|
+
*/
|
|
325
|
+
rtn.addNotes = function(index, title, notes, callback) {
|
|
326
|
+
var title = (typeof title !== 'undefined') ? title : "";
|
|
327
|
+
|
|
328
|
+
// Get the Task
|
|
329
|
+
_getTaskInfo(index, function(err, listId, taskSeriesId, taskId) {
|
|
330
|
+
if ( err ) {
|
|
331
|
+
return callback(err);
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
// Add the Note
|
|
335
|
+
return _tasks.addNotes(
|
|
336
|
+
listId,
|
|
337
|
+
taskSeriesId,
|
|
338
|
+
taskId,
|
|
339
|
+
title,
|
|
340
|
+
notes,
|
|
341
|
+
user,
|
|
342
|
+
callback
|
|
343
|
+
);
|
|
344
|
+
|
|
345
|
+
});
|
|
346
|
+
|
|
347
|
+
};
|
|
348
|
+
|
|
349
|
+
/**
|
|
350
|
+
* Remove the specified Task from the User's Account
|
|
351
|
+
* @param {int} index Task Index
|
|
352
|
+
* @param {function} callback Callback function(err)
|
|
353
|
+
* @param {RTMError} callback.err RTM API Error Response, if encountered
|
|
354
|
+
* @function RTMUser~tasks/remove
|
|
355
|
+
*/
|
|
356
|
+
rtn.remove = function(index, callback) {
|
|
357
|
+
|
|
358
|
+
// Get the Task
|
|
359
|
+
_getTaskInfo(index, function(err, listId, taskSeriesId, taskId) {
|
|
360
|
+
if ( err ) {
|
|
361
|
+
return callback(err);
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
// Remove the Task
|
|
365
|
+
return _tasks.remove(
|
|
366
|
+
listId,
|
|
367
|
+
taskSeriesId,
|
|
368
|
+
taskId,
|
|
369
|
+
user,
|
|
370
|
+
callback
|
|
371
|
+
);
|
|
372
|
+
|
|
373
|
+
});
|
|
374
|
+
|
|
375
|
+
};
|
|
376
|
+
|
|
377
|
+
/**
|
|
378
|
+
* Increase the Priority of the specified Task
|
|
379
|
+
* @param {int} index Task Index
|
|
380
|
+
* @param {function} callback Callback function(err)
|
|
381
|
+
* @param {RTMError} callback.err RTM API Error Response, if encountered
|
|
382
|
+
* @function RTMUser~tasks/increasePriority
|
|
383
|
+
*/
|
|
384
|
+
rtn.increasePriority = function(index, callback) {
|
|
385
|
+
|
|
386
|
+
// Get the Task
|
|
387
|
+
_getTaskInfo(index, function(err, listId, taskSeriesId, taskId) {
|
|
388
|
+
if ( err ) {
|
|
389
|
+
return callback(err);
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
// Increase the Priority of the Task
|
|
393
|
+
return _tasks.movePriority(
|
|
394
|
+
listId,
|
|
395
|
+
taskSeriesId,
|
|
396
|
+
taskId,
|
|
397
|
+
'up',
|
|
398
|
+
user,
|
|
399
|
+
callback
|
|
400
|
+
);
|
|
401
|
+
|
|
402
|
+
});
|
|
403
|
+
|
|
404
|
+
};
|
|
405
|
+
|
|
406
|
+
/**
|
|
407
|
+
* Decrease the Priority of the specified Task
|
|
408
|
+
* @param {int} index Task Index
|
|
409
|
+
* @param {function} callback Callback function(err)
|
|
410
|
+
* @param {RTMError} callback.err RTM API Error Response, if encountered
|
|
411
|
+
* @function RTMUser~tasks/decreasePriority
|
|
412
|
+
*/
|
|
413
|
+
rtn.decreasePriority = function(index, callback) {
|
|
414
|
+
|
|
415
|
+
// Get the Task
|
|
416
|
+
_getTaskInfo(index, function(err, listId, taskSeriesId, taskId) {
|
|
417
|
+
if ( err ) {
|
|
418
|
+
return callback(err);
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
// Decrease the Priority of the Task
|
|
422
|
+
return _tasks.movePriority(
|
|
423
|
+
listId,
|
|
424
|
+
taskSeriesId,
|
|
425
|
+
taskId,
|
|
426
|
+
'down',
|
|
427
|
+
user,
|
|
428
|
+
callback
|
|
429
|
+
);
|
|
430
|
+
|
|
431
|
+
});
|
|
432
|
+
|
|
433
|
+
};
|
|
434
|
+
|
|
435
|
+
/**
|
|
436
|
+
* Move the specified Task to a different List
|
|
437
|
+
* @param {int} index Task Index
|
|
438
|
+
* @param {string} listName List Name to move Task to
|
|
439
|
+
* @param {function} callback Callback function(err)
|
|
440
|
+
* @param {RTMError} callback.err RTM API Error Response, if encountered
|
|
441
|
+
* @function RTMUser~tasks/move
|
|
442
|
+
*/
|
|
443
|
+
rtn.move = function(index, listName, callback) {
|
|
444
|
+
|
|
445
|
+
// Get the Task
|
|
446
|
+
_getTaskInfo(index, function(err, listId, taskSeriesId, taskId) {
|
|
447
|
+
if ( err ) {
|
|
448
|
+
return callback(err);
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
// Get the List
|
|
452
|
+
user.lists.get(function(err, lists) {
|
|
453
|
+
if ( err ) {
|
|
454
|
+
return callback(err);
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
// Find the List
|
|
458
|
+
let id = [];
|
|
459
|
+
for ( let i = 0; i < lists.length; i++ ) {
|
|
460
|
+
if ( lists[i].name.toLowerCase() === listName.toLowerCase() ) {
|
|
461
|
+
id.push(lists[i].id);
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
// No List Match
|
|
466
|
+
if ( id.length !== 1 ) {
|
|
467
|
+
return callback(errors.referenceError());
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
// Move the Task
|
|
471
|
+
else {
|
|
472
|
+
return _tasks.move(
|
|
473
|
+
listId,
|
|
474
|
+
taskSeriesId,
|
|
475
|
+
taskId,
|
|
476
|
+
id[0],
|
|
477
|
+
user,
|
|
478
|
+
callback
|
|
479
|
+
);
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
});
|
|
483
|
+
|
|
484
|
+
});
|
|
485
|
+
|
|
486
|
+
};
|
|
487
|
+
|
|
488
|
+
/**
|
|
489
|
+
* Postpone the due date of the Task by 1 day
|
|
490
|
+
* @param {int} index Task Index
|
|
491
|
+
* @param {function} callback Callback function(err)
|
|
492
|
+
* @param {RTMError} callback.err RTM API Error Response, if encountered
|
|
493
|
+
* @function RTMUser~tasks/postpone
|
|
494
|
+
*/
|
|
495
|
+
rtn.postpone = function(index, callback) {
|
|
496
|
+
|
|
497
|
+
// Get the Task
|
|
498
|
+
_getTaskInfo(index, function(err, listId, taskSeriesId, taskId) {
|
|
499
|
+
if ( err ) {
|
|
500
|
+
return callback(err);
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
// Postpone the Task
|
|
504
|
+
return _tasks.postpone(
|
|
505
|
+
listId,
|
|
506
|
+
taskSeriesId,
|
|
507
|
+
taskId,
|
|
508
|
+
user,
|
|
509
|
+
callback
|
|
510
|
+
);
|
|
511
|
+
|
|
512
|
+
});
|
|
513
|
+
|
|
514
|
+
};
|
|
515
|
+
|
|
516
|
+
/**
|
|
517
|
+
* Remove the specified tag(s) from the Task
|
|
518
|
+
* @param {int} index Task Index
|
|
519
|
+
* @param {string|string[]} tags Tags to remove from the Task
|
|
520
|
+
* @param {function} callback Callback function(err)
|
|
521
|
+
* @param {RTMError} callback.err RTM API Error Response, if encountered
|
|
522
|
+
* @function RTMUser~tasks/removeTags
|
|
523
|
+
*/
|
|
524
|
+
rtn.removeTags = function(index, tags, callback) {
|
|
525
|
+
|
|
526
|
+
// Make sure tags is an array
|
|
527
|
+
if ( !Array.isArray(tags) ) {
|
|
528
|
+
tags = [tags];
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
// Get the Task
|
|
532
|
+
_getTaskInfo(index, function(err, listId, taskSeriesId, taskId) {
|
|
533
|
+
if ( err ) {
|
|
534
|
+
return callback(err);
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
// Remove the Tags
|
|
538
|
+
return _tasks.removeTags(
|
|
539
|
+
listId,
|
|
540
|
+
taskSeriesId,
|
|
541
|
+
taskId,
|
|
542
|
+
tags,
|
|
543
|
+
user,
|
|
544
|
+
callback
|
|
545
|
+
);
|
|
546
|
+
|
|
547
|
+
});
|
|
548
|
+
|
|
549
|
+
};
|
|
550
|
+
|
|
551
|
+
/**
|
|
552
|
+
* Set the Due Date of the specified Task
|
|
553
|
+
* @param {int} index Task Index
|
|
554
|
+
* @param {string} due The Due Date of the Task (RTM parsed date)
|
|
555
|
+
* @param {function} callback Callback function(err)
|
|
556
|
+
* @param {RTMError} callback.err RTM API Error Response, if encountered
|
|
557
|
+
* @function RTMUser~tasks/setDueDate
|
|
558
|
+
*/
|
|
559
|
+
rtn.setDueDate = function(index, due, callback) {
|
|
560
|
+
|
|
561
|
+
// Get the Task
|
|
562
|
+
_getTaskInfo(index, function(err, listId, taskSeriesId, taskId) {
|
|
563
|
+
if ( err ) {
|
|
564
|
+
return callback(err);
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
// Decrease the Priority of the Task
|
|
568
|
+
return _tasks.setDueDate(
|
|
569
|
+
listId,
|
|
570
|
+
taskSeriesId,
|
|
571
|
+
taskId,
|
|
572
|
+
due,
|
|
573
|
+
user,
|
|
574
|
+
callback
|
|
575
|
+
);
|
|
576
|
+
|
|
577
|
+
});
|
|
578
|
+
|
|
579
|
+
};
|
|
580
|
+
|
|
581
|
+
/**
|
|
582
|
+
* Set the Name of the specified Task
|
|
583
|
+
* @param {int} index Task Index
|
|
584
|
+
* @param {string} name New Task Name
|
|
585
|
+
* @param {function} callback Callback function(err)
|
|
586
|
+
* @param {RTMError} callback.err RTM API Error Response, if encountered
|
|
587
|
+
* @function RTMUser~tasks/setName
|
|
588
|
+
*/
|
|
589
|
+
rtn.setName = function(index, name, callback) {
|
|
590
|
+
|
|
591
|
+
// Get the Task
|
|
592
|
+
_getTaskInfo(index, function(err, listId, taskSeriesId, taskId) {
|
|
593
|
+
if ( err ) {
|
|
594
|
+
return callback(err);
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
// Decrease the Priority of the Task
|
|
598
|
+
return _tasks.setName(
|
|
599
|
+
listId,
|
|
600
|
+
taskSeriesId,
|
|
601
|
+
taskId,
|
|
602
|
+
name,
|
|
603
|
+
user,
|
|
604
|
+
callback
|
|
605
|
+
);
|
|
606
|
+
|
|
607
|
+
});
|
|
608
|
+
|
|
609
|
+
};
|
|
610
|
+
|
|
611
|
+
/**
|
|
612
|
+
* Set the URL of the specified Task
|
|
613
|
+
* @param {int} index Task Index
|
|
614
|
+
* @param {string} url New Task URL
|
|
615
|
+
* @param {function} callback Callback function(err)
|
|
616
|
+
* @param {RTMError} callback.err RTM API Error Response, if encountered
|
|
617
|
+
* @function RTMUser~tasks/setURL
|
|
618
|
+
*/
|
|
619
|
+
rtn.setURL = function(index, url, callback) {
|
|
620
|
+
|
|
621
|
+
// Get the Task
|
|
622
|
+
_getTaskInfo(index, function(err, listId, taskSeriesId, taskId) {
|
|
623
|
+
if ( err ) {
|
|
624
|
+
return callback(err);
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
// Decrease the Priority of the Task
|
|
628
|
+
return _tasks.setURL(
|
|
629
|
+
listId,
|
|
630
|
+
taskSeriesId,
|
|
631
|
+
taskId,
|
|
632
|
+
url,
|
|
633
|
+
user,
|
|
634
|
+
callback
|
|
635
|
+
);
|
|
636
|
+
|
|
637
|
+
});
|
|
638
|
+
|
|
639
|
+
};
|
|
640
|
+
|
|
641
|
+
|
|
642
|
+
|
|
643
|
+
/**
|
|
644
|
+
* Get the Matching Task IDs by Index
|
|
645
|
+
* @param {int} index Task Index
|
|
646
|
+
* @param callback Callback function(err, list_id, taskseries_id, task_id)
|
|
647
|
+
* @private
|
|
648
|
+
*/
|
|
649
|
+
function _getTaskInfo(index, callback) {
|
|
650
|
+
|
|
651
|
+
// Get IDs
|
|
652
|
+
let listId = taskIds.getListId(user.id, index);
|
|
653
|
+
let taskSeriesId = taskIds.getTaskSeriesId(user.id, index);
|
|
654
|
+
let taskId = taskIds.getTaskId(user.id, index);
|
|
655
|
+
|
|
656
|
+
// All IDs found...
|
|
657
|
+
if ( listId !== undefined && taskSeriesId !== undefined && taskId !== undefined ) {
|
|
658
|
+
return callback(null, listId, taskSeriesId, taskId);
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
// Get Task From API
|
|
662
|
+
user.tasks.get(function(err, tasks) {
|
|
663
|
+
if ( err ) {
|
|
664
|
+
return callback(err);
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
// Find Matching Task
|
|
668
|
+
let found = false;
|
|
669
|
+
for ( let i = 0; i < tasks.length; i++ ) {
|
|
670
|
+
if ( !found && tasks[i].task_id === taskId ) {
|
|
671
|
+
found = true;
|
|
672
|
+
return callback(null, tasks[i].list_id, tasks[i].taskseries_id, tasks[i].task_id);
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
// Task Not Found
|
|
677
|
+
if ( !found ) {
|
|
678
|
+
return callback(errors.referenceError());
|
|
679
|
+
}
|
|
680
|
+
});
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
return rtn;
|
|
684
|
+
};
|
|
685
|
+
</code></pre>
|
|
686
|
+
</article>
|
|
687
|
+
</section>
|
|
688
|
+
|
|
689
|
+
|
|
690
|
+
|
|
691
|
+
|
|
692
|
+
</div>
|
|
693
|
+
|
|
694
|
+
<br class="clear">
|
|
695
|
+
|
|
696
|
+
<footer>
|
|
697
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.11</a> on Mon Sep 05 2022 15:26:15 GMT-0400 (Eastern Daylight Time) using the <a href="https://github.com/dwaring87/docdash">@dwaring87/docdash</a> theme.
|
|
698
|
+
</footer>
|
|
699
|
+
|
|
700
|
+
<script>prettyPrint();</script>
|
|
701
|
+
<script src="scripts/linenumber.js"></script>
|
|
702
|
+
</body>
|
|
703
|
+
</html>
|