Source of file SalesforceTest.php
Size: 2,404 Bytes - Last Modified: 2021-12-23T10:46:09+00:00
/var/www/docs.ssmods.com/process/src/code/Tasks/SalesforceTest.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 | <?php class SalesforceTest extends BuildTask { protected $title = 'Test Sales Force API'; protected $description = 'Test Sales Cloud'; protected $emailStub = '@test.best.co.com.org.net'; protected $email = ''; public function run($request) { MySalesforceContactApi::set_debug(true); $this->setEmail(); $this->findContact(); $this->createContact(); $this->findContact(); $this->updateContact(); $this->setEmail(); $this->createSubscriber(); $this->findContact(); $this->updateSubscriber(); $this->setEmail(); $this->createBadContact(); } protected function createContact() { MySalesforceContactApi::create_contact( [ 'FirstName' => 'John', 'LastName' => 'Smith', 'Phone' => '(510) 555-5555', 'Email' => $this->email, ] ); } protected function updateContact() { MySalesforceContactApi::update_contact( [ 'FirstName' => 'Joan', 'LastName' => 'Smith', 'Phone' => '(510) 555-5555', 'Email' => $this->email, ] ); } protected function findContact() { $isRegistered = MySalesforceContactApi::is_email_registered($this->email); echo '<h1>Does ' . $this->email . ' exist ' . ($isRegistered ? 'YES' : 'NO') . '</h1>'; } protected function createSubscriber() { MySalesforceContactApi::add_email_subscriber( $this->email, '(510) 555-5555', 'John', 'Smith', [ ] ); } protected function updateSubscriber() { MySalesforceContactApi::update_email_subscriber( $this->email, [ 'Phone' => '(511) 555-1111', ] ); } protected function createBadContact() { MySalesforceContactApi::create_contact( [ 'FirstName' => 'John', 'LastName' => 'Smith', 'NON_EXISTING_FIELD' => 'RUBBISH', 'Email' => $this->email, ] ); } protected function setEmail() { $this->email = 'test' . rand(0, 99999) . $this->emailStub; } } |