Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More

node-outlook

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-outlook - npm Package Compare versions

Comparing version 1.1.4 to 1.1.5

// Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license at the bottom of this file.
var base = require('./version-2.js');
var utilities = require('./utilities.js');
/**
* @module calendar
*/
module.exports = {

@@ -10,12 +15,48 @@ /**

* @param parameters.token {string} The access token.
* @param [parameters.user] {string} The SMTP address of the user. If absent, the '/Me' segment is used in the API URL.
* @param [parameters.useMe] {boolean} If true, use the `/Me` segment instead of the `/Users/<email>` segment. This parameter defaults to false and is ignored if the `parameters.user.email` parameter isn't provided (the `/Me` segment is always used in this case).
* @param [parameters.user.email] {string} The SMTP address of the user. If absent, the `/Me` segment is used in the API URL.
* @param [parameters.user.timezone] {string} The timezone of the user.
* @param [parameters.calendarId] {string} The calendar id. If absent, the API calls the `/User/Events` endpoint.
*
* @param [parameters.odataParams] {object} An object containing key/value pairs representing OData query parameters. See [Use OData query parameters]{@link https://msdn.microsoft.com/office/office365/APi/complex-types-for-mail-contacts-calendar#UseODataqueryparameters} for details.
*
* @param [callback] {function} A callback function that is called when the function completes. It should have the signature `function (error, result)`.
*
* @example var outlook = require('node-outlook');
*
* // Set the API endpoint to use the v2.0 endpoint
* outlook.base.setApiEndpoint('https://outlook.office.com/api/v2.0');
*
* // This is the oAuth token
* var token = 'eyJ0eXAiOiJKV1Q...';
*
* // Set up oData parameters
* var queryParams = {
* '$select': 'Subject,Start,End',
* '$orderby': 'Start/DateTime desc',
* '$top': 20
* };
*
* // Pass the user's email address
* var userInfo = {
* email: 'sarad@contoso.com'
* };
*
* outlook.calendar.getEvents({token: token, folderId: 'Inbox', odataParams: queryParams, user: userInfo},
* function(error, result){
* if (error) {
* console.log('getEvents returned an error: ' + error);
* }
* else if (result) {
* console.log('getEvents returned ' + result.value.length + ' events.');
* result.value.forEach(function(event) {
* console.log(' Subject:', event.Subject);
* console.log(' Start:', event.Start.DateTime.toString());
* console.log(' End:', event.End.DateTime.toString());
* });
* }
* });
*/
getEvents: function(parameters, callback){
var userSpec = parameters.user === undefined ? '/Me' : '/Users/' + parameters.user;
var calendarSpec = parameters.folderId === undefined ? '' : '/Calendars/' + parameters.folderId;
var userSpec = utilities.getUserSegment(parameters);
var calendarSpec = parameters.calendarId === undefined ? '' : '/Calendars/' + parameters.calendarId;

@@ -26,3 +67,4 @@ var requestUrl = base.apiEndpoint() + userSpec + calendarSpec + '/Events';

url: requestUrl,
token: parameters.token
token: parameters.token,
user: parameters.user
};

@@ -59,10 +101,44 @@

* @param parameters.eventId {string} The Id of the event.
* @param [parameters.user] {string} The SMTP address of the user. If absent, the '/Me' segment is used in the API URL.
*
* @param [parameters.useMe] {boolean} If true, use the `/Me` segment instead of the `/Users/<email>` segment. This parameter defaults to false and is ignored if the `parameters.user.email` parameter isn't provided (the `/Me` segment is always used in this case).
* @param [parameters.user.email] {string} The SMTP address of the user. If absent, the `/Me` segment is used in the API URL.
* @param [parameters.user.timezone] {string} The timezone of the user.
* @param [parameters.odataParams] {object} An object containing key/value pairs representing OData query parameters. See [Use OData query parameters]{@link https://msdn.microsoft.com/office/office365/APi/complex-types-for-mail-contacts-calendar#UseODataqueryparameters} for details.
* @param [callback] {function} A callback function that is called when the function completes. It should have the signature `function (error, result)`.
*
* @param [callback] {function} A callback function that is called when the function completes. It should have the signature `function (error, result)`.
* @example var outlook = require('node-outlook');
*
* // Set the API endpoint to use the v2.0 endpoint
* outlook.base.setApiEndpoint('https://outlook.office.com/api/v2.0');
*
* // This is the oAuth token
* var token = 'eyJ0eXAiOiJKV1Q...';
*
* // The Id property of the event to retrieve. This could be
* // from a previous call to getEvents
* var eventId = 'AAMkADVhYTYwNzk...';
*
* // Set up oData parameters
* var queryParams = {
* '$select': 'Subject,Start,End'
* };
*
* // Pass the user's email address
* var userInfo = {
* email: 'sarad@contoso.com'
* };
*
* outlook.calendar.getEvent({token: token, eventId: eventId, odataParams: queryParams, user: userInfo},
* function(error, result){
* if (error) {
* console.log('getEvent returned an error: ' + error);
* }
* else if (result) {
* console.log(' Subject:', result.Subject);
* console.log(' Start:', result.Start.DateTime.toString());
* console.log(' End:', result.End.DateTime.toString());
* }
* });
*/
getEvent: function(parameters, callback) {
var userSpec = parameters.user === undefined ? '/Me' : '/Users/' + parameters.user;
var userSpec = utilities.getUserSegment(parameters);

@@ -73,3 +149,4 @@ var requestUrl = base.apiEndpoint() + userSpec + '/Events/' + parameters.eventId;

url: requestUrl,
token: parameters.token
token: parameters.token,
user: parameters.user
};

@@ -101,2 +178,95 @@

/**
* Create a new event
*
* @param parameters {object} An object containing all of the relevant parameters. Possible values:
* @param parameters.token {string} The access token.
* @param parameters.event {object} The JSON-serializable event
* @param [parameters.useMe] {boolean} If true, use the `/Me` segment instead of the `/Users/<email>` segment. This parameter defaults to false and is ignored if the `parameters.user.email` parameter isn't provided (the `/Me` segment is always used in this case).
* @param [parameters.user.email] {string} The SMTP address of the user. If absent, the `/Me` segment is used in the API URL.
* @param [parameters.user.timezone] {string} The timezone of the user.
* @param [parameters.calendarId] {string} The calendar id. If absent, the API calls the `/User/Events` endpoint.
* @param [callback] {function} A callback function that is called when the function completes. It should have the signature `function (error, result)`.
*
* @example var outlook = require('node-outlook');
*
* // Set the API endpoint to use the v2.0 endpoint
* outlook.base.setApiEndpoint('https://outlook.office.com/api/v2.0');
*
* // This is the oAuth token
* var token = 'eyJ0eXAiOiJKV1Q...';
*
* var newEvent = {
* "Subject": "Discuss the Calendar REST API",
* "Body": {
* "ContentType": "HTML",
* "Content": "I think it will meet our requirements!"
* },
* "Start": {
* "DateTime": "2016-02-03T18:00:00",
* "TimeZone": "Eastern Standard Time"
* },
* "End": {
* "DateTime": "2016-02-03T19:00:00",
* "TimeZone": "Eastern Standard Time"
* },
* "Attendees": [
* {
* "EmailAddress": {
* "Address": "allieb@contoso.com",
* "Name": "Allie Bellew"
* },
* "Type": "Required"
* }
* ]
* };
*
* // Pass the user's email address
* var userInfo = {
* email: 'sarad@contoso.com'
* };
*
* outlook.calendar.createEvent({token: token, event: newEvent, user: userInfo},
* function(error, result){
* if (error) {
* console.log('createEvent returned an error: ' + error);
* }
* else if (result) {
* console.log(JSON.stringify(result, null, 2));
* }
* });
*/
createEvent: function(parameters, callback) {
var userSpec = utilities.getUserSegment(parameters);
var calendarSpec = parameters.calendarId === undefined ? '' : '/Calendars/' + parameters.calendarId;
var requestUrl = base.apiEndpoint() + userSpec + calendarSpec + '/Events';
var apiOptions = {
url: requestUrl,
token: parameters.token,
user: parameters.user,
payload: parameters.event,
method: 'POST'
};
base.makeApiCall(apiOptions, function(error, response) {
if (error) {
if (typeof callback === 'function') {
callback(error, response);
}
}
else if (response.statusCode !== 201) {
if (typeof callback === 'function') {
callback('REST request returned ' + response.statusCode + '; body: ' + JSON.stringify(response.body), response);
}
}
else {
if (typeof callback === 'function') {
callback(null, response.body);
}
}
});
},
/**
* Update a specific event.

@@ -107,11 +277,45 @@ *

* @param parameters.eventId {string} The Id of the event.
* @param parameters.update {object}: The JSON-serializable update payload
* @param [parameters.user] {string} The SMTP address of the user. If absent, the '/Me' segment is used in the API URL.
*
* @param parameters.update {object} The JSON-serializable update payload
* @param [parameters.useMe] {boolean} If true, use the `/Me` segment instead of the `/Users/<email>` segment. This parameter defaults to false and is ignored if the `parameters.user.email` parameter isn't provided (the `/Me` segment is always used in this case).
* @param [parameters.user.email] {string} The SMTP address of the user. If absent, the `/Me` segment is used in the API URL.
* @param [parameters.user.timezone] {string} The timezone of the user.
* @param [parameters.odataParams] {object} An object containing key/value pairs representing OData query parameters. See [Use OData query parameters]{@link https://msdn.microsoft.com/office/office365/APi/complex-types-for-mail-contacts-calendar#UseODataqueryparameters} for details.
* @param [callback] {function} A callback function that is called when the function completes. It should have the signature `function (error, result)`.
*
* @param [callback] {function} A callback function that is called when the function completes. It should have the signature `function (error, result)`.
* @example var outlook = require('node-outlook');
*
* // Set the API endpoint to use the v2.0 endpoint
* outlook.base.setApiEndpoint('https://outlook.office.com/api/v2.0');
*
* // This is the oAuth token
* var token = 'eyJ0eXAiOiJKV1Q...';
*
* // The Id property of the event to update. This could be
* // from a previous call to getEvents
* var eventId = 'AAMkADVhYTYwNzk...';
*
* // Update the location
* var update = {
* Location: {
* DisplayName: 'Conference Room 2'
* }
* };
*
* // Pass the user's email address
* var userInfo = {
* email: 'sarad@contoso.com'
* };
*
* outlook.calendar.updateEvent({token: token, eventId: eventId, update: update, user: userInfo},
* function(error, result){
* if (error) {
* console.log('updateEvent returned an error: ' + error);
* }
* else if (result) {
* console.log(JSON.stringify(result, null, 2));
* }
* });
*/
updateEvent: function(parameters, callback) {
var userSpec = parameters.user === undefined ? '/Me' : '/Users/' + parameters.user;
var userSpec = utilities.getUserSegment(parameters);

@@ -123,2 +327,3 @@ var requestUrl = base.apiEndpoint() + userSpec + '/Events/' + parameters.eventId;

token: parameters.token,
user: parameters.user,
payload: parameters.update,

@@ -157,10 +362,36 @@ method: 'PATCH'

* @param parameters.eventId {string} The Id of the event.
* @param [parameters.user] {string} The SMTP address of the user. If absent, the '/Me' segment is used in the API URL.
* @param [parameters.useMe] {boolean} If true, use the `/Me` segment instead of the `/Users/<email>` segment. This parameter defaults to false and is ignored if the `parameters.user.email` parameter isn't provided (the `/Me` segment is always used in this case).
* @param [parameters.user.email] {string} The SMTP address of the user. If absent, the `/Me` segment is used in the API URL.
* @param [parameters.user.timezone] {string} The timezone of the user.
* @param [callback] {function} A callback function that is called when the function completes. It should have the signature `function (error, result)`.
*
* @param [parameters.odataParams] {object} An object containing key/value pairs representing OData query parameters. See [Use OData query parameters]{@link https://msdn.microsoft.com/office/office365/APi/complex-types-for-mail-contacts-calendar#UseODataqueryparameters} for details.
* @example var outlook = require('node-outlook');
*
* @param [callback] {function} A callback function that is called when the function completes. It should have the signature `function (error, result)`.
* // Set the API endpoint to use the v2.0 endpoint
* outlook.base.setApiEndpoint('https://outlook.office.com/api/v2.0');
*
* // This is the oAuth token
* var token = 'eyJ0eXAiOiJKV1Q...';
*
* // The Id property of the event to delete. This could be
* // from a previous call to getEvents
* var eventId = 'AAMkADVhYTYwNzk...';
*
* // Pass the user's email address
* var userInfo = {
* email: 'sarad@contoso.com'
* };
*
* outlook.calendar.deleteEvent({token: token, eventId: eventId, user: userInfo},
* function(error, result){
* if (error) {
* console.log('deleteEvent returned an error: ' + error);
* }
* else if (result) {
* console.log('SUCCESS');
* }
* });
*/
deleteEvent: function(parameters, callback) {
var userSpec = parameters.user === undefined ? '/Me' : '/Users/' + parameters.user;
var userSpec = utilities.getUserSegment(parameters);

@@ -172,2 +403,3 @@ var requestUrl = base.apiEndpoint() + userSpec + '/Events/' + parameters.eventId;

token: parameters.token,
user: parameters.user,
method: 'DELETE'

@@ -174,0 +406,0 @@ };

// Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license at the bottom of this file.
var base = require('./version-2.js');
var utilities = require('./utilities.js');
/**
* @module contacts
*/
module.exports = {

@@ -11,3 +16,5 @@ /**

* @param parameters.token {string} The access token.
* @param [parameters.user] {string} The SMTP address of the user. If absent, the '/Me' segment is used in the API URL.
* @param [parameters.useMe] {boolean} If true, use the `/Me` segment instead of the `/Users/<email>` segment. This parameter defaults to false and is ignored if the `parameters.user.email` parameter isn't provided (the `/Me` segment is always used in this case).
* @param [parameters.user.email] {string} The SMTP address of the user. If absent, the `/Me` segment is used in the API URL.
* @param [parameters.user.timezone] {string} The timezone of the user.
* @param [parameters.contactFolderId] {string} The contact folder id. If absent, the API calls the `/User/Contacts` endpoint.

@@ -18,5 +25,40 @@ *

* @param [callback] {function} A callback function that is called when the function completes. It should have the signature `function (error, result)`.
*
* @example var outlook = require('node-outlook');
*
* // Set the API endpoint to use the v2.0 endpoint
* outlook.base.setApiEndpoint('https://outlook.office.com/api/v2.0');
*
* // This is the oAuth token
* var token = 'eyJ0eXAiOiJKV1Q...';
*
* // Set up oData parameters
* var queryParams = {
* '$select': 'GivenName,Surname,EmailAddresses',
* '$orderby': 'CreatedDateTime desc',
* '$top': 20
* };
*
* // Pass the user's email address
* var userInfo = {
* email: 'sarad@contoso.com'
* };
*
* outlook.contacts.getContacts({token: token, odataParams: queryParams, user: userInfo},
* function(error, result){
* if (error) {
* console.log('getContacts returned an error: ' + error);
* }
* else if (result) {
* console.log('getContacts returned ' + result.value.length + ' contacts.');
* result.value.forEach(function(contact) {
* console.log(' GivenName:', contact.GivenName);
* console.log(' Surname:', contact.Surname);
* console.log(' Email Address:', contact.EmailAddresses[0] ? contact.EmailAddresses[0].Address : "NONE");
* });
* }
* });
*/
getContacts: function(parameters, callback){
var userSpec = parameters.user === undefined ? '/Me' : '/Users/' + parameters.user;
var userSpec = utilities.getUserSegment(parameters);
var contactFolderSpec = parameters.folderId === undefined ? '' : '/ContactFolders/' + parameters.folderId;

@@ -28,3 +70,4 @@

url: requestUrl,
token: parameters.token
token: parameters.token,
user: parameters.user
};

@@ -53,2 +96,318 @@

});
},
/**
* Used to get a specific contact.
*
* @param parameters {object} An object containing all of the relevant parameters. Possible values:
* @param parameters.token {string} The access token.
* @param parameters.contactId {string} The Id of the contact.
* @param [parameters.useMe] {boolean} If true, use the `/Me` segment instead of the `/Users/<email>` segment. This parameter defaults to false and is ignored if the `parameters.user.email` parameter isn't provided (the `/Me` segment is always used in this case).
* @param [parameters.user.email] {string} The SMTP address of the user. If absent, the `/Me` segment is used in the API URL.
* @param [parameters.user.timezone] {string} The timezone of the user.
* @param [parameters.odataParams] {object} An object containing key/value pairs representing OData query parameters. See [Use OData query parameters]{@link https://msdn.microsoft.com/office/office365/APi/complex-types-for-mail-contacts-calendar#UseODataqueryparameters} for details.
* @param [callback] {function} A callback function that is called when the function completes. It should have the signature `function (error, result)`.
*
* @example var outlook = require('node-outlook');
*
* // Set the API endpoint to use the v2.0 endpoint
* outlook.base.setApiEndpoint('https://outlook.office.com/api/v2.0');
*
* // This is the oAuth token
* var token = 'eyJ0eXAiOiJKV1Q...';
*
* // The Id property of the contact to retrieve. This could be
* // from a previous call to getContacts
* var contactId = 'AAMkADVhYTYwNzk...';
*
* // Set up oData parameters
* var queryParams = {
* '$select': 'GivenName,Surname,EmailAddresses'
* };
*
* // Pass the user's email address
* var userInfo = {
* email: 'sarad@contoso.com'
* };
*
* outlook.contacts.getContact({token: token, contactId: contactId, odataParams: queryParams, user: userInfo},
* function(error, result){
* if (error) {
* console.log('getContact returned an error: ' + error);
* }
* else if (result) {
* console.log(' GivenName:', result.GivenName);
* console.log(' Surname:', result.Surname);
* console.log(' Email Address:', result.EmailAddresses[0] ? result.EmailAddresses[0].Address : "NONE");
* }
* });
*/
getContact: function(parameters, callback) {
var userSpec = utilities.getUserSegment(parameters);
var requestUrl = base.apiEndpoint() + userSpec + '/Contacts/' + parameters.contactId;
var apiOptions = {
url: requestUrl,
token: parameters.token,
user: parameters.user
};
if (parameters.odataParams !== undefined) {
apiOptions['query'] = parameters.odataParams;
}
base.makeApiCall(apiOptions, function(error, response) {
if (error) {
if (typeof callback === 'function') {
callback(error, response);
}
}
else if (response.statusCode !== 200) {
if (typeof callback === 'function') {
callback('REST request returned ' + response.statusCode + '; body: ' + JSON.stringify(response.body), response);
}
}
else {
if (typeof callback === 'function') {
callback(null, response.body);
}
}
});
},
/**
* Create a new contact
*
* @param parameters {object} An object containing all of the relevant parameters. Possible values:
* @param parameters.token {string} The access token.
* @param parameters.contact {object} The JSON-serializable contact
* @param [parameters.useMe] {boolean} If true, use the `/Me` segment instead of the `/Users/<email>` segment. This parameter defaults to false and is ignored if the `parameters.user.email` parameter isn't provided (the `/Me` segment is always used in this case).
* @param [parameters.user.email] {string} The SMTP address of the user. If absent, the `/Me` segment is used in the API URL.
* @param [parameters.user.timezone] {string} The timezone of the user.
* @param [parameters.contactFolderId] {string} The contact folder id. If absent, the API calls the `/User/Contacts` endpoint.
* @param [callback] {function} A callback function that is called when the function completes. It should have the signature `function (error, result)`.
*
* @example var outlook = require('node-outlook');
*
* // Set the API endpoint to use the v2.0 endpoint
* outlook.base.setApiEndpoint('https://outlook.office.com/api/v2.0');
*
* // This is the oAuth token
* var token = 'eyJ0eXAiOiJKV1Q...';
*
* var newContact = {
* "GivenName": "Pavel",
* "Surname": "Bansky",
* "EmailAddresses": [
* {
* "Address": "pavelb@contoso.com",
* "Name": "Pavel Bansky"
* }
* ],
* "BusinessPhones": [
* "+1 732 555 0102"
* ]
* };
*
* // Pass the user's email address
* var userInfo = {
* email: 'sarad@contoso.com'
* };
*
* outlook.contacts.createContact({token: token, contact: newContact, user: userInfo},
* function(error, result){
* if (error) {
* console.log('createContact returned an error: ' + error);
* }
* else if (result) {
* console.log(JSON.stringify(result, null, 2));
* }
* });
*/
createContact: function(parameters, callback) {
var userSpec = utilities.getUserSegment(parameters);
var folderSpec = parameters.folderId === undefined ? '' : '/ContactFolders/' + parameters.folderId;
var requestUrl = base.apiEndpoint() + userSpec + folderSpec + '/Contacts';
var apiOptions = {
url: requestUrl,
token: parameters.token,
user: parameters.user,
payload: parameters.contact,
method: 'POST'
};
base.makeApiCall(apiOptions, function(error, response) {
if (error) {
if (typeof callback === 'function') {
callback(error, response);
}
}
else if (response.statusCode !== 201) {
if (typeof callback === 'function') {
callback('REST request returned ' + response.statusCode + '; body: ' + JSON.stringify(response.body), response);
}
}
else {
if (typeof callback === 'function') {
callback(null, response.body);
}
}
});
},
/**
* Update a specific contact.
*
* @param parameters {object} An object containing all of the relevant parameters. Possible values:
* @param parameters.token {string} The access token.
* @param parameters.contactId {string} The Id of the contact.
* @param parameters.update {object} The JSON-serializable update payload
* @param [parameters.useMe] {boolean} If true, use the `/Me` segment instead of the `/Users/<email>` segment. This parameter defaults to false and is ignored if the `parameters.user.email` parameter isn't provided (the `/Me` segment is always used in this case).
* @param [parameters.user.email] {string} The SMTP address of the user. If absent, the `/Me` segment is used in the API URL.
* @param [parameters.user.timezone] {string} The timezone of the user.
* @param [parameters.odataParams] {object} An object containing key/value pairs representing OData query parameters. See [Use OData query parameters]{@link https://msdn.microsoft.com/office/office365/APi/complex-types-for-mail-contacts-calendar#UseODataqueryparameters} for details.
* @param [callback] {function} A callback function that is called when the function completes. It should have the signature `function (error, result)`.
*
* @example var outlook = require('node-outlook');
*
* // Set the API endpoint to use the v2.0 endpoint
* outlook.base.setApiEndpoint('https://outlook.office.com/api/v2.0');
*
* // This is the oAuth token
* var token = 'eyJ0eXAiOiJKV1Q...';
*
* // The Id property of the contact to update. This could be
* // from a previous call to getContacts
* var contactId = 'AAMkADVhYTYwNzk...';
*
* // Change the mobile number
* var update = {
* MobilePhone1: '425-555-1212',
* };
*
* // Pass the user's email address
* var userInfo = {
* email: 'sarad@contoso.com'
* };
*
* outlook.contacts.updateContact({token: token, contactId: contactId, update: update, user: userInfo},
* function(error, result){
* if (error) {
* console.log('updateContact returned an error: ' + error);
* }
* else if (result) {
* console.log(JSON.stringify(result, null, 2));
* }
* });
*/
updateContact: function(parameters, callback) {
var userSpec = utilities.getUserSegment(parameters);
var requestUrl = base.apiEndpoint() + userSpec + '/Contacts/' + parameters.contactId;
var apiOptions = {
url: requestUrl,
token: parameters.token,
user: parameters.user,
payload: parameters.update,
method: 'PATCH'
};
if (parameters.odataParams !== undefined) {
apiOptions['query'] = parameters.odataParams;
}
base.makeApiCall(apiOptions, function(error, response) {
if (error) {
if (typeof callback === 'function') {
callback(error, response);
}
}
else if (response.statusCode !== 200) {
if (typeof callback === 'function') {
callback('REST request returned ' + response.statusCode + '; body: ' + JSON.stringify(response.body), response);
}
}
else {
if (typeof callback === 'function') {
callback(null, response.body);
}
}
});
},
/**
* Delete a specific contact.
*
* @param parameters {object} An object containing all of the relevant parameters. Possible values:
* @param parameters.token {string} The access token.
* @param parameters.contactId {string} The Id of the contact.
* @param [parameters.useMe] {boolean} If true, use the `/Me` segment instead of the `/Users/<email>` segment. This parameter defaults to false and is ignored if the `parameters.user.email` parameter isn't provided (the `/Me` segment is always used in this case).
* @param [parameters.user.email] {string} The SMTP address of the user. If absent, the `/Me` segment is used in the API URL.
* @param [parameters.user.timezone] {string} The timezone of the user.
* @param [callback] {function} A callback function that is called when the function completes. It should have the signature `function (error, result)`.
*
* @example var outlook = require('node-outlook');
*
* // Set the API endpoint to use the v2.0 endpoint
* outlook.base.setApiEndpoint('https://outlook.office.com/api/v2.0');
*
* // This is the oAuth token
* var token = 'eyJ0eXAiOiJKV1Q...';
*
* // The Id property of the contact to delete. This could be
* // from a previous call to getContacts
* var contactId = 'AAMkADVhYTYwNzk...';
*
* // Pass the user's email address
* var userInfo = {
* email: 'sarad@contoso.com'
* };
*
* outlook.contacts.deleteContact({token: token, contactId: contactId, user: userInfo},
* function(error, result){
* if (error) {
* console.log('deleteContact returned an error: ' + error);
* }
* else if (result) {
* console.log('SUCCESS');
* }
* });
*/
deleteContact: function(parameters, callback) {
var userSpec = utilities.getUserSegment(parameters);
var requestUrl = base.apiEndpoint() + userSpec + '/Contacts/' + parameters.contactId;
var apiOptions = {
url: requestUrl,
token: parameters.token,
user: parameters.user,
method: 'DELETE'
};
if (parameters.odataParams !== undefined) {
apiOptions['query'] = parameters.odataParams;
}
base.makeApiCall(apiOptions, function(error, response) {
if (error) {
if (typeof callback === 'function') {
callback(error, response);
}
}
else if (response.statusCode !== 204) {
if (typeof callback === 'function') {
callback('REST request returned ' + response.statusCode + '; body: ' + JSON.stringify(response.body), response);
}
}
else {
if (typeof callback === 'function') {
callback(null, response.body);
}
}
});
}

@@ -55,0 +414,0 @@ };

// Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license at the bottom of this file.
var base = require('./version-2.js');
var utilities = require('./utilities.js');
/**
* @module mail
*/
module.exports = {

@@ -10,3 +15,5 @@ /**

* @param parameters.token {string} The access token.
* @param [parameters.user] {string} The SMTP address of the user. If absent, the '/Me' segment is used in the API URL.
* @param [parameters.useMe] {boolean} If true, use the `/Me` segment instead of the `/Users/<email>` segment. This parameter defaults to false and is ignored if the `parameters.user.email` parameter isn't provided (the `/Me` segment is always used in this case).
* @param [parameters.user.email] {string} The SMTP address of the user. If absent, the `/Me` segment is used in the API URL.
* @param [parameters.user.timezone] {string} The timezone of the user.
* @param [parameters.folderId] {string} The folder id. If absent, the API calls the `/User/Messages` endpoint. Valid values of this parameter are:

@@ -23,6 +30,41 @@ *

* @param [callback] {function} A callback function that is called when the function completes. It should have the signature `function (error, result)`.
*
* @example var outlook = require('node-outlook');
*
* // Set the API endpoint to use the v2.0 endpoint
* outlook.base.setApiEndpoint('https://outlook.office.com/api/v2.0');
*
* // This is the oAuth token
* var token = 'eyJ0eXAiOiJKV1Q...';
*
* // Set up oData parameters
* var queryParams = {
* '$select': 'Subject,ReceivedDateTime,From',
* '$orderby': 'ReceivedDateTime desc',
* '$top': 20
* };
*
* // Pass the user's email address
* var userInfo = {
* email: 'sarad@contoso.com'
* };
*
* outlook.mail.getMessages({token: token, folderId: 'Inbox', odataParams: queryParams, user: userInfo},
* function(error, result){
* if (error) {
* console.log('getMessages returned an error: ' + error);
* }
* else if (result) {
* console.log('getMessages returned ' + result.value.length + ' messages.');
* result.value.forEach(function(message) {
* console.log(' Subject:', message.Subject);
* console.log(' Received:', message.ReceivedDateTime.toString());
* console.log(' From:', message.From ? message.From.EmailAddress.Name : 'EMPTY');
* });
* }
* });
*/
getMessages: function(parameters, callback){
var userSpec = parameters.user === undefined ? '/Me' : '/Users/' + parameters.user;
var folderSpec = parameters.folderId === undefined ? '' : '/Folders/' + parameters.folderId;
var userSpec = utilities.getUserSegment(parameters);
var folderSpec = parameters.folderId === undefined ? '' : getFolderSegment() + parameters.folderId;

@@ -33,3 +75,4 @@ var requestUrl = base.apiEndpoint() + userSpec + folderSpec + '/Messages';

url: requestUrl,
token: parameters.token
token: parameters.token,
user: parameters.user
};

@@ -58,5 +101,494 @@

});
}
},
/**
* Used to get a specific message.
*
* @param parameters {object} An object containing all of the relevant parameters. Possible values:
* @param parameters.token {string} The access token.
* @param parameters.messageId {string} The Id of the message.
* @param [parameters.useMe] {boolean} If true, use the `/Me` segment instead of the `/Users/<email>` segment. This parameter defaults to false and is ignored if the `parameters.user.email` parameter isn't provided (the `/Me` segment is always used in this case).
* @param [parameters.user.email] {string} The SMTP address of the user. If absent, the `/Me` segment is used in the API URL.
* @param [parameters.user.timezone] {string} The timezone of the user.
* @param [parameters.odataParams] {object} An object containing key/value pairs representing OData query parameters. See [Use OData query parameters]{@link https://msdn.microsoft.com/office/office365/APi/complex-types-for-mail-contacts-calendar#UseODataqueryparameters} for details.
* @param [callback] {function} A callback function that is called when the function completes. It should have the signature `function (error, result)`.
*
* @example var outlook = require('node-outlook');
*
* // Set the API endpoint to use the v2.0 endpoint
* outlook.base.setApiEndpoint('https://outlook.office.com/api/v2.0');
*
* // This is the oAuth token
* var token = 'eyJ0eXAiOiJKV1Q...';
*
* // The Id property of the message to retrieve. This could be
* // from a previous call to getMessages
* var msgId = 'AAMkADVhYTYwNzk...';
*
* // Set up oData parameters
* var queryParams = {
* '$select': 'Subject,ReceivedDateTime,From'
* };
*
* // Pass the user's email address
* var userInfo = {
* email: 'sarad@contoso.com'
* };
*
* outlook.mail.getMessage({token: token, messageId: msgId, odataParams: queryParams, user: userInfo},
* function(error, result){
* if (error) {
* console.log('getMessage returned an error: ' + error);
* }
* else if (result) {
* console.log(' Subject:', result.Subject);
* console.log(' Received:', result.ReceivedDateTime.toString());
* console.log(' From:', result.From ? result.From.EmailAddress.Name : 'EMPTY');
* }
* });
*/
getMessage: function(parameters, callback) {
var userSpec = utilities.getUserSegment(parameters);
var requestUrl = base.apiEndpoint() + userSpec + '/Messages/' + parameters.messageId;
var apiOptions = {
url: requestUrl,
token: parameters.token,
user: parameters.user
};
if (parameters.odataParams !== undefined) {
apiOptions['query'] = parameters.odataParams;
}
base.makeApiCall(apiOptions, function(error, response) {
if (error) {
if (typeof callback === 'function') {
callback(error, response);
}
}
else if (response.statusCode !== 200) {
if (typeof callback === 'function') {
callback('REST request returned ' + response.statusCode + '; body: ' + JSON.stringify(response.body), response);
}
}
else {
if (typeof callback === 'function') {
callback(null, response.body);
}
}
});
},
/**
* Create a new message
*
* @param parameters {object} An object containing all of the relevant parameters. Possible values:
* @param parameters.token {string} The access token.
* @param parameters.message {object} The JSON-serializable message
* @param [parameters.useMe] {boolean} If true, use the `/Me` segment instead of the `/Users/<email>` segment. This parameter defaults to false and is ignored if the `parameters.user.email` parameter isn't provided (the `/Me` segment is always used in this case).
* @param [parameters.user.email] {string} The SMTP address of the user. If absent, the `/Me` segment is used in the API URL.
* @param [parameters.user.timezone] {string} The timezone of the user.
* @param [parameters.folderId] {string} The folder id. If absent, the API calls the `/User/Messages` endpoint.
* @param [callback] {function} A callback function that is called when the function completes. It should have the signature `function (error, result)`.
*
* @example var outlook = require('node-outlook');
*
* // Set the API endpoint to use the v2.0 endpoint
* outlook.base.setApiEndpoint('https://outlook.office.com/api/v2.0');
*
* // This is the oAuth token
* var token = 'eyJ0eXAiOiJKV1Q...';
*
* var newMsg = {
* Subject: 'Did you see last night\'s game?',
* Importance: 'Low',
* Body: {
* ContentType: 'HTML',
* Content: 'They were <b>awesome</b>!'
* },
* ToRecipients: [
* {
* EmailAddress: {
* Address: 'azizh@contoso.com'
* }
* }
* ]
* };
*
* // Pass the user's email address
* var userInfo = {
* email: 'sarad@contoso.com'
* };
*
* outlook.mail.createMessage({token: token, message: newMsg, user: userInfo},
* function(error, result){
* if (error) {
* console.log('createMessage returned an error: ' + error);
* }
* else if (result) {
* console.log(JSON.stringify(result, null, 2));
* }
* });
*/
createMessage: function(parameters, callback) {
var userSpec = utilities.getUserSegment(parameters);
var folderSpec = parameters.folderId === undefined ? '' : getFolderSegment() + parameters.folderId;
var requestUrl = base.apiEndpoint() + userSpec + folderSpec + '/Messages';
var apiOptions = {
url: requestUrl,
token: parameters.token,
user: parameters.user,
payload: parameters.message,
method: 'POST'
};
base.makeApiCall(apiOptions, function(error, response) {
if (error) {
if (typeof callback === 'function') {
callback(error, response);
}
}
else if (response.statusCode !== 201) {
if (typeof callback === 'function') {
callback('REST request returned ' + response.statusCode + '; body: ' + JSON.stringify(response.body), response);
}
}
else {
if (typeof callback === 'function') {
callback(null, response.body);
}
}
});
},
/**
* Update a specific message.
*
* @param parameters {object} An object containing all of the relevant parameters. Possible values:
* @param parameters.token {string} The access token.
* @param parameters.messageId {string} The Id of the message.
* @param parameters.update {object} The JSON-serializable update payload
* @param [parameters.useMe] {boolean} If true, use the `/Me` segment instead of the `/Users/<email>` segment. This parameter defaults to false and is ignored if the `parameters.user.email` parameter isn't provided (the `/Me` segment is always used in this case).
* @param [parameters.user.email] {string} The SMTP address of the user. If absent, the `/Me` segment is used in the API URL.
* @param [parameters.user.timezone] {string} The timezone of the user.
* @param [parameters.odataParams] {object} An object containing key/value pairs representing OData query parameters. See [Use OData query parameters]{@link https://msdn.microsoft.com/office/office365/APi/complex-types-for-mail-contacts-calendar#UseODataqueryparameters} for details.
* @param [callback] {function} A callback function that is called when the function completes. It should have the signature `function (error, result)`.
*
* @example var outlook = require('node-outlook');
*
* // Set the API endpoint to use the v2.0 endpoint
* outlook.base.setApiEndpoint('https://outlook.office.com/api/v2.0');
*
* // This is the oAuth token
* var token = 'eyJ0eXAiOiJKV1Q...';
*
* // The Id property of the message to update. This could be
* // from a previous call to getMessages
* var msgId = 'AAMkADVhYTYwNzk...';
*
* // Mark the message unread
* var update = {
* IsRead: false,
* };
*
* // Pass the user's email address
* var userInfo = {
* email: 'sarad@contoso.com'
* };
*
* outlook.mail.updateMessage({token: token, messageId: msgId, update: update, user: userInfo},
* function(error, result){
* if (error) {
* console.log('updateMessage returned an error: ' + error);
* }
* else if (result) {
* console.log(JSON.stringify(result, null, 2));
* }
* });
*/
updateMessage: function(parameters, callback) {
var userSpec = utilities.getUserSegment(parameters);
var requestUrl = base.apiEndpoint() + userSpec + '/Messages/' + parameters.messageId;
var apiOptions = {
url: requestUrl,
token: parameters.token,
user: parameters.user,
payload: parameters.update,
method: 'PATCH'
};
if (parameters.odataParams !== undefined) {
apiOptions['query'] = parameters.odataParams;
}
base.makeApiCall(apiOptions, function(error, response) {
if (error) {
if (typeof callback === 'function') {
callback(error, response);
}
}
else if (response.statusCode !== 200) {
if (typeof callback === 'function') {
callback('REST request returned ' + response.statusCode + '; body: ' + JSON.stringify(response.body), response);
}
}
else {
if (typeof callback === 'function') {
callback(null, response.body);
}
}
});
},
/**
* Delete a specific message.
*
* @param parameters {object} An object containing all of the relevant parameters. Possible values:
* @param parameters.token {string} The access token.
* @param parameters.messageId {string} The Id of the message.
* @param [parameters.useMe] {boolean} If true, use the `/Me` segment instead of the `/Users/<email>` segment. This parameter defaults to false and is ignored if the `parameters.user.email` parameter isn't provided (the `/Me` segment is always used in this case).
* @param [parameters.user.email] {string} The SMTP address of the user. If absent, the `/Me` segment is used in the API URL.
* @param [parameters.user.timezone] {string} The timezone of the user.
* @param [callback] {function} A callback function that is called when the function completes. It should have the signature `function (error, result)`.
*
* @example var outlook = require('node-outlook');
*
* // Set the API endpoint to use the v2.0 endpoint
* outlook.base.setApiEndpoint('https://outlook.office.com/api/v2.0');
*
* // This is the oAuth token
* var token = 'eyJ0eXAiOiJKV1Q...';
*
* // The Id property of the message to delete. This could be
* // from a previous call to getMessages
* var msgId = 'AAMkADVhYTYwNzk...';
*
* // Pass the user's email address
* var userInfo = {
* email: 'sarad@contoso.com'
* };
*
* outlook.mail.deleteMessage({token: token, messageId: msgId, user: userInfo},
* function(error, result){
* if (error) {
* console.log('deleteMessage returned an error: ' + error);
* }
* else if (result) {
* console.log('SUCCESS');
* }
* });
*/
deleteMessage: function(parameters, callback) {
var userSpec = utilities.getUserSegment(parameters);
var requestUrl = base.apiEndpoint() + userSpec + '/Messages/' + parameters.messageId;
var apiOptions = {
url: requestUrl,
token: parameters.token,
user: parameters.user,
method: 'DELETE'
};
if (parameters.odataParams !== undefined) {
apiOptions['query'] = parameters.odataParams;
}
base.makeApiCall(apiOptions, function(error, response) {
if (error) {
if (typeof callback === 'function') {
callback(error, response);
}
}
else if (response.statusCode !== 204) {
if (typeof callback === 'function') {
callback('REST request returned ' + response.statusCode + '; body: ' + JSON.stringify(response.body), response);
}
}
else {
if (typeof callback === 'function') {
callback(null, response.body);
}
}
});
},
/**
* Sends a new message
*
* @param parameters {object} An object containing all of the relevant parameters. Possible values:
* @param parameters.token {string} The access token.
* @param parameters.message {object} The JSON-serializable message
* @param [parameters.saveToSentItems] {boolean} Set to false to bypass saving a copy to the Sent Items folder. Default is true.
* @param [parameters.useMe] {boolean} If true, use the `/Me` segment instead of the `/Users/<email>` segment. This parameter defaults to false and is ignored if the `parameters.user.email` parameter isn't provided (the `/Me` segment is always used in this case).
* @param [parameters.user.email] {string} The SMTP address of the user. If absent, the `/Me` segment is used in the API URL.
* @param [parameters.user.timezone] {string} The timezone of the user.
* @param [callback] {function} A callback function that is called when the function completes. It should have the signature `function (error, result)`.
*
* @example var outlook = require('node-outlook');
*
* // Set the API endpoint to use the v2.0 endpoint
* outlook.base.setApiEndpoint('https://outlook.office.com/api/v2.0');
*
* // This is the oAuth token
* var token = 'eyJ0eXAiOiJKV1Q...';
*
* var newMsg = {
* Subject: 'Did you see last night\'s game?',
* Importance: 'Low',
* Body: {
* ContentType: 'HTML',
* Content: 'They were <b>awesome</b>!'
* },
* ToRecipients: [
* {
* EmailAddress: {
* Address: 'azizh@contoso.com'
* }
* }
* ]
* };
*
* // Pass the user's email address
* var userInfo = {
* email: 'sarad@contoso.com'
* };
*
* outlook.mail.sendNewMessage({token: token, message: newMsg, user: userInfo},
* function(error, result){
* if (error) {
* console.log('sendNewMessage returned an error: ' + error);
* }
* else if (result) {
* console.log(JSON.stringify(result, null, 2));
* }
* });
*/
sendNewMessage: function(parameters, callback) {
var userSpec = utilities.getUserSegment(parameters);
var requestUrl = base.apiEndpoint() + userSpec + '/sendmail';
var payload = {
Message: parameters.message,
SaveToSentItems: parameters.saveToSentItems !== undefined ? parameters.saveToSentItems : 'true'
};
var apiOptions = {
url: requestUrl,
token: parameters.token,
user: parameters.user,
payload: payload,
method: 'POST'
};
base.makeApiCall(apiOptions, function(error, response) {
if (error) {
if (typeof callback === 'function') {
callback(error, response);
}
}
else if (response.statusCode !== 202) {
if (typeof callback === 'function') {
callback('REST request returned ' + response.statusCode + '; body: ' + JSON.stringify(response.body), response);
}
}
else {
if (typeof callback === 'function') {
callback(null, response.body);
}
}
});
},
/**
* Sends a draft message.
*
* @param parameters {object} An object containing all of the relevant parameters. Possible values:
* @param parameters.token {string} The access token.
* @param parameters.messageId {string} The Id of the message.
* @param [parameters.useMe] {boolean} If true, use the `/Me` segment instead of the `/Users/<email>` segment. This parameter defaults to false and is ignored if the `parameters.user.email` parameter isn't provided (the `/Me` segment is always used in this case).
* @param [parameters.user.email] {string} The SMTP address of the user. If absent, the `/Me` segment is used in the API URL.
* @param [parameters.user.timezone] {string} The timezone of the user.
* @param [callback] {function} A callback function that is called when the function completes. It should have the signature `function (error, result)`.
*
* @example var outlook = require('node-outlook');
*
* // Set the API endpoint to use the v2.0 endpoint
* outlook.base.setApiEndpoint('https://outlook.office.com/api/v2.0');
*
* // This is the oAuth token
* var token = 'eyJ0eXAiOiJKV1Q...';
*
* // The Id property of the message to send. This could be
* // from a previous call to getMessages
* var msgId = 'AAMkADVhYTYwNzk...';
*
* // Pass the user's email address
* var userInfo = {
* email: 'sarad@contoso.com'
* };
*
* outlook.mail.sendDraftMessage({token: token, messageId: msgId, user: userInfo},
* function(error, result){
* if (error) {
* console.log('sendDraftMessage returned an error: ' + error);
* }
* else if (result) {
* console.log('SUCCESS');
* }
* });
*/
sendDraftMessage: function(parameters, callback) {
var userSpec = utilities.getUserSegment(parameters);
var requestUrl = base.apiEndpoint() + userSpec + '/Messages/' + parameters.messageId + '/send';
var apiOptions = {
url: requestUrl,
token: parameters.token,
user: parameters.user,
method: 'POST'
};
base.makeApiCall(apiOptions, function(error, response) {
if (error) {
if (typeof callback === 'function') {
callback(error, response);
}
}
else if (response.statusCode !== 202) {
if (typeof callback === 'function') {
callback('REST request returned ' + response.statusCode + '; body: ' + JSON.stringify(response.body), response);
}
}
else {
if (typeof callback === 'function') {
callback(null, response.body);
}
}
});
},
};
/**
* Helper function to return the correct name for the folders segment
* of the request URL. /Me/Folders became /Me/MailFolders in the beta and
* 2.0 endpoints.
* @private
*/
var getFolderSegment = function() {
if (base.apiEndpoint().toLowerCase().indexOf('/api/v1.0') > 0){
return '/Folders/';
}
return '/MailFolders/'
}
/*

@@ -63,0 +595,0 @@ MIT License:

{
"name": "node-outlook",
"version": "1.1.4",
"version": "1.1.5",
"description": "A package for calling the Outlook APIs from Node.",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "echo \"Error: no test specified\" && exit 1",
"docs": "jsdoc2md version-2.js mail-api.js calendar-api.js contacts-api.js > ./reference/node-outlook.md"
},

@@ -30,3 +31,6 @@ "keywords": [

},
"homepage": "https://github.com/jasonjoh/node-outlook"
"homepage": "https://github.com/jasonjoh/node-outlook",
"devDependencies": {
"jsdoc-to-markdown": "^1.3.3"
}
}

@@ -28,2 +28,4 @@ # Node.js Wrapper for Office 365 APIs Client Library #

The new interface is documented in a simple [reference](reference/node-outlook.md) (courtesy of [jsdoc-to-markdown](https://github.com/jsdoc2md/jsdoc-to-markdown)).
#### Configuration ####

@@ -97,2 +99,2 @@

Follow the [Exchange Dev Blog](http://blogs.msdn.com/b/exchangedev/)
Follow the [Outlook Dev Blog](http://blogs.msdn.com/b/exchangedev/)

@@ -8,5 +8,9 @@ // Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license at the bottom of this file.

var endpoint = 'https://outlook.office.com/api/v1.0';
var anchor = '';
var timeZone = '';
var defaultAnchor = '';
var defaultTimeZone = '';
/**
* @module base
*/
module.exports = {

@@ -19,7 +23,9 @@ /**

* @param parameters.token {string} The access token for authentication
* @param [parameters.user.email] {string} The user's SMTP email address, used to set the `X-AnchorMailbox` header.
* @param [parameters.user.timezone] {string} The user's time zone, used to set the `outlook.timezone` `Prefer` header.
* @param [parameters.method] {string} Used to specify the HTTP method. Default is 'GET'.
* @param [parameters.query] {object} An object containing key/value pairs. The pairs will be serialized into a query string.
* @param [parameters.payload] {object}: A JSON-serializable object representing the request body.
* @param [parameters.headers] {object}: A JSON-serializable object representing custom headers to send with the request.
* @param [callback] {function}: A callback function that is called when the function completes. It should have the signature `function (error, result)`.
* @param [parameters.payload] {object} A JSON-serializable object representing the request body.
* @param [parameters.headers] {object} A JSON-serializable object representing custom headers to send with the request.
* @param [callback] {function} A callback function that is called when the function completes. It should have the signature `function (error, result)`.
*/

@@ -51,8 +57,30 @@ makeApiCall: function (parameters, callback) {

headers['return-client-request-id'] = headers['return-client-request-id'] || 'true';
if (anchor.length > 0) {
headers['X-Anchor-Mailbox'] = anchor;
// Determine if we have an anchor mailbox to use
// Passed parameter has greater priority than module-level default
var anchorMbx = '';
if (parameters.user && parameters.user.email && parameters.user.email.length > 0) {
anchorMbx = parameters.user.email;
}
if (timeZone.length > 0) {
else {
anchorMbx = defaultAnchor;
}
if (anchorMbx.length > 0) {
headers['X-Anchor-Mailbox'] = anchorMbx;
}
// Determine if we have a time zone to use
// Passed parameter has greater priority than module-level default
var timezone = '';
if (parameters.user && parameters.user.timezone && parameters.user.timezone.length > 0) {
timezone = parameters.user.timezone;
}
else {
timezone = defaultTimeZone;
}
if (timezone.length > 0) {
headers['Prefer'] = headers['Prefer'] || [];
headers['Prefer'].push('outlook.timezone = "' + timeZone + '"');
headers['Prefer'].push('outlook.timezone = "' + timezone + '"');
}

@@ -104,3 +132,3 @@

*
* @param enabled {boolean}: `true` to enable default Fiddler proxy and disable SSL verification. `false` to disable proxy and enable SSL verification.
* @param enabled {boolean} `true` to enable default Fiddler proxy and disable SSL verification. `false` to disable proxy and enable SSL verification.
*/

@@ -120,3 +148,3 @@ setFiddlerEnabled: function(enabled) {

/**
* Sets the API endpoint URL. If not called, the default of `https://outlook.office.com/api/v2.0` is used.
* Sets the API endpoint URL. If not called, the default of `https://outlook.office.com/api/v1.0` is used.
*

@@ -130,11 +158,11 @@ * @param newEndPoint {string} The API endpoint URL to use.

/**
* Gets the anchor mailbox address.
* Gets the default anchor mailbox address.
* @return {string}
*/
anchorMailbox: function() {
return anchor;
return defaultAnchor;
},
/**
* Sets the anchor mailbox address.
* Sets the default anchor mailbox address.
*

@@ -144,15 +172,15 @@ * @param newAnchor {string} The SMTP address to send in the `X-Anchor-Mailbox` header.

setAnchorMailbox: function(newAnchor) {
anchor = newAnchor;
defaultAnchor = newAnchor;
},
/**
* Gets the preferred time zone.
* Gets the default preferred time zone.
* @return {string}
*/
preferredTimeZone: function() {
return timeZone;
return defaultTimeZone;
},
/**
* Sets the preferred time zone.
* Sets the default preferred time zone.
*

@@ -162,6 +190,9 @@ * @param preferredTimeZone {string} The time zone in which the server should return date time values.

setPreferredTimeZone: function(preferredTimeZone) {
timeZone = preferredTimeZone;
defaultTimeZone = preferredTimeZone;
}
};
/**
* @private
*/
function trace(message) {

@@ -168,0 +199,0 @@ if (typeof traceFunction === 'function') {