@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.
Files changed (52) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +285 -0
  3. package/config.js +22 -0
  4. package/docs/RTMClient.html +2798 -0
  5. package/docs/RTMError.html +1029 -0
  6. package/docs/RTMList.html +966 -0
  7. package/docs/RTMResponse.html +868 -0
  8. package/docs/RTMSuccess.html +337 -0
  9. package/docs/RTMTask.html +2461 -0
  10. package/docs/RTMUser.html +6761 -0
  11. package/docs/client_auth.js.html +123 -0
  12. package/docs/client_index.js.html +241 -0
  13. package/docs/client_user.js.html +170 -0
  14. package/docs/global.html +386 -0
  15. package/docs/index.html +305 -0
  16. package/docs/list_index.js.html +159 -0
  17. package/docs/response_error.js.html +172 -0
  18. package/docs/response_response.js.html +160 -0
  19. package/docs/response_success.js.html +104 -0
  20. package/docs/scripts/linenumber.js +25 -0
  21. package/docs/scripts/prettify/Apache-License-2.0.txt +202 -0
  22. package/docs/scripts/prettify/lang-css.js +2 -0
  23. package/docs/scripts/prettify/prettify.js +28 -0
  24. package/docs/styles/jsdoc.css +664 -0
  25. package/docs/styles/prettify.css +79 -0
  26. package/docs/task_helper.js.html +531 -0
  27. package/docs/task_index.js.html +304 -0
  28. package/docs/user_index.js.html +347 -0
  29. package/docs/user_lists.js.html +208 -0
  30. package/docs/user_tasks.js.html +703 -0
  31. package/jsdoc.json +13 -0
  32. package/package.json +33 -0
  33. package/src/client/auth.js +65 -0
  34. package/src/client/index.js +182 -0
  35. package/src/client/user.js +112 -0
  36. package/src/list/helper.js +131 -0
  37. package/src/list/index.js +101 -0
  38. package/src/response/error.js +114 -0
  39. package/src/response/index.js +8 -0
  40. package/src/response/parse.js +51 -0
  41. package/src/response/response.js +102 -0
  42. package/src/response/success.js +46 -0
  43. package/src/task/helper.js +469 -0
  44. package/src/task/index.js +264 -0
  45. package/src/user/index.js +288 -0
  46. package/src/user/lists.js +150 -0
  47. package/src/user/tasks.js +708 -0
  48. package/src/utils/auth.js +188 -0
  49. package/src/utils/fetch.js +67 -0
  50. package/src/utils/get.js +247 -0
  51. package/src/utils/sign.js +93 -0
  52. package/src/utils/taskIds.js +188 -0
@@ -0,0 +1,304 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <title>task/index.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">task/index.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 taskIds = require('../utils/taskIds.js');
44
+
45
+
46
+ /**
47
+ * ### RTM List
48
+ *
49
+ * This Class is used to represent the combined properties of an RTM TaskSeries
50
+ * combined with an RTM Task. If an RTM TaskSeries has more than one task
51
+ * property then there will be multiple `RTMTask` instances representing the
52
+ * data (which will duplicate the TaskSeries properties).
53
+ *
54
+ * Each instance of an `RTMTask` contains a `list_id`, `taskseries_id` and
55
+ * `task_id` property.
56
+ *
57
+ * All of the taskseries and task properties from the RTM API are directly
58
+ * accessible as `RTMTask` properties.
59
+ *
60
+ * ```
61
+ * let task = new RTMTask(..., ..., ...);
62
+ * let name = task.name;
63
+ * let priority = task.priority;
64
+ * ```
65
+ * @class
66
+ */
67
+ class RTMTask {
68
+
69
+ /**
70
+ * Create a new RTM Task
71
+ * @param {number} userId RTM User ID
72
+ * @param {number} listId RTM List ID
73
+ * @param {object} series Taskseries properties (resp.task.list[].taskseries[])
74
+ * @param {object} task Task properties (resp.task.list[].taskseries[].task)
75
+ */
76
+ constructor(userId, listId, series, task) {
77
+
78
+ // List added after construction
79
+ this._list = undefined;
80
+
81
+ /**
82
+ * List ID
83
+ * @type {Number}
84
+ */
85
+ this.list_id = parseFloat(listId);
86
+
87
+ /**
88
+ * TaskSeries ID
89
+ * @type {Number}
90
+ */
91
+ this.taskseries_id = parseFloat(series.id);
92
+
93
+ /**
94
+ * Task Creation Date
95
+ * @type {Date|undefined}
96
+ */
97
+ this.created = series.created.toString() === '' ? undefined : new Date(series.created);
98
+
99
+ /**
100
+ * Task Modification Date
101
+ * @type {Date|undefined}
102
+ */
103
+ this.modified = series.modified.toString() === '' ? undefined : new Date(series.modified);
104
+
105
+ /**
106
+ * Task Name
107
+ * @type {string}
108
+ */
109
+ this.name = series.name;
110
+
111
+ /**
112
+ * Task Creation Source
113
+ * @type {string}
114
+ */
115
+ this.source = series.source;
116
+
117
+ /**
118
+ * Task Reference URL
119
+ * @type {string|undefined}
120
+ */
121
+ this.url = series.url === '' ? undefined : series.url;
122
+
123
+ /**
124
+ * Task Location ID
125
+ * @type {number|undefined}
126
+ */
127
+ this.location_id = series.location_id.toString() === '' ? undefined : parseFloat(series.location_id);
128
+
129
+ /**
130
+ * Task Tags
131
+ * @type {string[]}
132
+ */
133
+ this.tags = series.tags.tag !== undefined ? series.tags.tag : [];
134
+ if ( !Array.isArray(this.tags) ) {
135
+ this.tags = [this.tags];
136
+ }
137
+
138
+ /**
139
+ * Task Participants
140
+ * @type {Array}
141
+ */
142
+ this.participants = series.participants;
143
+
144
+
145
+ /**
146
+ * Task Note
147
+ * @typedef {Object} RTMTask~Note
148
+ * @property {number} id Note ID
149
+ * @property {Date} created Note Creation Date
150
+ * @property {Date} modified Note Modified Date
151
+ * @property {string} title Note Title
152
+ * @property {string} body Note Body
153
+ */
154
+
155
+ /**
156
+ * Task Notes
157
+ * @type {RTMTask~Note[]}
158
+ */
159
+ this.notes = series.notes.note !== undefined ? series.notes.note : [];
160
+ if ( !Array.isArray(this.notes) ) {
161
+ this.notes = [this.notes];
162
+ }
163
+ for ( let i = 0; i &lt; this.notes.length; i++ ) {
164
+ this.notes[i].id = parseFloat(this.notes[i].id);
165
+ this.notes[i].created = new Date(this.notes[i].created);
166
+ this.notes[i].modified = new Date(this.notes[i].modified);
167
+ this.notes[i].title = this.notes[i].title === '' ? undefined : this.notes[i].title;
168
+ this.notes[i].body = this.notes[i]['$t'];
169
+ delete this.notes[i]['$t'];
170
+ }
171
+
172
+ /**
173
+ * Task ID
174
+ * @type {Number}
175
+ */
176
+ this.task_id = parseFloat(task.id);
177
+
178
+ /**
179
+ * Task Due Date
180
+ * @type {Date|undefined}
181
+ */
182
+ this.due = task.due.toString() === '' ? undefined : new Date(task.due);
183
+
184
+ /**
185
+ * Task Due Time Flag (true when `due` includes a Due Time)
186
+ * @type {boolean}
187
+ */
188
+ this.has_due_time = task.has_due_time.toString() === '1';
189
+
190
+ /**
191
+ * Task Start Date
192
+ * @type {Date|undefined}
193
+ */
194
+ this.start = task.start.toString() === '' ? undefined : new Date(task.start);
195
+
196
+ /**
197
+ * Task Start Time Flag (true when `start` includes a Start Time)
198
+ * @type {boolean}
199
+ */
200
+ this.has_start_time = task.has_start_time.toString() === '1';
201
+
202
+ /**
203
+ * Task Added Date
204
+ * @type {Date|undefined}
205
+ */
206
+ this.added = task.added.toString() === '' ? undefined : new Date(task.added);
207
+
208
+ /**
209
+ * Task Completed Date
210
+ * @type {Date|undefined}
211
+ */
212
+ this.completed = task.completed.toString() === '' ? undefined : new Date(task.completed);
213
+
214
+ /**
215
+ * Task Completed Flag (true when task is marked as completed)
216
+ * @type {boolean}
217
+ */
218
+ this.isCompleted = this.completed !== undefined;
219
+
220
+ /**
221
+ * Task Deleted Flag
222
+ * @type {Date|undefined}
223
+ */
224
+ this.deleted = task.deleted.toString() === '' ? undefined : new Date(task.deleted);
225
+
226
+ /**
227
+ * Task Priority (0, 1, 2, or 3)
228
+ * @type {int}
229
+ */
230
+ this.priority = task.priority.toString() === 'N' ? 0 : parseInt(task.priority);
231
+
232
+ /**
233
+ * Task Postponed Flag
234
+ * @type {boolean}
235
+ */
236
+ this.postponed = task.postponed.toString() === '1';
237
+
238
+ /**
239
+ * Task Time Estimate
240
+ * @type {string|undefined}
241
+ */
242
+ this.estimate = task.estimate.toString() === '' ? undefined : task.estimate;
243
+
244
+
245
+ // Assign Task Index
246
+ this._index = taskIds.getIndex(userId, this);
247
+
248
+ }
249
+
250
+
251
+ /**
252
+ * An index added to each RTMTask based on the `task_id`
253
+ * @type {int}
254
+ */
255
+ get index() {
256
+ return this._index;
257
+ }
258
+
259
+ /**
260
+ * The `RTMList` this Task is in
261
+ * @type {RTMList}
262
+ */
263
+ get list() {
264
+ if ( this._list === undefined ) {
265
+ throw "Tasks not loaded with associated Lists"
266
+ }
267
+ return this._list;
268
+ }
269
+
270
+ /**
271
+ * All of the RTM TaskSeries properties
272
+ * @type {object}
273
+ */
274
+ get props() {
275
+ let rtn = {};
276
+ for ( let key in this ) {
277
+ if ( this.hasOwnProperty(key) &amp;&amp; key !== '_index' ) {
278
+ rtn[key] = this[key];
279
+ }
280
+ }
281
+ return rtn;
282
+ }
283
+
284
+ }
285
+
286
+ module.exports = RTMTask;</code></pre>
287
+ </article>
288
+ </section>
289
+
290
+
291
+
292
+
293
+ </div>
294
+
295
+ <br class="clear">
296
+
297
+ <footer>
298
+ 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.
299
+ </footer>
300
+
301
+ <script>prettyPrint();</script>
302
+ <script src="scripts/linenumber.js"></script>
303
+ </body>
304
+ </html>
@@ -0,0 +1,347 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <title>user/index.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/index.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 config = require('../../rtm.json');
44
+
45
+ /**
46
+ * ### RTM User
47
+ *
48
+ * This Class is used to represent an authorized RTM User. An `RTMUser` instance
49
+ * contains the user's ID, username and fullname as well as an auth token that can
50
+ * be used to make user-authenticated API requests.
51
+ *
52
+ * #### Usage
53
+ *
54
+ * An `RTMUser` instance can created manually with an {@link RTMClient}:
55
+ *
56
+ * ```
57
+ * let user = client.user.create(1234, 'username', 'full name', 'auth_token');
58
+ * ```
59
+ *
60
+ * or can be returned through the RTM API auth process (specifically the callback
61
+ * function from {@link RTMClient~auth/getAuthToken|RTMClient.auth.getAuthToken()}).
62
+ *
63
+ * ```
64
+ * // Get an Auth URL
65
+ * client.auth.getAuthUrl(function(err, authUrl, frob) {
66
+ *
67
+ * // Have the User open this URL in their browser
68
+ * console.log(authUrl);
69
+ *
70
+ * // Get an authenticated RTMUser
71
+ * client.auth.getAuthToken(frob, function(err, user) {
72
+ *
73
+ * // user is an instance of RTMUser
74
+ *
75
+ * });
76
+ *
77
+ * });
78
+ * ```
79
+ *
80
+ * #### API Wrappers
81
+ *
82
+ * The `RTMUser` also includes a number of wrapper functions for commonly
83
+ * used RTM API methods dealing with Lists and Tasks.
84
+ *
85
+ * **Tasks:**
86
+ *
87
+ * For example, to get the User's RTM Tasks:
88
+ *
89
+ * ```
90
+ * user.tasks.get(function(err, tasks) {
91
+ * console.log(tasks);
92
+ * });
93
+ * ```
94
+ *
95
+ * The `tasks.get()` function will also fetch the User's RTM Lists and add
96
+ * the List (as an `RTMList` instance) that contains the Task to the `list`
97
+ * property of the `RTMTask`.
98
+ *
99
+ * @class
100
+ */
101
+ class RTMUser {
102
+
103
+ /**
104
+ * Create a new RTM User.
105
+ *
106
+ * An `RTMUser` can be used to make user-authenticated RTM API calls and also
107
+ * includes wrapper methods around some common RTM API methods.
108
+ * @param {number} id The RTM User's ID
109
+ * @param {string} username The RTM User's username
110
+ * @param {string} fullname The RTM User's full name
111
+ * @param {string} authToken The RTM User's Auth Token
112
+ * @constructor
113
+ */
114
+ constructor(id, username, fullname, authToken) {
115
+ this._id = parseFloat(id);
116
+ this._username = username;
117
+ this._fullname = fullname;
118
+ this._authToken = authToken;
119
+ this._client = undefined;
120
+ this._timeline = undefined;
121
+ this._burstsRemaining = config.api.rate.bursts;
122
+ this._lastBurst = undefined;
123
+ this._nextRequest = new Date().getTime();
124
+ }
125
+
126
+
127
+ // ==== RTMUser PROPERTY GETTERS &amp; SETTERS ==== //
128
+
129
+ /**
130
+ * RTM User ID
131
+ * @type {number}
132
+ */
133
+ get id() {
134
+ return this._id;
135
+ }
136
+
137
+ /**
138
+ * RTM User Username
139
+ * @type {string}
140
+ */
141
+ get username() {
142
+ return this._username;
143
+ }
144
+
145
+ /**
146
+ * RTM User fullname
147
+ * @type {string}
148
+ */
149
+ get fullname() {
150
+ return this._fullname;
151
+ }
152
+
153
+ /**
154
+ * RTM User Auth Token
155
+ * @type {string}
156
+ */
157
+ get authToken() {
158
+ return this._authToken;
159
+ }
160
+
161
+ /**
162
+ * Set the RTM User Auth Token
163
+ * @param {string} token
164
+ * @private
165
+ */
166
+ set authToken(token) {
167
+ this._authToken = token;
168
+ }
169
+
170
+ /**
171
+ * The {@link RTMClient} that authorized this User
172
+ * @type {RTMClient}
173
+ */
174
+ get client() {
175
+ if ( !this._client ) {
176
+ throw "User does not have Client specified";
177
+ }
178
+ return this._client;
179
+ }
180
+
181
+ /**
182
+ * Set the Client that authorized this User
183
+ * @param {RTMClient} client
184
+ * @private
185
+ */
186
+ set client(client) {
187
+ this._client = client;
188
+ }
189
+
190
+ /**
191
+ * The RTM Timeline for this User
192
+ * @type {number}
193
+ */
194
+ get timeline() {
195
+ if ( !this._timeline ) {
196
+ throw "User does not have a valid timeline set";
197
+ }
198
+ return this._timeline;
199
+ }
200
+
201
+ /**
202
+ * Set the RTM Timeline for this User
203
+ * @param {number} timeline
204
+ * @private
205
+ */
206
+ set timeline(timeline) {
207
+ this._timeline = parseFloat(timeline);
208
+ }
209
+
210
+
211
+ // ==== REQUEST RATE FUNCTIONS ==== //
212
+
213
+ /**
214
+ * Time (ms) to wait to make an API Request
215
+ * @returns {number}
216
+ */
217
+ get requestTimeout() {
218
+ let now = new Date().getTime();
219
+ let next = this._nextRequest;
220
+ let wait = next - now &lt; 0 ? 0 : next - now;
221
+
222
+ // Default Timeout
223
+ let timeout = config.api.rate.timeout;
224
+
225
+ // Can we start bursting again?
226
+ if ( this._lastBurst !== undefined ) {
227
+ let burstDelta = now - this._lastBurst;
228
+ if ( burstDelta > config.api.rate.burstWait ) {
229
+ this._burstsRemaining = config.api.rate.bursts;
230
+ }
231
+ }
232
+
233
+ // Do we have bursts remaining?
234
+ if ( this._burstsRemaining > 0 ) {
235
+ this._burstsRemaining--;
236
+ timeout = config.api.rate.burstTimeout;
237
+ if ( this._burstsRemaining === 0 ) {
238
+ this._lastBurst = now;
239
+ }
240
+ }
241
+
242
+ // Set Next Request Time
243
+ this._nextRequest = now + wait + timeout;
244
+
245
+ // Return wait time
246
+ return wait;
247
+ }
248
+
249
+
250
+ // ==== API HELPER FUNCTIONS ==== //
251
+
252
+ /**
253
+ * Make the specified RTM API call.
254
+ *
255
+ * The `method` should be the name of the RTM API method. Any necessary
256
+ * parameters should be provided with `params` as an object with the properties
257
+ * of the object as the parameters' key/value pairs.
258
+ *
259
+ * This function will automatically add the User's auth token to the request.
260
+ * @param {string} method RTM API Method
261
+ * @param {object} [params] RTM API Method Parameters
262
+ * @param {function} callback Callback function(err, resp)
263
+ * @param {RTMError} callback.err RTM Error Response, if encountered
264
+ * @param {RTMSuccess} callback.resp The parsed RTM API Response, if successful
265
+ */
266
+ get(method, params, callback) {
267
+ require('../utils/get.js')(method, params, this, this.client, callback);
268
+ }
269
+
270
+ /**
271
+ * Verify the Auth Token of this RTM User
272
+ * @param {function} callback Callback function(err, verified)
273
+ * @param {RTMError} callback.err RTM Error, if encountered (excluding a `Login failed / Invalid auth token` error)
274
+ * @param {boolean} callback.verified `true` if the User's auth token was successfully verified or `false` if
275
+ * a `Login failed / Invalid auth token` error was encountered
276
+ */
277
+ verifyAuthToken(callback) {
278
+ require('../utils/auth.js').verifyAuthToken(this.authToken, this.client, callback);
279
+ }
280
+
281
+ /**
282
+ * Clear the Task Index Cache for this RTM User
283
+ */
284
+ clearTaskIndexCache() {
285
+ require('../utils/taskIds.js').clear(this.id);
286
+ }
287
+
288
+
289
+ /**
290
+ * RTM List related functions:
291
+ * - {@link RTMUser~lists/get|get}
292
+ * - {@link RTMUser~lists/add|add}
293
+ * - {@link RTMUser~lists/rename|rename}
294
+ * - {@link RTMUser~lists/remove|remove}
295
+ * @returns {{get: function, add: function, remove: function, rename: function}}
296
+ */
297
+ get lists() {
298
+ return require('./lists.js')(this);
299
+ }
300
+
301
+
302
+ /**
303
+ * RTM Task related functions:
304
+ * - {@link RTMUser~tasks/get|get}
305
+ * - {@link RTMUser~tasks/add|add}
306
+ * - {@link RTMUser~tasks/remove|remove}
307
+ * - {@link RTMUser~tasks/complete|complete}
308
+ * - {@link RTMUser~tasks/uncomplete|uncomplete}
309
+ * - {@link RTMUser~tasks/addNotes|addNotes}
310
+ * - {@link RTMUser~tasks/addTags|addTags}
311
+ * - {@link RTMUser~tasks/removeTags|removeTags}
312
+ * - {@link RTMUser~tasks/priority|priority}
313
+ * - {@link RTMUser~tasks/decreasePriority|decreasePriority}
314
+ * - {@link RTMUser~tasks/increasePriority|increasePriority}
315
+ * - {@link RTMUser~tasks/move|move}
316
+ * - {@link RTMUser~tasks/setDueDate|setDueDate}
317
+ * - {@link RTMUser~tasks/postpone|postpone}
318
+ * - {@link RTMUser~tasks/setName|setName}
319
+ * @returns {{get: function, add:function, remove: function, complete: function, uncomplete: function, addNotes: function, addTags: function, removeTags: function, priority: function, decreasePriority: function, increasePriority: function, move: function, setDueDate: function, postpone: function, setName: function}}
320
+ */
321
+ get tasks() {
322
+ return require('./tasks.js')(this);
323
+ }
324
+
325
+ }
326
+
327
+
328
+ module.exports = RTMUser;
329
+ </code></pre>
330
+ </article>
331
+ </section>
332
+
333
+
334
+
335
+
336
+ </div>
337
+
338
+ <br class="clear">
339
+
340
+ <footer>
341
+ 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.
342
+ </footer>
343
+
344
+ <script>prettyPrint();</script>
345
+ <script src="scripts/linenumber.js"></script>
346
+ </body>
347
+ </html>