   * );
   ###
 
-  getCalendar: (id, onSuccess, onError) ->
-    @sendRequest('/calendars/' + id + '/', 'GET', 0, onSuccess, onError)
+  getCalendar: (id) ->
+    action = (resolve, reject) -> @sendRequest('/calendars/' + id + '/', 'GET', 0, resolve, reject)
+    new Promise(action.bind(@))
 
   ###*
   * Callback, returns particular calendar including its name and id. TODO: return custom fields here.

  * );
  ###

  addCalendar: (name, onSuccess, onError) ->
    @sendRequest('/calendars/', 'POST', {name: name}, onSuccess, onError)

  ###*
  * Callback function, executed when calendar successfully added.

  * );
  ###

  addEvent: (calendarId, event) ->
    action = (resolve, reject) -> @sendRequest('/calendars/' + calendarId + '/events/', 'POST', event, resolve, reject)
    new Promise(action.bind(@))

  addEvents: (calendarId, events) ->
    action = (resolve, reject) ->
      numEvents = events.length
      count = 0
      i = 0
      while i < numEvents
        @addEvent(calendarId, events[i])
        .then (args) ->
          count++
          if count >= numEvents
            resolve()
        , (err) ->
          count++
          if count >= numEvents
            reject()
        i++
      return
    new Promise(action.bind(@))

  ###*
  * Callback, executed when event added successfully.
