113 lines
3.3 KiB
PHP
Executable File
113 lines
3.3 KiB
PHP
Executable File
<?php declare(strict_types=1); namespace IR\App\Webservices; if (!defined('IR_START')) exit('<pre>No direct script access allowed</pre>');
|
|
|
|
# core
|
|
use IR\Core\Base as Base;
|
|
use IR\Core\Application as Application;
|
|
|
|
# helpers
|
|
use IR\App\Helpers\Authentication as Authentication;
|
|
use IR\App\Helpers\Page as Page;
|
|
use IR\App\Helpers\Api as Api;
|
|
|
|
# models
|
|
use IR\App\Models\Production\MtaProcess as MtaProcess;
|
|
use IR\App\Models\Production\SmtpProcess as SmtpProcess;
|
|
use IR\App\Models\Admin\User as User;
|
|
|
|
|
|
# orm
|
|
use IR\Orm\Table as Table;
|
|
use IR\Orm\Sequence as Sequence;
|
|
|
|
# http
|
|
use IR\Http\Client as Client;
|
|
|
|
/**
|
|
* @name Tracking
|
|
* @description Tracking WebService
|
|
*/
|
|
class StatsSmtpSend extends Base
|
|
{
|
|
/**
|
|
* @app
|
|
* @readwrite
|
|
*/
|
|
protected $app;
|
|
|
|
/**
|
|
* @name init
|
|
* @description initializing process before the action method executed
|
|
* @once
|
|
* @protected
|
|
*/
|
|
public function init()
|
|
{
|
|
# set the current application to a local variable
|
|
$this->app = Application::getCurrent();
|
|
|
|
# get api authenticated user
|
|
$this->authenticatedUser = new User([
|
|
'id' => 5,
|
|
'production_id' => 1,
|
|
'master_access' => 'Enabled',
|
|
'status' => 'Activated',
|
|
'first_name' => 'achraf',
|
|
'last_name' => 'Tracking User',
|
|
'email' => 'achraf.ahaddouch@gmail.com',
|
|
'is_tracking_user' => true
|
|
]);
|
|
|
|
# store api authenticated user
|
|
Authentication::registerUser($this->authenticatedUser);
|
|
|
|
# check users roles
|
|
// Authentication::checkUserRoles();
|
|
}
|
|
|
|
/**
|
|
* @name getLink
|
|
* @description get offer link action
|
|
* @before init
|
|
*/
|
|
public function delivered($parameters = [])
|
|
{
|
|
# check for authentication
|
|
if(!Authentication::isUserAuthenticated())
|
|
{
|
|
Page::printApiResults(401,'Only logged-in access allowed !');
|
|
}
|
|
$paramStats = explode('|',$parameters);
|
|
|
|
//sd_1982210_4469_9589_1373_96
|
|
|
|
if(count($paramStats) > 0)
|
|
{
|
|
$id = $paramStats[1];
|
|
$status = $paramStats[2];
|
|
$processStats = explode('_',$id);
|
|
|
|
if(count($processStats )>0){
|
|
$typeDrop=$processStats[0];
|
|
$userProductionId=$processStats[1];
|
|
$dropProcessID=$processStats[2];
|
|
$smtpUserID=$processStats[3];
|
|
$emailID=$processStats[4];
|
|
$listID=$processStats[5];
|
|
if($status == 'success'){
|
|
$this->app->database('system')->execute("UPDATE production.smtp_processes SET delivered = delivered + 1 WHERE id = {$dropProcessID}");
|
|
}else if($status == 'failed'){
|
|
$this->app->database('system')->execute("UPDATE production.smtp_processes SET soft_bounced = soft_bounced + 1 WHERE id = {$dropProcessID}");
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
Page::printApiResults(200,'Operation completed successfully !');
|
|
|
|
}
|
|
|
|
} |