@@ -249,8 +249,10 @@ if (forcetk.Client === undefined) {
249
249
* @param [error=null] function to which jqXHR will be passed in case of error
250
250
* @param [method="GET"] HTTP method for call
251
251
* @param [payload=null] payload for POST/PATCH etc
252
+ * @param [paramMap={ }] parameters to send as header values for POST/PATCH etc
253
+ * @param [retry] specifies whether to retry on error
252
254
*/
253
- forcetk . Client . prototype . apexrest = function ( path , callback , error , method , payload , retry ) {
255
+ forcetk . Client . prototype . apexrest = function ( path , callback , error , method , payload , paramMap , retry ) {
254
256
var that = this ;
255
257
var url = this . instanceUrl + '/services/apexrest' + path ;
256
258
@@ -268,7 +270,7 @@ if (forcetk.Client === undefined) {
268
270
that . refreshAccessToken ( function ( oauthResponse ) {
269
271
that . setSessionToken ( oauthResponse . access_token , null ,
270
272
oauthResponse . instance_url ) ;
271
- that . ajax ( path , callback , error , method , payload , true ) ;
273
+ that . apexrest ( path , callback , error , method , payload , paramMap , true ) ;
272
274
} ,
273
275
error ) ;
274
276
} else {
@@ -280,6 +282,13 @@ if (forcetk.Client === undefined) {
280
282
if ( that . proxyUrl !== null ) {
281
283
xhr . setRequestHeader ( 'SalesforceProxy-Endpoint' , url ) ;
282
284
}
285
+ //Add any custom headers
286
+ if ( paramMap === null ) {
287
+ paramMap = { } ;
288
+ }
289
+ for ( paramName in paramMap ) {
290
+ xhr . setRequestHeader ( paramName , paramMap [ paramName ] ) ;
291
+ }
283
292
xhr . setRequestHeader ( that . authzHeader , "OAuth " + that . sessionId ) ;
284
293
xhr . setRequestHeader ( 'X-User-Agent' , 'salesforce-toolkit-rest-javascript/' + that . apiVersion ) ;
285
294
}
@@ -430,6 +439,30 @@ if (forcetk.Client === undefined) {
430
439
this . ajax ( '/' + this . apiVersion + '/query?q=' + escape ( soql )
431
440
, callback , error ) ;
432
441
}
442
+
443
+ /*
444
+ * Queries the next set of records based on pagination.
445
+ * <p>This should be used if performing a query that retrieves more than can be returned
446
+ * in accordance with http://www.salesforce.com/us/developer/docs/api_rest/Content/dome_query.htm</p>
447
+ * <p>Ex: forcetkClient.queryMore( successResponse.nextRecordsUrl, successHandler, failureHandler )</p>
448
+ *
449
+ * @param url - the url retrieved from nextRecordsUrl or prevRecordsUrl
450
+ * @param callback function to which response will be passed
451
+ * @param [error=null] function to which jqXHR will be passed in case of error
452
+ */
453
+ forcetk . Client . prototype . queryMore = function ( url , callback , error ) {
454
+ //-- ajax call adds on services/data to the url call, so only send the url after
455
+ var serviceData = "services/data" ;
456
+ var index = url . indexOf ( serviceData ) ;
457
+
458
+ if ( index > - 1 ) {
459
+ url = url . substr ( index + serviceData . length ) ;
460
+ } else {
461
+ //-- leave alone
462
+ }
463
+
464
+ this . ajax ( url , callback , error ) ;
465
+ }
433
466
434
467
/*
435
468
* Executes the specified SOSL search.
0 commit comments