/* global console, MashupPlatform, moment */

var CalendarAPI = (function () {
    "use strict";

    var url =  "http://130.206.113.159:8085/api/v1";

    /*****************************************************************
    *                     C O N S T R U C T O R                      *
    *****************************************************************/

    function CalendarAPI () {
      
    }

    /******************************************************************/
    /*                P R I V A T E   F U N C T I O N S               */
    /******************************************************************/
    function getAllEvents(success, error) {
        MashupPlatform.http.makeRequest(url + "/events", {
        method: 'GET',
        requestHeaders: {
        "X-FI-WARE-OAuth-Token": "true",
        "X-FI-WARE-OAuth-Header-Name": "X-Auth-Token"	
        },
        onSuccess: success,
        onError: error
      });
    }
    
    function addEvent(event, success, error) {
        MashupPlatform.http.makeRequest(url + "/events", {
        method: 'POST',
        contentType: "application/json",
        requestHeaders: {
        "X-FI-WARE-OAuth-Token": "true",
        "X-FI-WARE-OAuth-Header-Name": "X-Auth-Token"	
        },
        postBody: JSON.stringify(event),
        onSuccess: success,
        onError: error
      });
    }
    
    function deleteEvent(event, success, error) {
        MashupPlatform.http.makeRequest(url + "/events/" + event.uid, {
        method: 'DELETE',
        requestHeaders: {
        "X-FI-WARE-OAuth-Token": "true",
        "X-FI-WARE-OAuth-Header-Name": "X-Auth-Token"	
        },
        onSuccess: success,
        onError: error
      });
    }
    
    function test(event, success, error) {
        MashupPlatform.http.makeRequest(url, {
        method: 'GET',
        requestHeaders: {
        "X-FI-WARE-OAuth-Token": "true",
        "X-FI-WARE-OAuth-Header-Name": "X-Auth-Token"	
        },
        onSuccess: success,
        onError: error
      });
    }

    /******************************************************************/
    /*                 P U B L I C   F U N C T I O N S                */
    /******************************************************************/

    CalendarAPI.prototype = {
        getAllEvents: function (success, error) {
          getAllEvents(success, error);
        },
        addEvent: function (event, success, error) {
          addEvent(event, success, error);
        },
        deleteEvent: function (event, success, error) {
          deleteEvent(event, success, error);
        },
        test: function (success, error) {
          test(success, error);
        }
    };

    return CalendarAPI;
})();
@@ -664,34 +664,32 @@
  error) %7B%0A      
-  
 MashupPlatform.h
@@ -772,32 +772,34 @@
 ders: %7B%0A        
+  
 %22X-FI-WARE-OAuth
@@ -807,32 +807,34 @@
 Token%22: %22true%22,%0A
+  
         %22X-FI-WA
@@ -994,32 +994,74 @@
 ccess, error) %7B%0A
+      console.log(JSON.stringify(event));%0A
         MashupPl
@@ -1194,32 +1194,34 @@
 ders: %7B%0A        
+  
 %22X-FI-WARE-OAuth
@@ -1229,32 +1229,34 @@
 Token%22: %22true%22,%0A
+  
         %22X-FI-WA
@@ -1466,34 +1466,32 @@
  error) %7B%0A      
-  
 MashupPlatform.h
@@ -1814,26 +1814,24 @@
 or) %7B%0A      
-  
 MashupPlatfo
@@ -1906,32 +1906,34 @@
 ders: %7B%0A        
+  
 %22X-FI-WARE-OAuth
@@ -1941,32 +1941,34 @@
 Token%22: %22true%22,%0A
+  
         %22X-FI-WA
@@ -2079,24 +2079,540 @@
    %7D);%0A    %7D
+%0A    %0A    function createEventObject(uid, description, summary, location, dtstart, dtend, dtstamp) %7B%0A      var event = %7B%7D;%0A      if (uid !== null) event.uid = uid;%0A      if (description !== null) event.description = description;%0A      if (summary !== null) event.summary = summary;%0A      if (location !== null) event.location = location;%0A      if (dtstart !== null) event.dtstart = dtstart;%0A      if (dtend !== null) event.dtend = dtend;%0A      if (dtstamp !== null) event.dtstamp = dtstamp;%0A      return event;%0A    %7D
 %0A%0A    /*****
@@ -2853,26 +2853,24 @@
 e = %7B%0A      
-  
 getAllEvents
@@ -2903,26 +2903,24 @@
 ) %7B%0A        
-  
 getAllEvents
@@ -2935,34 +2935,32 @@
 , error);%0A      
-  
 %7D,%0A        addEv
@@ -2948,26 +2948,24 @@
    %7D,%0A      
- 
- 
 addEvent: fu
@@ -3001,26 +3001,24 @@
 ) %7B%0A        
-  
 addEvent(eve
@@ -3030,34 +3030,32 @@
 uccess, error);%0A
-  
       %7D,%0A       
@@ -3049,26 +3049,24 @@
    %7D,%0A      
-  
 deleteEvent:
@@ -3093,34 +3093,32 @@
 ccess, error) %7B%0A
-  
         deleteEv
@@ -3147,31 +3147,27 @@
 ror);%0A      
-  
 %7D,%0A
-  
       test: 
@@ -3198,26 +3198,24 @@
 ) %7B%0A        
-  
 test(success
@@ -3220,26 +3220,24 @@
 ss, error);%0A
-  
       %7D%0A    

Add auxiliar method