@beauraines/rtm-api 1.5.0 → 1.6.0

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.
@@ -23,7 +23,7 @@
23
23
  <label for="nav-trigger" class="overlay"></label>
24
24
 
25
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>
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/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#callAPI">callAPI</a></li><li><a href="global.html#formQuery">formQuery</a></li><li><a href="global.html#setStartDate">setStartDate</a></li></ul>
27
27
  </nav>
28
28
 
29
29
  <div id="main">
@@ -199,7 +199,7 @@ module.exports = function(user) {
199
199
  <br class="clear">
200
200
 
201
201
  <footer>
202
- 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.
202
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.11</a> on Sun Mar 12 2023 09:58:16 GMT-0700 (Pacific Daylight Time) using the <a href="https://github.com/dwaring87/docdash">@dwaring87/docdash</a> theme.
203
203
  </footer>
204
204
 
205
205
  <script>prettyPrint();</script>
@@ -23,7 +23,7 @@
23
23
  <label for="nav-trigger" class="overlay"></label>
24
24
 
25
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>
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/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#callAPI">callAPI</a></li><li><a href="global.html#formQuery">formQuery</a></li><li><a href="global.html#setStartDate">setStartDate</a></li></ul>
27
27
  </nav>
28
28
 
29
29
  <div id="main">
@@ -44,6 +44,9 @@ const _tasks = require('../task/helper.js');
44
44
  const _lists = require('../list/helper.js');
45
45
  const taskIds = require('../utils/taskIds.js');
46
46
  const errors = require('../response/error.js');
47
+ const { getListId, getTaskId, getTaskSeriesId } = require('../utils/taskIds');
48
+ const { callAPI, buildUrl } = require('../utils/fetch');
49
+ const RTMTask = require('../task/index.js');
47
50
 
48
51
  /**
49
52
  * This module returns the RTM Tasks-related functions for the RTMUser
@@ -65,7 +68,7 @@ module.exports = function(user) {
65
68
  rtn.get = function(filter, callback) {
66
69
  if ( callback === undefined &amp;&amp; typeof filter === 'function' ) {
67
70
  callback = filter;
68
- filter = "";
71
+ filter = '';
69
72
  }
70
73
 
71
74
  // Callback counters
@@ -114,8 +117,8 @@ module.exports = function(user) {
114
117
  if ( list === undefined ) {
115
118
  list = {
116
119
  id: TASKS[i].list_id,
117
- name: "List #" + TASKS[i].list_id
118
- }
120
+ name: 'List #' + TASKS[i].list_id
121
+ };
119
122
  }
120
123
  TASKS[i]._list = list;
121
124
  }
@@ -123,14 +126,75 @@ module.exports = function(user) {
123
126
  };
124
127
 
125
128
  /**
126
- * Get the RTMTask specified by its index
129
+ * Get the an RTM response of lists, task series and tasks in a JSON
130
+ * @param {int} index Task Index
131
+ * @param {string} [filter] Tasks Filter (RTM Advanced Search Syntax)
132
+ * @return {JSON}
133
+ */
134
+ rtn.rtmFetch = async function(filter) {
135
+ let url = buildUrl(user,filter);
136
+ let response = await callAPI(url);
137
+ return await response.rsp.tasks?.list;
138
+ };
139
+
140
+ /**
141
+ * Get the RTMTask specified by its index. Unlike getTask(), this will only create an RTMTask
142
+ * for the matching index, which is more performant.
143
+ * @param {int} index Task Index
144
+ * @param {string} [filter] Tasks Filter (RTM Advanced Search Syntax)
145
+ * @function RTMUser~tasks/getTask
146
+ * @return {RTMTask}
147
+ */
148
+ rtn.rtmIndexFetchTask = async function(index,filter) {
149
+
150
+ let url = buildUrl(user,filter);
151
+ let response = await callAPI(url,user);
152
+ const lists = response.rsp.tasks?.list;
153
+
154
+
155
+ // index to ids
156
+ let listId = getListId(user.id,index);
157
+ let taskSeriesId = getTaskSeriesId(user.id,index);
158
+ let taskId = getTaskId(user.id,index);
159
+
160
+ if (listId == undefined || taskSeriesId == undefined || taskId == undefined) {
161
+ return {err: {code: -3}}; // Not sure why this is the code
162
+ }
163
+ // filter the response for the matching index
164
+ let taskList = lists.filter(x => x.id == listId)[0].taskseries;
165
+ let taskSeries = taskList ? taskList.filter(x => x.id == taskSeriesId)[0] : null;
166
+ taskSeries
167
+ ? taskSeries.task = taskSeries.task.filter(x => x.id == taskId)[0]
168
+ : null;
169
+
170
+
171
+ let err;
172
+ let task;
173
+ if (!taskSeries ) {
174
+ err = {code: -3}; // Not sure why this is the code
175
+ } else {
176
+ task = new RTMTask(user.id,listId,taskSeries,taskSeries.task);
177
+ }
178
+ return {err,task};
179
+ };
180
+
181
+ /**
182
+ * Get the RTMTask specified by its index. While this will return only the matching RTMTask,
183
+ * this function will create RTMTasks, updating the index for every task returned. This can
184
+ * contribute to laggy performance. You may be better off using rtmIndexFetchTask()
127
185
  * @param {int} index Task Index
186
+ * @param {string} [filter] Tasks Filter (RTM Advanced Search Syntax)
128
187
  * @param {function} callback Callback function(err, task)
129
188
  * @param {RTMError} callback.err RTM API Error Response, if encountered
130
189
  * @param {RTMTask} callback.task Matching RTM Task
131
190
  * @function RTMUser~tasks/getTask
191
+ * @deprecated use rtmIndexFetchTask instead
132
192
  */
133
- rtn.getTask = function(index, callback) {
193
+ rtn.getTask = function(index, filter, callback) {
194
+ if ( callback === undefined &amp;&amp; typeof filter === 'function' ) {
195
+ callback = filter;
196
+ filter = '';
197
+ }
134
198
 
135
199
  // Get Task Info
136
200
  _getTaskInfo(index, function(err, listId, taskSeriesId, taskId) {
@@ -139,7 +203,7 @@ module.exports = function(user) {
139
203
  }
140
204
 
141
205
  // Get Task From API
142
- user.tasks.get(function(err, tasks) {
206
+ user.tasks.get(filter, function(err, tasks) {
143
207
  if ( err ) {
144
208
  return callback(err);
145
209
  }
@@ -323,7 +387,7 @@ module.exports = function(user) {
323
387
  * @function RTMUser~tasks/addNotes
324
388
  */
325
389
  rtn.addNotes = function(index, title, notes, callback) {
326
- var title = (typeof title !== 'undefined') ? title : "";
390
+ var title = (typeof title !== 'undefined') ? title : '';
327
391
 
328
392
  // Get the Task
329
393
  _getTaskInfo(index, function(err, listId, taskSeriesId, taskId) {
@@ -694,7 +758,7 @@ module.exports = function(user) {
694
758
  <br class="clear">
695
759
 
696
760
  <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.
761
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.11</a> on Sun Mar 12 2023 09:58:16 GMT-0700 (Pacific Daylight Time) using the <a href="https://github.com/dwaring87/docdash">@dwaring87/docdash</a> theme.
698
762
  </footer>
699
763
 
700
764
  <script>prettyPrint();</script>
@@ -0,0 +1,128 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <title>utils/fetch.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/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#callAPI">callAPI</a></li><li><a href="global.html#formQuery">formQuery</a></li><li><a href="global.html#setStartDate">setStartDate</a></li></ul>
27
+ </nav>
28
+
29
+ <div id="main">
30
+
31
+ <h1 class="page-title">utils/fetch.js</h1>
32
+
33
+
34
+
35
+
36
+
37
+
38
+
39
+ <section>
40
+ <article>
41
+ <pre class="prettyprint source linenums"><code>const fetch = require('node-fetch');
42
+ const sign = require('../utils/sign');
43
+ const debug = require('debug')('rtm-api-fetch');
44
+
45
+ // API Configuration Properties
46
+ const config = require('../../config');
47
+ const scheme = config.api.scheme;
48
+ const base = config.api.url.base;
49
+ const format = config.api.format;
50
+ const version = config.api.version;
51
+
52
+
53
+ function buildUrl(user,filter) {
54
+ let query = {
55
+ filter: filter ,
56
+ auth_token: user._authToken,
57
+ method: 'rtm.tasks.getList',
58
+ api_key: user._client._apiKey,
59
+ v: version,
60
+ format
61
+ };
62
+
63
+ let apiSig=sign(query,{secret:user._client._apiSecret});
64
+
65
+ let url = `${scheme}://${base}?${formQuery(query)}&amp;api_sig=${apiSig}`;
66
+ return url;
67
+ }
68
+
69
+
70
+
71
+
72
+ /**
73
+ * Generate a URI Encoded query string from the parameters set of
74
+ * key/value pairs
75
+ * @param {object} params Object containing the key/value parameters
76
+ * @returns {string} URL Encoded query string
77
+ */
78
+ function formQuery(params) {
79
+ let parts = [];
80
+ for ( let key in params ) {
81
+ if ( params.hasOwnProperty(key) ) {
82
+ parts.push(encodeURIComponent(key) + '=' + encodeURIComponent(params[key]));
83
+ }
84
+ }
85
+ return parts.join('&amp;');
86
+ }
87
+
88
+ /**
89
+ *
90
+ * @param {string} url fully formed url to call
91
+ * @returns JSON response
92
+ */
93
+ async function callAPI(url) {
94
+ try {
95
+ const response = await fetch(url);
96
+ if (await response.ok) {
97
+ const responseJson = await response.json();
98
+ debug(JSON.stringify(responseJson));
99
+ return responseJson;
100
+ } else {
101
+ // TODO improve this error message
102
+ console.error('There was an error');
103
+ }
104
+ } catch (error) {
105
+ console.error(error);
106
+ }
107
+ }
108
+
109
+ module.exports = {callAPI,formQuery, buildUrl};
110
+ </code></pre>
111
+ </article>
112
+ </section>
113
+
114
+
115
+
116
+
117
+ </div>
118
+
119
+ <br class="clear">
120
+
121
+ <footer>
122
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.11</a> on Sun Mar 12 2023 09:58:16 GMT-0700 (Pacific Daylight Time) using the <a href="https://github.com/dwaring87/docdash">@dwaring87/docdash</a> theme.
123
+ </footer>
124
+
125
+ <script>prettyPrint();</script>
126
+ <script src="scripts/linenumber.js"></script>
127
+ </body>
128
+ </html>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@beauraines/rtm-api",
3
- "version": "1.5.0",
3
+ "version": "1.6.0",
4
4
  "description": "Remember the Milk API Interface",
5
5
  "author": "David Waring <dev@davidwaring.net> (https://davidwaring.net)",
6
6
  "contributors": [
@@ -17,7 +17,7 @@
17
17
  ],
18
18
  "main": "src/client/index.js",
19
19
  "scripts": {
20
- "docs": "jsdoc -c jsdoc.json --readme README.md --template $NODE_PATH/@dwaring87/docdash",
20
+ "docs": "jsdoc -c jsdoc.json --readme README.md --template node_modules/@dwaring87/docdash",
21
21
  "test": "jest --passWithNoTests",
22
22
  "lint": "eslint src",
23
23
  "lint:fix": "eslint src --fix",
package/src/user/index.js CHANGED
@@ -274,9 +274,10 @@ class RTMUser {
274
274
  * - {@link RTMUser~tasks/increasePriority|increasePriority}
275
275
  * - {@link RTMUser~tasks/move|move}
276
276
  * - {@link RTMUser~tasks/setDueDate|setDueDate}
277
+ * - {@link RTMUser~tasks/setStartDate|setStartDate}
277
278
  * - {@link RTMUser~tasks/postpone|postpone}
278
279
  * - {@link RTMUser~tasks/setName|setName}
279
- * @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}}
280
+ * @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, setStartDate: function, postpone: function, setName: function}}
280
281
  */
281
282
  get tasks() {
282
283
  return require('./tasks.js')(this);
package/src/user/tasks.js CHANGED
@@ -360,7 +360,7 @@ module.exports = function(user) {
360
360
  listId,
361
361
  taskSeriesId,
362
362
  taskId,
363
- title,
363
+ title,
364
364
  notes,
365
365
  user,
366
366
  callback
@@ -588,7 +588,7 @@ module.exports = function(user) {
588
588
  return callback(err);
589
589
  }
590
590
 
591
- // Decrease the Priority of the Task
591
+ // Sets the Due Date of the Task
592
592
  return _tasks.setDueDate(
593
593
  listId,
594
594
  taskSeriesId,
@@ -602,6 +602,36 @@ module.exports = function(user) {
602
602
 
603
603
  };
604
604
 
605
+ /**
606
+ * Set the Start Date of the specified Task
607
+ * @param {int} index Task Index
608
+ * @param {string} start The Start Date of the Task (RTM parsed date)
609
+ * @param {function} callback Callback function(err)
610
+ * @param {RTMError} callback.err RTM API Error Response, if encountered
611
+ * @function RTMUser~tasks/setStartDate
612
+ */
613
+ rtn.setStartDate = function(index, start, callback) {
614
+
615
+ // Get the Task
616
+ _getTaskInfo(index, function(err, listId, taskSeriesId, taskId) {
617
+ if ( err ) {
618
+ return callback(err);
619
+ }
620
+
621
+ // Sets the Start Date of the Task
622
+ return _tasks.setStartDate(
623
+ listId,
624
+ taskSeriesId,
625
+ taskId,
626
+ start,
627
+ user,
628
+ callback
629
+ );
630
+
631
+ });
632
+
633
+ };
634
+
605
635
  /**
606
636
  * Set the Name of the specified Task
607
637
  * @param {int} index Task Index