@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,123 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <title>client/auth.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">client/auth.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 _auth = require('../utils/auth.js');
44
+
45
+
46
+ /**
47
+ * This module returns the auth-related functions for RTMClient
48
+ * @param {RTMClient} client RTMClient instance
49
+ * @returns {{getAuthUrl: function, getAuthToken: function, verifyAuthToken: function}}
50
+ * @private
51
+ */
52
+ module.exports = function(client) {
53
+ let rtn = {};
54
+
55
+ /**
56
+ * Get an Auth URL.
57
+ *
58
+ * This function will generate an Auth URL that will be given to the RTM User
59
+ * to authorize the RTM Client to access their account. It will also request
60
+ * a frob that will be used to gain an auth token in `getAuthToken()`.
61
+ * @param {function} callback Callback function(err, authUrl, frob)
62
+ * @param {RTMError} callback.err RTM Error Response, if encountered
63
+ * @param {string} callback.authUrl Auth URL to be given to User
64
+ * @param {string} callback.frob Auth Frob to be used in `getAuthToken()`
65
+ * @function RTMClient~auth/getAuthUrl
66
+ */
67
+ rtn.getAuthUrl = function(callback) {
68
+ _auth.getAuthUrl(client, callback);
69
+ };
70
+
71
+ /**
72
+ * Get an Auth Token.
73
+ *
74
+ * This function takes the frob that was generated by `getAuthUrl()` and
75
+ * requests an Auth Token. The callback function will return an `RTMUser`
76
+ * which will include the RTM User's information and an Auth Token to be
77
+ * used in future API calls.
78
+ * @param {string} frob Auth Frob from `getAuthUrl()`
79
+ * @param {function} callback Callback function(err, user)
80
+ * @param {RTMError} callback.err RTM Error Response, if encountered
81
+ * @param {RTMUser} callback.user RTM User, with user information and auth token
82
+ * @function RTMClient~auth/getAuthToken
83
+ */
84
+ rtn.getAuthToken = function(frob, callback) {
85
+ _auth.getAuthToken(frob, client, callback);
86
+ };
87
+
88
+ /**
89
+ * Verify Auth Token.
90
+ *
91
+ * This function will check if the User's Auth Token is still valid and
92
+ * can be used to make authenticated RTM API requests.
93
+ * @param {string|RTMUser} token Auth Token or RTMUser containing an auth token
94
+ * @param {function} callback Callback function(err, verified)
95
+ * @param {RTMError} callback.err RTM Error, if encountered (excluding a `Login failed / Invalid auth token` error)
96
+ * @param {boolean} callback.verified `true` if the User's auth token was successfully verified or `false` if
97
+ * a `Login failed / Invalid auth token` error was encountered
98
+ * @function RTMClient~auth/verifyAuthToken
99
+ */
100
+ rtn.verifyAuthToken = function(token, callback) {
101
+ _auth.verifyAuthToken(token, client, callback);
102
+ };
103
+
104
+ return rtn;
105
+ };</code></pre>
106
+ </article>
107
+ </section>
108
+
109
+
110
+
111
+
112
+ </div>
113
+
114
+ <br class="clear">
115
+
116
+ <footer>
117
+ 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.
118
+ </footer>
119
+
120
+ <script>prettyPrint();</script>
121
+ <script src="scripts/linenumber.js"></script>
122
+ </body>
123
+ </html>
@@ -0,0 +1,241 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <title>client/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">client/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
+
44
+ /**
45
+ * ### RTM API Client
46
+ *
47
+ * This Class is used to represent an RTM API Client. The Client contains
48
+ * the API Key, API Secret and access permissions used to access the
49
+ * RTM API endpoints.
50
+ *
51
+ * It also includes API wrapper functions for making a general RTM API request
52
+ * as well as the auth-related functions.
53
+ *
54
+ * #### Usage
55
+ *
56
+ * The `RTMClient` Class is what is exported when the entire `rtm-api` module
57
+ * is loaded via `require`.
58
+ *
59
+ * ```
60
+ * const RTM = require('rtm-api');
61
+ * let client = new RTM(API_KEY, API_SECRET, RTM.PERM_DELETE);
62
+ * ```
63
+ *
64
+ * #### Auth Example
65
+ *
66
+ * This example gets an Auth URL to be opened by the RTM User
67
+ *
68
+ * ```
69
+ * client.auth.getAuthUrl(function(err, authUrl, frob) {
70
+ * // Have user authenticate and authorize the program with the authUrl
71
+ * // Once authorized by the user, use the frob to get an authToken
72
+ * )};
73
+ * ```
74
+ *
75
+ * #### RTM API Example
76
+ *
77
+ * This example makes an RTM API request using the method `rtm.method` and the
78
+ * parameter foo=bar.
79
+ *
80
+ * ```
81
+ * client.get('rtm.method', {foo: "bar"}, function(err, resp) {
82
+ * if ( err ) {
83
+ * // handle error
84
+ * }
85
+ * // use the response
86
+ * });
87
+ * ```
88
+ *
89
+ * See {@link RTMUser#get|RTMUser.get} for making User-authenticated API requests.
90
+ *
91
+ * @class
92
+ */
93
+ class RTMClient {
94
+
95
+ /**
96
+ * Create a new RTM Client with the specified API access information
97
+ * @param {string} key RTM API Client Key
98
+ * @param {string} secret RTM API Client Secret
99
+ * @param {string} [perms=RTMClient.PERM_READ] RTM API Client Access Permissions. This
100
+ * should be one of {@link RTMClient.PERM_READ}, {@link RTMClient.PERM_WRITE} or
101
+ * {@link RTMClient.PERM_DELETE}.
102
+ * @constructor
103
+ */
104
+ constructor(key, secret, perms=RTMClient.PERM_READ) {
105
+ this._apiKey = key;
106
+ this._apiSecret = secret;
107
+ this._perms = perms;
108
+ }
109
+
110
+
111
+ /**
112
+ * RTM API Client Key
113
+ * @type {string}
114
+ */
115
+ get key() {
116
+ return this._apiKey;
117
+ }
118
+
119
+ /**
120
+ * RTM API Client Secret
121
+ * @type {string}
122
+ */
123
+ get secret() {
124
+ return this._apiSecret;
125
+ }
126
+
127
+ /**
128
+ * RTM API Client Access Permissions
129
+ * @type {string}
130
+ */
131
+ get perms() {
132
+ return this._perms;
133
+ }
134
+
135
+
136
+
137
+ // ===== USER FUNCTIONS ===== //
138
+
139
+ /**
140
+ * User export/import-related functions:
141
+ * - {@link RTMClient~user/create|create}
142
+ * - {@link RTMClient~user/export|export}
143
+ * - {@link RTMClient~user/exportToString|exportToString}
144
+ * - {@link RTMClient~user/import|import}
145
+ * - {@link RTMClient~user/importFromString|importFromString}
146
+ * @returns {{create: function, export: function, exportToString: function, import: function, importFromString: function}}
147
+ */
148
+ get user() {
149
+ return require('./user.js')(this);
150
+ }
151
+
152
+
153
+
154
+ // ===== API HELPER FUNCTIONS ===== //
155
+
156
+
157
+ /**
158
+ * Make the specified RTM API call.
159
+ *
160
+ * The `method` should be the name of the RTM API method. Any necessary
161
+ * parameters should be provided with `params` as an object with the properties
162
+ * of the object as the parameters' key/value pairs.
163
+ *
164
+ * RTM API methods that require an AuthToken should set the `params` `auth_token`
165
+ * property or provide a valid `RTMUser` with an AuthToken.
166
+ * @param {string} method RTM API Method
167
+ * @param {object} [params] RTM Method Parameters (as an object with key/value pairs)
168
+ * @param {RTMUser} [user=undefined] The RTM User making the request
169
+ * @param {function} callback Callback function(err, resp)
170
+ * @param {RTMError} callback.err RTM Error Response, if encountered
171
+ * @param {RTMSuccess} callback.resp The parsed RTM API Response, if successful
172
+ */
173
+ get(method, params, user, callback) {
174
+ require('../utils/get.js')(method, params, user, this, callback);
175
+ }
176
+
177
+ /**
178
+ * Auth-related functions:
179
+ * - {@link RTMClient~auth/getAuthUrl|getAuthUrl}
180
+ * - {@link RTMClient~auth/getAuthToken|getAuthToken}
181
+ * - {@link RTMClient~auth/verifyAuthToken|verifyAuthToken}
182
+ * @returns {{getAuthUrl: function, getAuthToken: function, verifyAuthToken: function}}
183
+ */
184
+ get auth() {
185
+ return require('./auth.js')(this);
186
+ }
187
+
188
+ }
189
+
190
+
191
+
192
+ // ==== RTM API PERMISSION LEVELS ==== //
193
+
194
+ /**
195
+ * RTM API Access: `read` -
196
+ * gives the ability to read task, contact, group and list details and contents.
197
+ * @type {string}
198
+ * @default
199
+ */
200
+ RTMClient.PERM_READ = 'read';
201
+
202
+ /**
203
+ * RTM API Access: `write` -
204
+ * gives the ability to add and modify task, contact, group and list details and
205
+ * contents (also allows you to `read`).
206
+ * @type {string}
207
+ * @default
208
+ */
209
+ RTMClient.PERM_WRITE = 'write';
210
+
211
+ /**
212
+ * RTM API Access: `delete` -
213
+ * gives the ability to delete task, contacts, groups and list (also allows
214
+ * you to `read` and `write`).
215
+ * @type {string}
216
+ * @default
217
+ */
218
+ RTMClient.PERM_DELETE = 'delete';
219
+
220
+
221
+
222
+ module.exports = RTMClient;
223
+ </code></pre>
224
+ </article>
225
+ </section>
226
+
227
+
228
+
229
+
230
+ </div>
231
+
232
+ <br class="clear">
233
+
234
+ <footer>
235
+ 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.
236
+ </footer>
237
+
238
+ <script>prettyPrint();</script>
239
+ <script src="scripts/linenumber.js"></script>
240
+ </body>
241
+ </html>
@@ -0,0 +1,170 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <title>client/user.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">client/user.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 RTMClient = require('./index.js');
44
+ const RTMUser = require('../user/index.js');
45
+
46
+
47
+ /**
48
+ * This module returns the user-related functions for RTMClient
49
+ * @param {RTMClient} client RTMClient instance
50
+ * @returns {{create: function, export: function, exportToString: function, import: function, importFromString: function}}
51
+ */
52
+ module.exports = function(client) {
53
+ let rtn = {};
54
+
55
+ /**
56
+ * Create a new `RTMUser` manually.
57
+ *
58
+ * This will also set the User's RTM API Client to this `RTMClient`.
59
+ * @param {number} id The RTM User's ID
60
+ * @param {string} username The RTM User's username
61
+ * @param {string} fullname The RTM User's full name
62
+ * @param {string} authToken The RTM User's Auth Token
63
+ * @returns {RTMUser}
64
+ * @function RTMClient~user/create
65
+ */
66
+ rtn.create = function(id, username, fullname, authToken) {
67
+ let user = new RTMUser(id, username, fullname, authToken);
68
+ user.client = client;
69
+ return user;
70
+ };
71
+
72
+ /**
73
+ * Get the User's required information:
74
+ * - id
75
+ * - username
76
+ * - fullname
77
+ * - authToken
78
+ * - client (if set or use this `RTMClient`)
79
+ * @param {RTMUser} user The RTMUser to export
80
+ * @returns {object}
81
+ * @function RTMClient~user/export
82
+ */
83
+ rtn.export = function(user) {
84
+ let rtn = {
85
+ id: user.id,
86
+ username: user.username,
87
+ fullname: user.fullname,
88
+ authToken: user.authToken,
89
+ timeline: user._timeline
90
+ };
91
+ if ( user.client ) {
92
+ rtn.client = {
93
+ apiKey: user.client.key,
94
+ apiSecret: user.client.secret,
95
+ perms: user.client.perms
96
+ }
97
+ }
98
+ else {
99
+ rtn.client = {
100
+ apiKey: client.key,
101
+ apiSecret: client.key,
102
+ perms: client.perms
103
+ }
104
+ }
105
+
106
+ return rtn;
107
+ };
108
+
109
+ /**
110
+ * Get the User's required information as a JSON-string
111
+ * @param {RTMUser} user The RTMUser to export
112
+ * @returns {string}
113
+ * @function RTMClient~user/exportToString
114
+ */
115
+ rtn.exportToString = function(user) {
116
+ return JSON.stringify(rtn.export(user));
117
+ };
118
+
119
+ /**
120
+ * Create a new `RTMUser` from an exported User's properties
121
+ * @param {Object} properties The RTM User's required properties
122
+ * @returns {RTMUser}
123
+ * @function RTMClient~user/import
124
+ */
125
+ rtn.import = function(properties) {
126
+ if ( properties.id &amp;&amp; properties.username &amp;&amp; properties.fullname &amp;&amp; properties.authToken ) {
127
+ let user = new RTMUser(properties.id, properties.username, properties.fullname, properties.authToken);
128
+ if ( properties.timeline ) {
129
+ user.timeline = properties.timeline;
130
+ }
131
+ if ( properties.client ) {
132
+ user.client = new RTMClient(properties.client.apiKey, properties.client.apiSecret, properties.client.perms);
133
+ }
134
+ return user;
135
+ }
136
+ else {
137
+ throw "Missing User Properties";
138
+ }
139
+ };
140
+
141
+ /**
142
+ * Create a new `RTMUser` from an exported User's properties' JSON-string
143
+ * @param {string} string JSON-string of RTM User's required properties
144
+ * @returns {RTMUser}
145
+ * @function RTMClient~user/importFromString
146
+ */
147
+ rtn.importFromString = function(string) {
148
+ return rtn.import(JSON.parse(string));
149
+ };
150
+
151
+ return rtn;
152
+ };</code></pre>
153
+ </article>
154
+ </section>
155
+
156
+
157
+
158
+
159
+ </div>
160
+
161
+ <br class="clear">
162
+
163
+ <footer>
164
+ 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.
165
+ </footer>
166
+
167
+ <script>prettyPrint();</script>
168
+ <script src="scripts/linenumber.js"></script>
169
+ </body>
170
+ </html>