Example #1
0
 /**
  * Make Salesforce REST api calls.
  *
  * @param string $path   API endpoint
  * @param string $method API request type
  * @param array  $params Assoc of request parameters
  *
  * @return mixed
  */
 public function call($path, $method = 'GET', $params = [])
 {
     $headers = ['headers' => ['X-SFDC-Session' => $this->session->getAccessToken()]];
     $params = array_merge_recursive($headers, $params);
     try {
         $response = $this->httpClient->request($method, $this->session->getInstanceUrl() . '/services/async/' . $this->getApiVersion() . '/' . $path, $params);
     } catch (RequestException $e) {
         return $e->getResponse()->getBody() . PHP_EOL;
     }
     return $response->getBody()->getContents();
 }