Skip to content
  • Watch
  • Fork

/dav

HTTPS clone URL

SSH clone URL

Subversion checkout URL

You can clone with HTTPS, SSH, or Subversion.

Download ZIP

Loading…

Simplify lower-level WebDAV api #50

Open
gaye opened this Issue · 1 comment

2 participants

@gaye
Owner

Right now using the WebDAV bits looks like

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'
  }
);

var req = dav.request.basic({
  method: 'PUT',
  data: 'BEGIN:VCALENDAR\nEND:VCALENDAR',
  etag: '12345'
});

// req instanceof dav.Request

client.send(req, { url: '/calendars/123.ics' })
.then(function(response) {
  // response instanceof XMLHttpRequest
});

This is quite verbose and I think there's room for some cleanup.

@millermedeiros

if you remove the unnecessary constructors it gets a little bit simpler:

var dav = require('dav');

// use `dav.transport.Basic` by default if single argument & no `send()` method
var client = new dav.Client({
  baseUrl: 'https://mail.mozilla.com',
  credentials: {
    username: 'xxx',
    password: 'xxx'
  }
});

var req = {
  method: 'PUT',
  data: 'BEGIN:VCALENDAR\nEND:VCALENDAR',
  etag: '12345'
};
client.send(req, '/calendars/123.ics').then(response => {
  // response instanceof XMLHttpRequest
});

see: #70, #71

@mcepl

Attach images by dragging & dropping or selecting them. Uploading your images… Unfortunately, we don't support that file type. Try again with a PNG, GIF, or JPG. Yowza, that's a big file. Try again with an image file smaller than 10MB. This file is empty. Try again with a file that's not empty. This browser doesn't support image attachments. We recommend updating to the latest Internet Explorer, Google Chrome, or Firefox. Something went really wrong, and we can't process that image. Try again.

Nothing to preview

Something went wrong with that request. Please try again.