NexusLeads Webshell
NexusLeads


Server : LiteSpeed
System : Linux server 3.10.0-1160.90.1.el7.x86_64 #1 SMP Thu May 4 15:21:22 UTC 2023 x86_64
User : alsaif ( 1057)
PHP Version : 7.4.33
Disable Function : show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Directory :  /home/alsaif/public_html/plugins/system/nrframework/NRFramework/Integrations/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/alsaif/public_html/plugins/system/nrframework/NRFramework/Integrations/Salesforce.php
<?php

/**
 * @author          Tassos Marinos <info@tassos.gr>
 * @link            https://www.tassos.gr
 * @copyright       Copyright © 2024 Tassos All Rights Reserved
 * @license         GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later
 */

namespace NRFramework\Integrations;

// No direct access
defined('_JEXEC') or die;

use Joomla\CMS\Language\Text;

class SalesForce extends Integration
{
	/**
	 *  Service API Endpoint
	 *
	 *  @var  string
	 */
	protected $endpoint = 'https://{{ENV}}.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8';

	/**
	 *  Encode data before sending the request
	 *
	 *  @var  boolean
	 */
	protected $encode = false;

	/**
	 * Create a new instance
	 * 
	 * @param  array       $options
	 * 
	 * @throws \Exception
	 */
	public function __construct($options = [])
	{
		parent::__construct();

		$this->setKey($options);
		$this->prepareEndpoint($options);

		$this->options->set('headers.Content-Type', 'application/x-www-form-urlencoded');
	}

	private function prepareEndpoint($options = [])
	{
		if (isset($options['test_mode']) && $options['test_mode'])
		{
			$this->setEndpoint(str_replace('{{ENV}}', 'test', $this->endpoint));
		}
		else
		{
			$this->setEndpoint(str_replace('{{ENV}}', 'webto', $this->endpoint));
		}
	}

	/**
	 *  Subscribe user to SalesForce
	 *
	 *  API References:
	 *  https://developer.salesforce.com/page/Wordpress-to-lead
	 *
	 *  @param   string   $email         	  User's email address
	 *  @param   array    $params  			  All the form fields
	 *
	 *  @return  void
	 */
	public function subscribe($email, $params)
	{
		$data = array(
			"email" => $email,
			"oid"   => $this->key
		);

		if (is_array($params) && count($params))
		{
			$data = array_merge($data, $params);
		}

		$this->post('', $data);

		return true;
	}

	/**
	 *  Determine if the Lead has been stored successfully in SalesForce
	 *
	 *  @return  string
	 */
	public function determineSuccess()
	{
		$status = $this->last_response->code;

		if ($status < 200 && $status > 299)
		{
			return false;
		}

		$headers = $this->last_response->headers;

		if (isset($headers['Is-Processed']) && (strpos($headers['Is-Processed'], 'Exception') !== false))
		{
			$this->last_error = Text::_('NR_SALESFORCE_ERROR');
			return false;
		}

		return ($this->request_successful = true);
	}
}

NexusLeads