Fetch changes from the remote server to the parameter calendar. Returns a Promise which will be fulfilled with an updated dav.Calendar object once sync is complete.
` @param {dav.Calendar} calendar the calendar to fetch changes for.
Options:
(Array.`
#### dav.syncCaldavAccount(account, options)
Fetch changes from the remote server to the account's calendars. Returns a Promise which will be fulfilled with an updated dav.Account object once sync is complete.
` @param {dav.Account} account the calendar account to sync.
Fetch changes from the remote server to the parameter address books. Returns a Promise which will be fulfilled with an updated dav.AddressBook object once sync is complete.
` @param {dav.AddressBook} addressBook the address book to fetch changes for.
Options:
(dav.Sandbox) sandbox - optional request sandbox.
(String) syncMethod - either 'basic' or 'webdav'. If unspecified, will
try to do webdav sync and failover to basic sync if rfc 6578 is not
supported by the server.
(dav.Transport) xhr - request sender.
` #### dav.syncCarddavAccount(account, options)
Fetch changes from the remote server to the account's address books. Returns a Promise which will be fulfilled with an updated dav.Account object once sync is complete.
` @param {dav.Account} account the address book account to sync.
Create a request sandbox. There is also a deprecated interface
dav.createSandbox(). Add requests to the sandbox like so:
`js
var sandbox = new dav.Sandbox();
// sandbox instanceof Sandbox
dav.createAccount({
username: 'Yoshi',
password: 'babybowsersoscaryomg',
server: 'https://caldav.yoshisstory.com',
sandbox: sandbox // <- Insert sandbox here!
})
.then(function(calendars) {
// etc, etc.
});
` And abort sandboxed requests as a group with sandbox.abort().
$3
#### dav.transport.Basic(credentials)
Create a new dav.transport.Basic object. This sends dav requests using http basic authentication.
` @param {dav.Credentials} credentials user authorization.
`
##### dav.transport.Basic.send(request, options)
` @param {dav.Request} request object with request info.
@return {Promise} a promise that will be resolved with an xhr request after its readyState is 4 or the result of applying an optional request transformResponse function to the xhr object after its readyState is 4.
Create a new dav.transport.OAuth2 object. This sends dav requests authorized via rfc 6749 oauth2.
` @param {dav.Credentials} credentials user authorization.
`
##### dav.transport.OAuth2.send(request, options)
` @param {dav.Request} request object with request info.
@return {Promise} a promise that will be resolved with an xhr request after its readyState is 4 or the result of applying an optional request transformResponse function to the xhr object after its readyState is 4.
(String) depth - optional value for Depth header.
(Array.`
#### dav.request.basic(options)
` Options:
(String) data - put request body.
(String) method - http method.
(String) etag - cached calendar object etag.
`
#### dav.request.calendarQuery(options)
` Options:
(String) depth - optional value for Depth header.
(Array.`
#### dav.request.propfind(options)
` Options:
(String) depth - optional value for Depth header.
(Array.) props - list of props to request.
`
#### dav.request.syncCollection(options)
` Options:
(String) depth - option value for Depth header.
(Array.) props - list of props to request.
(Number) syncLevel - indicates scope of the sync report request.
(String) syncToken - synchronization token provided by the server.
`
$3
#### dav.Client(xhr, options)
Create a new dav.Client object. The client interface allows consumers to set their credentials and transport once and then make authorized requests without passing them to each request. Each of the other, public API methods should be available on dav.Client objects.
Send a request using this client's transport (and perhaps baseUrl).
` @param {dav.request.Request} req - dav request.
@return {Promise} a promise that will be resolved with an xhr request after its readyState is 4 or the result of applying an optional request transformResponse function to the xhr object after its readyState is 4.
var client = new dav.Client(xhr);
// No transport arg
client.createAccount({
server: 'http://dav.example.com',
accountType: 'carddav'
})
.then(function(account) {
account.addressBooks.forEach(function(addressBook) {
console.log('Found address book name ' + addressBook.displayName);
// etc.
});
});
`
#### Using the lower-level webdav request api
_Caution_: The lower-level request api is undergoing some _major_ reworking with frequent changes which will break consumers upgrading from earlier versions. If you're looking for a stable api and can live with the higher-level CalDAV and/or CardDAV abstractions, I _strongly_ recommend those since that api is largely stable.
` var dav = require('dav');
var client = new dav.Client(
new dav.transport.Basic(
new dav.Credentials({
username: 'xxx',
password: 'xxx'
})
),
{
baseUrl: 'https://mail.mozilla.com'
}
);
As of version 1.8.0, dav can tell you a lot of potentially useful things if you set the DEBUG environment variable to dav:*.
You might filter them by setting DEBUG=dav:contacts, DEBUG=dav:xmlhttprequest`, etc.