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

node-outlook

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

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.5 to 1.1.6

98

mail-api.js

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

* @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)`.

@@ -66,3 +65,3 @@ *

*/
getMessages: function(parameters, callback){
getMessages: function(parameters, callback) {
var userSpec = utilities.getUserSegment(parameters);

@@ -576,2 +575,97 @@ var folderSpec = parameters.folderId === undefined ? '' : getFolderSegment() + parameters.folderId;

},
/**
* Syncs messages in a folder.
*
* @param parameters {object} An object containing all of the relevant parameters. Possible values:
* @param parameters.token {string} The access token.
* @param [parameters.pageSize] {Number} The maximum number of results to return in each call. Defaults to 50.
* @param [parameters.skipToken] {string} The value to pass in the `skipToken` query parameter in the API call.
* @param [parameters.deltaToken] {string} The value to pass in the `deltaToken` query parameter in the API call.
* @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:
*
* - The `Id` property of a `MailFolder` entity
* - `Inbox`
* - `Drafts`
* - `SentItems`
* - `DeletedItems`
*
* @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 beta endpoint
* outlook.base.setApiEndpoint('https://outlook.office.com/api/beta');
*
* // This is the oAuth token
* var token = 'eyJ0eXAiOiJKV1Q...';
*
* // 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');
* }
* });
*/
syncMessages: function(parameters, callback) {
var userSpec = utilities.getUserSegment(parameters);
var folderSpec = parameters.folderId === undefined ? '' : getFolderSegment() + parameters.folderId;
var requestUrl = base.apiEndpoint() + userSpec + folderSpec + '/Messages';
var query = parameters.odataParams || {};
if (parameters.skipToken) {
query['$skiptoken'] = parameters.skipToken;
}
if (parameters.deltaToken) {
query['$deltatoken'] = parameters.deltaToken;
}
var headers = {
Prefer: [
'odata.track-changes',
'odata.maxpagesize=' + (parameters.pageSize === undefined ? '50' : parameters.pageSize.toString())
]
};
var apiOptions = {
url: requestUrl,
token: parameters.token,
user: parameters.user,
query: query,
headers: headers
};
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);
}
}
});
}
};

@@ -578,0 +672,0 @@

4

package.json
{
"name": "node-outlook",
"version": "1.1.5",
"version": "1.1.6",
"description": "A package for calling the Outlook APIs from Node.",

@@ -8,3 +8,3 @@ "main": "index.js",

"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"
"builddocs": "jsdoc2md version-2.js mail-api.js calendar-api.js contacts-api.js > ./reference/node-outlook.md"
},

@@ -11,0 +11,0 @@ "keywords": [

@@ -19,2 +19,3 @@ ## Modules

* [.makeApiCall(parameters, [callback])](#module_base.makeApiCall)
* [.getUser(parameters, [callback])](#module_base.getUser)
* [.setTraceFunc(traceFunc)](#module_base.setTraceFunc)

@@ -48,2 +49,21 @@ * [.setFiddlerEnabled(enabled)](#module_base.setFiddlerEnabled)

<a name="module_base.getUser"></a>
### base.getUser(parameters, [callback])
Used to get information about a user.
**Kind**: static method of <code>[base](#module_base)</code>
| Param | Type | Description |
| --- | --- | --- |
| parameters | <code>object</code> | An object containing all of the relevant parameters. Possible values: |
| parameters.token | <code>string</code> | The access token. |
| [parameters.useMe] | <code>boolean</code> | 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). |
| [parameters.user.email] | <code>string</code> | The SMTP address of the user. If absent, the `/Me` segment is used in the API URL. |
| [parameters.odataParams] | <code>object</code> | An object containing key/value pairs representing OData query parameters. See [Use OData query parameters](https://msdn.microsoft.com/office/office365/APi/complex-types-for-mail-contacts-calendar#UseODataqueryparameters) for details. |
| [callback] | <code>function</code> | A callback function that is called when the function completes. It should have the signature `function (error, result)`. |
**Example**
```js
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': 'DisplayName, EmailAddress', }; outlook.base.getUser({token: token, odataParams: queryParams}, function(error, result) { if (error) { console.log('getUser returned an error: ' + error); } else if (result) { console.log('User name:', result.DisplayName); console.log('User email:', result.EmailAddress); } });
```
<a name="module_base.setTraceFunc"></a>

@@ -125,2 +145,3 @@ ### base.setTraceFunc(traceFunc)

* [.sendDraftMessage(parameters, [callback])](#module_mail.sendDraftMessage)
* [.syncMessages(parameters, [callback])](#module_mail.syncMessages)

@@ -273,2 +294,26 @@ <a name="module_mail.getMessages"></a>

```
<a name="module_mail.syncMessages"></a>
### mail.syncMessages(parameters, [callback])
Syncs messages in a folder.
**Kind**: static method of <code>[mail](#module_mail)</code>
| Param | Type | Description |
| --- | --- | --- |
| parameters | <code>object</code> | An object containing all of the relevant parameters. Possible values: |
| parameters.token | <code>string</code> | The access token. |
| [parameters.pageSize] | <code>Number</code> | The maximum number of results to return in each call. Defaults to 50. |
| [parameters.skipToken] | <code>string</code> | The value to pass in the `skipToken` query parameter in the API call. |
| [parameters.deltaToken] | <code>string</code> | The value to pass in the `deltaToken` query parameter in the API call. |
| [parameters.useMe] | <code>boolean</code> | 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). |
| [parameters.user.email] | <code>string</code> | The SMTP address of the user. If absent, the `/Me` segment is used in the API URL. |
| [parameters.user.timezone] | <code>string</code> | The timezone of the user. |
| [parameters.folderId] | <code>string</code> | The folder id. If absent, the API calls the `/User/Messages` endpoint. Valid values of this parameter are: - The `Id` property of a `MailFolder` entity - `Inbox` - `Drafts` - `SentItems` - `DeletedItems` |
| [parameters.odataParams] | <code>object</code> | An object containing key/value pairs representing OData query parameters. See [Use OData query parameters](https://msdn.microsoft.com/office/office365/APi/complex-types-for-mail-contacts-calendar#UseODataqueryparameters) for details. |
| [callback] | <code>function</code> | A callback function that is called when the function completes. It should have the signature `function (error, result)`. |
**Example**
```js
var outlook = require('node-outlook'); // Set the API endpoint to use the beta endpoint outlook.base.setApiEndpoint('https://outlook.office.com/api/beta'); // This is the oAuth token var token = 'eyJ0eXAiOiJKV1Q...'; // 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'); } });
```
<a name="module_calendar"></a>

@@ -275,0 +320,0 @@ ## calendar

// Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license at the bottom of this file.
var request = require('request');
var uuid = require('node-uuid');
var utilities = require('./utilities.js');

@@ -116,2 +117,70 @@ var fiddlerEnabled = false;

},
/**
* Used to get information about a user.
*
* @param parameters {object} An object containing all of the relevant parameters. Possible values:
* @param parameters.token {string} The access token.
* @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.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': 'DisplayName, EmailAddress',
* };
*
* outlook.base.getUser({token: token, odataParams: queryParams},
* function(error, result) {
* if (error) {
* console.log('getUser returned an error: ' + error);
* }
* else if (result) {
* console.log('User name:', result.DisplayName);
* console.log('User email:', result.EmailAddress);
* }
* });
*/
getUser: function(parameters, callback) {
var userSpec = utilities.getUserSegment(parameters);
var requestUrl = this.apiEndpoint() + userSpec;
var apiOptions = {
url: requestUrl,
token: parameters.token,
user: parameters.user
};
if (parameters.odataParams !== undefined) {
apiOptions['query'] = parameters.odataParams;
}
this.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);
}
}
});
},

@@ -118,0 +187,0 @@ /**

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc