@@ -6556,6 +6556,13 @@ function Api(config) {
65566556 this . httpOptions . path = path ;
65576557}
65586558
6559+ Api . Methods = {
6560+ GET : 'GET' ,
6561+ PUT : 'PUT' ,
6562+ DELETE : 'DELETE' ,
6563+ POST : 'POST'
6564+ } ;
6565+
65596566require ( './plugins/request' ) ( Api ) ;
65606567require ( './plugins/login' ) ( Api ) ;
65616568require ( './plugins/logout' ) ( Api ) ;
@@ -7117,7 +7124,7 @@ module.exports = function(Api) {
71177124 if ( updates ) {
71187125 params . updates = JSON . stringify ( updates ) ;
71197126 }
7120- return this . request ( objCode , params , fields , ' POST' ) ;
7127+ return this . request ( objCode , params , fields , Api . Methods . POST ) ;
71217128 } ;
71227129} ;
71237130} , { } ] , 41 :[ function ( require , module , exports ) {
@@ -7131,7 +7138,7 @@ module.exports = function(Api) {
71317138 Api . prototype . count = function ( objCode , query ) {
71327139 var that = this ;
71337140 return new Promise ( function ( resolve , reject ) {
7134- that . request ( objCode + '/count' , query , null , ' GET' )
7141+ that . request ( objCode + '/count' , query , null , Api . Methods . GET )
71357142 . then ( function ( data ) {
71367143 resolve ( data . count ) ;
71377144 } , reject ) ;
@@ -7148,7 +7155,7 @@ module.exports = function(Api) {
71487155 * @returns {Promise } A promise which will resolved with the ID and any other specified fields of newly created object
71497156 */
71507157 Api . prototype . create = function ( objCode , params , fields ) {
7151- return this . request ( objCode , params , fields , ' POST' ) ;
7158+ return this . request ( objCode , params , fields , Api . Methods . POST ) ;
71527159 } ;
71537160} ;
71547161} , { } ] , 43 :[ function ( require , module , exports ) {
@@ -7165,7 +7172,7 @@ module.exports = function(Api) {
71657172 var params = {
71667173 updates : JSON . stringify ( updates )
71677174 } ;
7168- return this . request ( objCode + '/' + objID , params , fields , ' PUT' ) ;
7175+ return this . request ( objCode + '/' + objID , params , fields , Api . Methods . PUT ) ;
71697176 } ;
71707177} ;
71717178} , { } ] , 44 :[ function ( require , module , exports ) {
@@ -7180,7 +7187,7 @@ module.exports = function(Api) {
71807187 * @returns {Promise } A promise which will resolved if everything went ok and rejected otherwise
71817188 */
71827189 Api . prototype . execute = function ( objCode , objID , action , actionArgs ) {
7183- return this . request ( objCode + '/' + objID + '/' + action , actionArgs , null , ' PUT' ) ;
7190+ return this . request ( objCode + '/' + objID + '/' + action , actionArgs , null , Api . Methods . PUT ) ;
71847191 } ;
71857192} ;
71867193} , { } ] , 45 :[ function ( require , module , exports ) {
@@ -7197,9 +7204,9 @@ module.exports = function(Api) {
71977204 objIDs = [ objIDs ] ;
71987205 }
71997206 if ( objIDs . length === 1 ) {
7200- return this . request ( objCode + '/' + objIDs [ 0 ] , null , fields , ' GET' ) ;
7207+ return this . request ( objCode + '/' + objIDs [ 0 ] , null , fields , Api . Methods . GET ) ;
72017208 } else {
7202- return this . request ( objCode , { id : objIDs } , fields , ' GET' ) ;
7209+ return this . request ( objCode , { id : objIDs } , fields , Api . Methods . GET ) ;
72037210 }
72047211 } ;
72057212} ;
@@ -7215,7 +7222,7 @@ module.exports = function(Api) {
72157222 Api . prototype . login = function ( username , password ) {
72167223 var that = this ;
72177224 return new Promise ( function ( resolve , reject ) {
7218- that . request ( 'login' , { username : username , password : password } , null , ' POST' )
7225+ that . request ( 'login' , { username : username , password : password } , null , Api . Methods . POST )
72197226 . then ( function ( data ) {
72207227 that . httpOptions . headers . sessionID = data . sessionID ;
72217228 resolve ( data ) ;
@@ -7232,7 +7239,7 @@ module.exports = function(Api) {
72327239 Api . prototype . logout = function ( ) {
72337240 var that = this ;
72347241 return new Promise ( function ( resolve , reject ) {
7235- that . request ( 'logout' , null , null , ' GET' ) . then ( function ( result ) {
7242+ that . request ( 'logout' , null , null , Api . Methods . GET ) . then ( function ( result ) {
72367243 if ( result && result . success ) {
72377244 delete that . httpOptions . headers . sessionID ;
72387245 resolve ( ) ;
@@ -7255,7 +7262,7 @@ module.exports = function(Api) {
72557262 if ( objCode ) {
72567263 path = objCode + path ;
72577264 }
7258- return this . request ( path , null , null , ' GET' ) ;
7265+ return this . request ( path , null , null , Api . Methods . GET ) ;
72597266 } ;
72607267} ;
72617268} , { } ] , 49 :[ function ( require , module , exports ) {
@@ -7270,7 +7277,7 @@ module.exports = function(Api) {
72707277 * @returns {Promise } A promise which will resolved with received data if everything went ok and rejected with error info otherwise
72717278 */
72727279 Api . prototype . namedQuery = function ( objCode , query , queryArgs , fields ) {
7273- return this . request ( objCode + '/' + query , queryArgs , fields , ' GET' ) ;
7280+ return this . request ( objCode + '/' + query , queryArgs , fields , Api . Methods . GET ) ;
72747281 } ;
72757282} ;
72767283} , { } ] , 50 :[ function ( require , module , exports ) {
@@ -7287,7 +7294,7 @@ module.exports = function(Api) {
72877294 var that = this ;
72887295 return new Promise ( function ( resolve , reject ) {
72897296 var params = bForce ? { force : true } : null ;
7290- that . request ( objCode + '/' + objID , params , null , ' DELETE' ) . then ( function ( result ) {
7297+ that . request ( objCode + '/' + objID , params , null , Api . Methods . DELETE ) . then ( function ( result ) {
72917298 if ( result && result . success ) {
72927299 resolve ( ) ;
72937300 } else {
@@ -7310,7 +7317,7 @@ var queryString = require('querystring'),
73107317
73117318module . exports = function ( Api ) {
73127319 var requestHasData = function ( method ) {
7313- return method !== ' GET' && method !== ' PUT' ;
7320+ return method !== Api . Methods . GET && method !== Api . Methods . PUT ;
73147321 } ;
73157322
73167323 Api . prototype . request = function ( path , params , fields , method ) {
@@ -7389,7 +7396,7 @@ module.exports = function(Api) {
73897396 * @return {Promise } A promise which will resolved with search results if everything went ok and rejected otherwise
73907397 */
73917398 Api . prototype . search = function ( objCode , query , fields ) {
7392- return this . request ( objCode + '/search' , query , fields , ' GET' ) ;
7399+ return this . request ( objCode + '/search' , query , fields , Api . Methods . GET ) ;
73937400 } ;
73947401} ;
73957402} , { } ] , 54 :[ function ( require , module , exports ) {
0 commit comments