Ignore:
Timestamp:
04/05/12 17:00:04 (12 years ago)
Author:
cristiano
Message:

Ticket #2598 - implementação base REST + oauth

Location:
sandbox/2.4-expresso-api
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • sandbox/2.4-expresso-api

    • Property svn:ignore
      •  

        old new  
        22header.inc.php 
        33._header.inc.php 
         4.htaccess.swp 
  • sandbox/2.4-expresso-api/prototype/api

    • Property svn:ignore set to
      .datalayer.js.kate-swp
  • sandbox/2.4-expresso-api/prototype/api/config.php

    r5764 r5888  
    2020     
    2121    static function me($config) 
    22     { 
    23          
     22    {    
    2423        return isset($_SESSION['wallet']['user'][$config]) ? $_SESSION['wallet']['user'][$config] : false; 
    2524    } 
  • sandbox/2.4-expresso-api/prototype/api/datalayer.js

    r5724 r5888  
    221221       
    222222          return( result ); 
     223    }, 
     224     
     225    /** 
     226    * This method is used to read resources from the server. 
     227    *  
     228    * @param uri Uri of the resource that gonna be readed. 
     229    * @param callback A function that is called when the resource is loaded successfully. When the parameter is ignored the request is made synchrounsly. 
     230    * @param accept The attribute accept that is used to ask the target format to the server 
     231    * @return The target resource when the callback is ommitted ( made it synchronous ) 
     232    */ 
     233 
     234    read: function( uri, callback, accept ){ 
     235        //return this.send( this.dispatchPath + 'rest' + uri, [ 'get', accept || 'json' ], false, callback ); 
     236        //http://expressodev.prognus.com.br/cristiano/expresso-api/rest/maillast 
     237         
     238        return this.send( ('rest' + uri), [ 'get', accept || 'json' ], true, callback, !!!callback,  
     239        {'beforeSend' : function (xhr){  
     240            xhr.setRequestHeader('Authorization', "OAUTH Bearer " + DataLayer.me.token)}  
     241        }); 
     242       
     243    }, 
     244 
     245    /** 
     246    * This method is used to create resources from the server. 
     247    *  
     248    * @param uri Uri of the resource that gonna be readed. 
     249    * @param callback A function that is called when the resource is created on the server successfully. When the parameter is ignored the request is made synchrounsly. 
     250    * @param accept The attribute accept that is used to ask the target format to the server. 
     251    * @return The result response of the create from the server when the callback is ommitted ( made it synchronous ) 
     252    */ 
     253     
     254    create: function( uri, data, callback, accept ){ 
     255       
     256        return this.send( this.dispatchPath + 'rest' + uri, [ 'post', accept || 'json' ], data, callback, !!!callback,  
     257        {'beforeSend' : function (xhr){  
     258            xhr.setRequestHeader('Authorization', "OAUTH Bearer " + DataLayer.me.token)}  
     259        }); 
     260       
     261    }, 
     262 
     263    /** 
     264    * This method is used to update resources from the server. 
     265    *  
     266    * @param uri Uri of the resource that gonna be readed. 
     267    * @param callback A function that is called when the resource is update on the server successfully. When the parameter is ignored the request is made synchrounsly. 
     268    * @param accept The attribute accept that is used to ask the target format to the server 
     269    * @return The result response of the update from the server when the callback is ommitted ( made it synchronous ) 
     270    */ 
     271 
     272    update: function( uri, data, callback, accept ){ 
     273       
     274        return this.send( this.dispatchPath + 'rest' + uri, [ 'put', accept || 'json' ], data, callback, !!!callback,  
     275        {'beforeSend' : function (xhr){  
     276            xhr.setRequestHeader('Authorization', "OAUTH Bearer " + DataLayer.me.token)}  
     277        }); 
     278       
     279    }, 
     280 
     281    /** 
     282    * This method is used to delete resources from the server. 
     283    *  
     284    * @param uri Uri of the resource that gonna be readed. 
     285    * @param callback A function that is called when the resource is deleted successfully in the server. When the parameter is ignored the request is made synchrounsly. 
     286    * @param accept The attribute accept that is used to ask the target format to the server 
     287    * @return The result response of the delete from the server when the callback is ommitted ( made it synchronous ) 
     288    */ 
     289 
     290    "delete": function( uri, callback, accept ){ 
     291       
     292        return this.send( this.dispatchPath + 'rest' + uri, [ 'delete', accept || 'json' ], false, callback, !!!callback,  
     293        {'beforeSend' : function (xhr){  
     294            xhr.setRequestHeader('Authorization', "OAUTH Bearer " + DataLayer.me.token)}  
     295        }); 
     296       
    223297    }, 
    224298     
     
    19912065 
    19922066        if( !this.dispatchPath ) 
    1993             this.dispatchPath = "../../"; 
     2067            this.dispatchPath = "prototype/"; 
    19942068 
    19952069        if( !this.templatePath ) 
     
    20062080 
    20072081        this.start(); 
     2082        this.me = this.dispatch( "me" ); 
    20082083    } 
    20092084} 
Note: See TracChangeset for help on using the changeset viewer.