RTMUser

RTMUser

RTM User

This Class is used to represent an authorized RTM User. An RTMUser instance contains the user's ID, username and fullname as well as an auth token that can be used to make user-authenticated API requests.

Usage

An RTMUser instance can created manually with an RTMClient:

let user = client.user.create(1234, 'username', 'full name', 'auth_token');

or can be returned through the RTM API auth process (specifically the callback function from RTMClient.auth.getAuthToken()).

// Get an Auth URL
client.auth.getAuthUrl(function(err, authUrl, frob) {

   // Have the User open this URL in their browser
   console.log(authUrl);

   // Get an authenticated RTMUser
   client.auth.getAuthToken(frob, function(err, user) {

     // user is an instance of RTMUser

   });

});

API Wrappers

The RTMUser also includes a number of wrapper functions for commonly used RTM API methods dealing with Lists and Tasks.

Tasks:

For example, to get the User's RTM Tasks:

user.tasks.get(function(err, tasks) {
   console.log(tasks);
});

The tasks.get() function will also fetch the User's RTM Lists and add the List (as an RTMList instance) that contains the Task to the list property of the RTMTask.

Constructor

new RTMUser(id, username, fullname, authToken)

Source:

Create a new RTM User.

An RTMUser can be used to make user-authenticated RTM API calls and also includes wrapper methods around some common RTM API methods.

Parameters:
Name Type Description
id number

The RTM User's ID

username string

The RTM User's username

fullname string

The RTM User's full name

authToken string

The RTM User's Auth Token

Members

authToken :string

Source:

RTM User Auth Token

Type:
  • string

client :RTMClient

Source:

The RTMClient that authorized this User

Type:

fullname :string

Source:

RTM User fullname

Type:
  • string

id :number

Source:

RTM User ID

Type:
  • number

lists

Source:

RTM List related functions:

tasks

Source:

RTM Task related functions:

timeline :number

Source:

The RTM Timeline for this User

Type:
  • number

username :string

Source:

RTM User Username

Type:
  • string

Methods

clearTaskIndexCache()

Source:

Clear the Task Index Cache for this RTM User

get(method, paramsopt, callback)

Source:

Make the specified RTM API call.

The method should be the name of the RTM API method. Any necessary parameters should be provided with params as an object with the properties of the object as the parameters' key/value pairs.

This function will automatically add the User's auth token to the request.

Parameters:
Name Type Attributes Description
method string

RTM API Method

params object <optional>

RTM API Method Parameters

callback function

Callback function(err, resp)

Properties
Name Type Description
err RTMError

RTM Error Response, if encountered

resp RTMSuccess

The parsed RTM API Response, if successful

verifyAuthToken(callback)

Source:

Verify the Auth Token of this RTM User

Parameters:
Name Type Description
callback function

Callback function(err, verified)

Properties
Name Type Description
err RTMError

RTM Error, if encountered (excluding a Login failed / Invalid auth token error)

verified boolean

true if the User's auth token was successfully verified or false if a Login failed / Invalid auth token error was encountered

(inner) lists/add(name, callback)

Source:

Add a new RTM List for this User

Parameters:
Name Type Description
name string

Name of the new RTM List

callback function

Callback function(err, lists)

Properties
Name Type Description
err RTMError

RTM API Error Response, if encountered

(inner) lists/get(callback)

Source:

Get the list of RTM Lists for this User from the API Server

Parameters:
Name Type Description
callback function

Callback function(err, lists)

Properties
Name Type Description
err RTMError

RTM API Error Response, if encountered

lists Array.<RTMList>

List of User's RTM Lists

(inner) lists/remove(name, callback)

Source:

Remove the specified RTM List for this User

Parameters:
Name Type Description
name string

RTM List Name

callback function

Callback function(err)

Properties
Name Type Description
err RTMError

RTM API Error Response, if encountered

(inner) lists/rename(oldName, newName, callback)

Source:

Rename the specified RTM List for this User

Parameters:
Name Type Description
oldName string

Old RTM List Name

newName string

New RTM List name

callback function

Callback function(err)

Properties
Name Type Description
err RTMError

RTM API Error Response, if encountered

(inner) tasks/add(name, propsopt, callback)

Source:

Add a new RTM Task for this User

Parameters:
Name Type Attributes Description
name string

Task Name (can include 'Smart Add' syntax)

props object <optional>

Task Properties

Properties
Name Type Description
due string

Task Due Date (RTM supported date format)

priority int

Task Priority (1, 2, 3)

list string

Task List Name

tags Array.<string>

Task Tags

location string

Task Location Name

start string

Task Start Date (RTM supported date format)

repeat string

Task Repeat Format (RTM supported repeat format)

estimate string

Task Time Estimate (RTM supported time estimate format)

to string

Contact Name to give Task to (existing contact or email address)

url string

Task Reference URL

note string

Task Note

callback function

Callback function(err)

Properties
Name Type Description
err RTMError

RTM API Error Response, if encountered

(inner) tasks/get(filteropt, callback)

Source:

Get the list of RTM Tasks for this User.

Parameters:
Name Type Attributes Description
filter string <optional>

Tasks Filter (RTM Advanced Search Syntax)

callback function

Callback function(err, tasks)

Properties
Name Type Description
err RTMError

RTM API Error Response, if encountered

tasks Array.<RTMTask>

List of User's RTM Tasks