Skip to content
Snippets Groups Projects
Commit 6156c48f authored by Aaron Bauman's avatar Aaron Bauman
Browse files

- Fix pull exception in Related IDs when pulling an empty lookup value

- Add httpRequestRaw to RestClient for fetching binary data
parent b1bc9b4f
No related branches found
No related tags found
No related merge requests found
...@@ -89,10 +89,19 @@ class RelatedIDs extends SalesforceMappingFieldPluginBase { ...@@ -89,10 +89,19 @@ class RelatedIDs extends SalesforceMappingFieldPluginBase {
} }
$value = $sf_object->field($this->config('salesforce_field')); $value = $sf_object->field($this->config('salesforce_field'));
// Empty value means nothing to do here.
if (empty($value)) {
return NULL;
}
// If value is not an SFID, make it one. // If value is not an SFID, make it one.
if (!($value instanceof SFID)) { if (!($value instanceof SFID)) {
$value = new SFID($value); try {
$value = new SFID($value);
}
catch (\Exception $e) {
return NULL;
}
} }
// Convert SF Id to Drupal Id. // Convert SF Id to Drupal Id.
......
...@@ -205,6 +205,25 @@ class RestClient implements RestClientInterface { ...@@ -205,6 +205,25 @@ class RestClient implements RestClientInterface {
return $this->httpRequest($url, $data, $headers, $method); return $this->httpRequest($url, $data, $headers, $method);
} }
/**
* Return raw response content from given URL. Useful for fetching data from
* binary fields like Attachments.
*
* @param string $url
* @return mixed
*/
public function httpRequestRaw($url) {
if (!$this->getAccessToken()) {
throw new \Exception('Missing OAuth Token');
}
$headers = [
'Authorization' => 'OAuth ' . $this->getAccessToken(),
'Content-type' => 'application/json',
];
$response = $this->httpRequest($url, NULL, $headers);
return $response->getBody()->getContents();
}
/** /**
* Make the HTTP request. Wrapper around drupal_http_request(). * Make the HTTP request. Wrapper around drupal_http_request().
* *
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment