Contact
Represents a Remember The Milk user whom you can share lists with or give tasks to.
addTask(name, parse)
Adds a new task for this contact.
Parameters
name
The name of the new task. Cannot be empty or contain only whitespace.
parse
Optionaltrue
to use Smart Add to process the task name,false
otherwise.
Return value
The newly added Task
.
Example
// Adds a new task "Buy bananas" for Bob T. Monkey.
const bob = rtm.getContacts()
.find(contact => contact.getEmail() === '[email protected]');
if (bob != null) {
const task = bob.addTask('Buy bananas');
console.log('Added "%s" task for %s.', task.getName(), bob.getEmail());
} else {
console.log('"[email protected]" contact not found.');
}
delete()
Deletes the contact. Any lists shared with this contact will be unshared.
Return value
undefined
Example
// Deletes a Bob T. Monkey contact.
const bob = rtm.getContacts()
.find(contact => contact.getEmail() === '[email protected]');
if (bob != null) {
bob.delete();
console.log('Deleted "%s" contact.', bob.getEmail());
} else {
console.log('"[email protected]" contact not found.');
}
getCreatedDate()
Gets the date the contact was created.
Return value
Example
// Outputs the list of contacts and their created dates.
rtm.getContacts().forEach(contact =>
console.log("%s - %s", contact.getEmail(), contact.getCreatedDate()));
getEmail()
Gets the email of the contact.
Return value
The email address of the contact.
Example
// Outputs the list of contacts.
rtm.getContacts().forEach(contact => console.log(contact.getEmail()));
getModifiedDate()
Gets the date the contact was last modified.
Return value
Example
// Outputs the list of contacts and their modified dates.
rtm.getContacts().forEach(contact =>
console.log("%s - %s", contact.getEmail(), contact.getModifiedDate()));
getPermalink()
Gets a permalink for this contact.
Return value
String
Example
// Outputs the list of contacts and their permalinks.
rtm.getContacts().forEach(contact =>
console.log("%s - %s", contact.getEmail(), contact.getPermalink()));
getTasks(filter)
Gets all tasks given to this contact.
Parameters
filter
OptionalIf specified, only tasks matching the given criteria are returned.
Return value
The list of Task
s given to this contact.
Example
// Outputs the number of incomplete tasks given to Bob T. Monkey.
const bob = rtm.getContacts()
.find(contact => contact.getEmail() === '[email protected]');
if (bob != null) {
console.log('Incomplete tasks given to "%s": %d',
bob.getEmail(), bob.getTasks('status:incomplete').length);
} else {
console.log('"[email protected]" contact not found.');
}
getUser()
Gets the contact username, email, and other details if available.
Return value
isFavorite()
Determines whether the contact is marked as a favorite.
Return value
true
if the contact is marked as a favorite, false
otherwise.
Example
// Outputs the email addresses of favorite contacts.
rtm.getContacts().forEach(contact => {
if (contact.isFavorite()) {
console.log(contact.getEmail());
}
});
isPending()
Determines whether the contact hasn't accepted a contact request yet.
Return value
true
if the contact hasn't accepted a contact request yet, false
otherwise.
Example
// Outputs the email addresses of pending contacts.
rtm.getContacts().forEach(contact => {
if (contact.isPending()) {
console.log(contact.getEmail());
}
});
setFavorite(favorite)
Sets whether the contact is marked as a favorite.
Parameters
favorite
true
to mark the contact as a favorite,false
otherwise.
Return value
The updated Contact
.
Example
// Favorites a Bob T. Monkey contact.
const bob = rtm.getContacts()
.find(contact => contact.getEmail() === '[email protected]');
if (bob != null) {
bob.setFavorite(true);
console.log('Marked "%s" contact as a favorite.', bob.getEmail());
} else {
console.log('"[email protected]" contact not found.');
}