diff --git a/composer.json b/composer.json index 6144a12..0ebd74b 100644 --- a/composer.json +++ b/composer.json @@ -11,7 +11,7 @@ ], "require": { "php": ">=5.3.0", - "illuminate/support": "4.1.*", + "illuminate/support": "4.*", "davispeixoto/force-dot-com-toolkit-for-php": "1.0.3" }, "autoload": { diff --git a/src/Davispeixoto/LaravelSalesforce/Salesforce.php b/src/Davispeixoto/LaravelSalesforce/Salesforce.php index d349f9c..4f99601 100644 --- a/src/Davispeixoto/LaravelSalesforce/Salesforce.php +++ b/src/Davispeixoto/LaravelSalesforce/Salesforce.php @@ -2,6 +2,7 @@ use Davispeixoto\ForceDotComToolkitForPhp\SforceEnterpriseClient as Client; use Illuminate\Config\Repository; +use Illuminate\Filesystem\Filesystem as File; class Salesforce { public $sfh; @@ -12,18 +13,24 @@ public function __construct(Repository $configExternal) $this->sfh = new Client(); $wsdl = $configExternal->get('laravel-salesforce::wsdl'); + $filePointer = new File(); - if (empty($wsdl)) { - $wsdl = __DIR__.'/Wsdl/enterprise.wsdl.xml'; + if (!empty($wsdl) && $filePointer->exists($wsdl)) { + $this->sfh->createConnection($configExternal->get('laravel-salesforce::wsdl')); + } else { + $this->sfh->createConnection(__DIR__.'/Wsdl/enterprise.wsdl.xml'); } - $this->sfh->createConnection($wsdl); + $endpoint = $configExternal->get('laravel-salesforce::endpoint'); + if (!empty($endpoint)) { + $this->sfh->setEndpoint($endpoint); + } $this->sfh->login($configExternal->get('laravel-salesforce::username') , $configExternal->get('laravel-salesforce::password') . $configExternal->get('laravel-salesforce::token')); return $this; - } catch (Exception $e) { + } catch (\Exception $e) { Log::error($e->getMessage()); - throw new Exception('Exception no Construtor' . $e->getMessage() . "\n\n" . $e->getTraceAsString()); + throw new \Exception('Exception in Construtor' . $e->getMessage() . PHP_EOL . $e->getTraceAsString()); } } @@ -35,14 +42,14 @@ public function create($sObjects, $type) return $this->sfh->create($sObjects, $type); } - public function update($sObjects, $type, $assignment_header = NULL, $mru_header = NULL) + public function update($sObjects, $type, $assignmentHeader = NULL, $mruHeader = NULL) { - return $this->sfh->update($sObjects, $type, $assignment_header, $mru_header); + return $this->sfh->update($sObjects, $type, $assignmentHeader, $mruHeader); } - public function upsert($ext_Id, $sObjects, $type = 'Contact') + public function upsert($extId, $sObjects, $type = 'Contact') { - return $this->sfh->upsert($ext_Id, $sObjects, $type); + return $this->sfh->upsert($extId, $sObjects, $type); } public function merge($mergeRequest, $type) @@ -63,9 +70,9 @@ public function printDebugInfo() return $this->sfh->printDebugInfo(); } - public function createConnection($wsdl, $proxy = NULL, $soap_options = array()) + public function createConnection($wsdl, $proxy = NULL, $soapOptions = array()) { - return $this->sfh->createConnection($wsdl, $proxy, $soap_options); + return $this->sfh->createConnection($wsdl, $proxy, $soapOptions); } public function setCallOptions($header) @@ -113,9 +120,9 @@ public function setMruHeader($header) return $this->sfh->setMruHeader($header); } - public function setSessionHeader($id) + public function setSessionHeader($sessionId) { - return $this->sfh->setSessionHeader($id); + return $this->sfh->setSessionHeader($sessionId); } public function setUserTerritoryDeleteHeader($header) @@ -324,7 +331,7 @@ public function resetPassword($userId) public function dump() { $str = print_r($this , true); - //$str .= print_r($this->sfh , true); + return $str; } } ?> \ No newline at end of file diff --git a/src/config/config.php b/src/config/config.php index e55d92e..7bfba71 100644 --- a/src/config/config.php +++ b/src/config/config.php @@ -13,12 +13,14 @@ 'username' => '', 'password' => '', 'token' => '', - 'wsdl' => app_path() . '/wsdl/enterprise.wsdl.xml', + 'endpoint' => null, + 'wsdl' => null, // sandbox // 'username' => '', // 'password' => '', // 'token' => '', -// 'wsdl' => app_path() . '/wsdl/enterprise.sandbox.wsdl.xml', +// 'endpoint' => 'https://test.salesforce.com/services/Soap/c/27.0', +// 'wsdl' => null, ); \ No newline at end of file