var http = require('http'),
    sys = require('sys'),
    querystring = require('querystring'),
    API_URI = 'http://api.dropbox.com/',
    CONTENT_API_URI = 'https://api-content.dropbox.com/',
    API_VERSION = '0';

// Returns a Dropbox Client, through which API calls can be made.
var DropboxClient = exports.DropboxClient =
  function(oauth, access_token, access_token_secret) {
    this.oauth = oauth;
    this.access_token = access_token;
    this.access_token_secret = access_token_secret;
  }

// Retrieves information about the user's account as a JSON response.
DropboxClient.prototype.getAccountInfo = function(optargs, callback) {
  if (typeof optargs == 'function')
    callback = optargs, optargs = {};
  this.oauth.get(API_URI + API_VERSION + '/account/info/' +
                 (optargs.status_in_response ? '?status_in_response=' +
                  optargs.status_in_response : ''),
                 this.access_token, this.access_token_secret,
                 function(err, data, res) {
                   if (err) callback(err);
                   else callback(null, JSON.parse(data));
                 });
}

// Retrieves contents of a file specified by path argument, relative to
// user's Dropbox root.
DropboxClient.prototype.getFile = function(path, callback) {
  this.oauth.get(CONTENT_API_URI + API_VERSION + '/files/dropbox/' + path,
                 this.access_token, this.access_token_secret,
                 function(err, data, res) {
                   callback(err, data);
                 });
}

// Uploads contents of a file specified by path argument, relative to
// application's directory.
DropboxClient.prototype.putFile = function(file, path, callback) {
  var boundary = 'sAxIqse3tPlHqUIUI9ofVlHvtdt3tpaG',
      content_type = 'multipart/form-data; boundary=' + boundary,
      file_contents = require('fs').readFileSync(file);
  
  // Build request body.
  var body = '--' + boundary + '\r\n' +
    'Content-Disposition: form-data; name=file; filename=' + file + '\r\n' +
    'Content-type: application/octet-stream\r\n' +
    '\r\n' + file_contents + '\r\n' +
    '--' + boundary + '--';
  this.oauth.post(CONTENT_API_URI + API_VERSION + '/files/dropbox/' + path +
                  '?file=' + file,
                  this.access_token, this.access_token_secret,
                  body, content_type,
                  function(err, data, res) {
                    callback(err, JSON.parse(data));
                  });
}

// Gets metadata of file/folder specified by path relative to user's
// Dropbox root.
DropboxClient.prototype.getMetadata = function(path, optargs, callback) {
  if (typeof optargs == 'function')
    callback = optargs, optargs = null;
  this.oauth.get(API_URI + API_VERSION + '/metadata/dropbox/' + path +
                 (optargs ? '?' + querystring.stringify(optargs) : ''),
                 this.access_token, this.access_token_secret,
                 function(err, data, res) {
                   if (err) callback(err);
                   else callback(err, JSON.parse(data));
                 });
}

// Downloads a minimized jpeg thumbnail for a photo. See
// https://www.dropbox.com/developers/docs#thumbnails for a list of
// valid size specifiers.
DropboxClient.prototype.getThumbnail = function(path, size, callback) {
  if (typeof(size) == 'function') callback = size, size = null;
  this.oauth.get(CONTENT_API_URI + API_VERSION + '/thumbnails/dropbox/' +
                 path + ((size) ? '?size=' + size : ''),
                 this.access_token, this.access_token_secret,
                 function(err, data, res) {
                   callback(err, data);
                 });
}

// Copies a file or folder to a new location.
// See https://www.dropbox.com/developers/docs#fileops-copy for explanation
// of arguments.
DropboxClient.prototype.copy = function(from_path, to_path, callback) {
  this.oauth.get(API_URI + API_VERSION + '/fileops/copy?from_path=' +
                 from_path + '&root=dropbox&to_path=' + to_path,
                 this.access_token, this.access_token_secret,
                 function(err, data, res) {
                   callback(err, JSON.parse(data));
                 });
}

// Creates a folder relative to the user's Dropbox root.
// See https://www.dropbox.com/developers/docs#fileops-create-folder
// for explanation of arguments.
DropboxClient.prototype.createFolder = function(path, callback) {
  this.oauth.get(API_URI + API_VERSION + '/fileops/create_folder?path='
                 + path +'&root=dropbox',
                 this.access_token, this.access_token_secret,
                 function(err, data, res) {
                   callback(err, JSON.parse(data));
                 });
}

// Deletes a file or folder.
// See https://www.dropbox.com/developers/docs#fileops-delete for
// explanation of arguments.
DropboxClient.prototype.deleteItem = function(path, callback) {
  this.oauth.get(API_URI + API_VERSION + '/fileops/delete?path=' +
                 path + '&root=dropbox',
                 this.access_token, this.access_token_secret,
                 function(err, data, res) {
                   callback(err, JSON.parse(data));
                 });
}

// Moves a file or folder.
// See https://www.dropbox.com/developers/docs#fileops-move for
// explanation of arguments.
DropboxClient.prototype.move = function(from_path, to_path, callback) {
  this.oauth.get(API_URI + API_VERSION + '/fileops/move?from_path=' +
                 from_path + '&root=dropbox&to_path=' + to_path,
                 this.access_token, this.access_token_secret,
                 function(err, data, res) {
                   callback(err, JSON.parse(data));
                 });
}
@@ -3280,20 +3280,23 @@
 n(path, 
-size
+optargs
 , callba
@@ -3313,22 +3313,24 @@
  (typeof
-(size)
+ optargs
  == 'fun
@@ -3336,16 +3336,20 @@
 nction')
+%0A   
  callbac
@@ -3356,18 +3356,24 @@
 k = 
-size, size
+optargs, optargs
  = n
@@ -3446,24 +3446,29 @@
 /dropbox/' +
+ path
 %0A           
@@ -3477,40 +3477,57 @@
     
-path + ((size) ? '?size=' + size
++ (optargs ? '?' + querystring.stringify(optargs)
  : '

Add support for optargs to getThumbnail.