viewpoint v0.2.0
node-viewpoint
the exchange API for nodejs module
Install
$ npm install --save viewpointUsage
var EWSClient = require('viewpoint');
var client = new EWSClient(username, password, ewsUrl, config);
client.syncFolders().then(function(res) {
console.log('sync folders successfully!');
});More examples can refer to examples/ in the source repo.
API
Many API function return the Promise object. For simplicity, I will use Promise(ObjectType) to represent the Promise object that return the ObjectType object. e.g. for function foo that return Promise(Number), you can invoke it with
foo().then(number) {}.
EWSClient
Methods
constructor:
function(username, password, url, options).Constructor functiongetFolder:
function(folderId, opts).Get the specific folder by folderIdfolderId:
StringorObject.ThefolderIdcan be like or {id: , changeKey: }. If you need distinguished id, then you should makefolderIdlike {id: , type: 'distinguished'}return:
Promise(Folder).TheFolderobject
getFolders:
function(folderIds, opts).Get folders by folderIds arrayfolderIds
Array.The array of folderId used to get a list of folderreturn:
Promise(Array).Each item isFolder.
findFolders:
function(opts).Get the folders by theopts- return:
Promise(RootFolder)
- return:
createFolders:
function(names, opts).Create the folders by the names- return:
Promise(Array).Each item isFolder.
- return:
moveFolders:
function(folderIds, opts).Move the folders that the id is in thefolderIds.- return:
Promise(Array).Each item isFolder.
- return:
syncFolders:
function(opts).Synchronize the foldersopts:
Object.syncState:
String.It represent the folders synchronization state.folderShape:
Object.The option represent what to return from server. It can like{baseShape: 'Default', additionalProperties: 'item:ParentFolderId'.
return:
Promise(EWSSyncResponse).
syncFoldersWithParent:
function(syncState).Synchronize the folders just likesyncFoldersbut also theparentFolderIdvariable will return.- return:
Promise(EWSSyncResponse).
- return:
getItem:
function(itemId, opts).Get the message by theitemId.itemId:
StringorObject.The item id is like{id: <id>}or<id>.return:
Promise(Item)orPromise(Message).
getItems:
function(itemIds).Get the messages by itemIds.itemIds:
Array.Each item isStringorObject.return:
Promise(Array).Each item isMessage.
findItems:
function(opts).Get the information of items that match the opts.deleteItems:
function(items).Delete the specific items.moveItems:
function(items, folder).Move the items to the destination folder.- folder:
StringorObject.The destination folder id.
- folder:
copyItems:
function(items, folder).Copy the items to the destination folder.saveItems:
function(opts).Save items in the specific folder.sendItems:
function(opts).Send items to destination mailbox.sendAndSaveItems:
function(opts).Send items to destination mailbox and save to the specific folder.markRead:
function(items).Mark the items to have read.- items:
ArrayorObject. The Array of itemid or itemid.
- items:
Folder
Methods
totalCount:
function().The total count of items- return:
Number
- return:
childFolderCount:
function().The count of child folders- return:
Number
- return:
unreadCount:
function().The count of unread items- return:
Number
- return:
folderClass:
function().The folder class such as 'IPF'- return:
String
- return:
displayName:
function().The display name- return:
String
- return:
folderId:
function().Get folder id object- return:
Object
- return:
parentFolderId:
function().Get parent folder id object- return:
Object
- return:
RootFolder
Methods
totalItemsInView:
function().Get the count of return items.- return:
Number.
- return:
includesLastItemInRange:
function().Get whether or not the last item is included.- return:
Bool
- return:
items:
function().Get the items of folder.- return:
Array.TheArrayofMessage.
- return:
folders:
function().Get the child folders of this folder.- return:
Array.TheArrayofFolder.
- return:
EWSSyncResponse
Methods
syncState:
function().Get the current synchronization state.- return:
String.
- return:
includesLastItemInRange:
function().Get whether the items include the last item.- return:
Bool
- return:
creates:
function().Get the created items.- return:
Array.Each item isMessage.
- return:
updates:
function().Get the updated items.- return:
Array.Each item isMessage.
- return:
deletes:
function().Get the deleted items.- return:
Array.Each item isMessagethat be deleted.
- return:
Contributing
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using gulp.
License
Copyright (c) 2015 liuxiong. Licensed under the MIT license.
