Skip to content

Commit

Permalink
Add functions to use custom apex rest classes
Browse files Browse the repository at this point in the history
  • Loading branch information
frankkessler committed Aug 11, 2016
1 parent e508faf commit 014e3d5
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/Salesforce.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,32 @@ public function search($query)
return $this->call_api('get','search/?q='.urlencode($query));
}

public function getCustomRest($uri)
{
$url = 'https://'.SalesforceConfig::get('salesforce.api.domain').'/services/apexrest/'.$uri;
return $this->rawgetRequest($url);
}

public function postCustomRest($uri, $data)
{
$url = 'https://'.SalesforceConfig::get('salesforce.api.domain').'/services/apexrest/'.$uri;
return $this->rawPostRequest($url, $data);
}

public function rawGetRequest($request_string){
return $this->call_api('get',$request_string);
}

public function rawPostRequest($request_string, $data){
return $this->call_api('post',$request_string,[
'http_errors' => false,
'body' => json_encode($data),
'headers' => [
'Content-type' => 'application/json',
],
]);
}

protected function call_api($method, $url, $options=[], $debug_info=[]){
try{
if(is_null($options)){
Expand Down

0 comments on commit 014e3d5

Please sign in to comment.