| Server IP : 95.46.96.79 / Your IP : 216.73.216.4 Web Server : Apache/2.4.41 (Ubuntu) System : Linux zaimer.uz 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64 User : akslabs_uz_usr ( 1001) PHP Version : 7.4.3-4ubuntu2.29 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /var/www/sugurtatrip__usr95/data/www/sugurtatrip.uz/apiv1/policy/src/Models/Apex/ |
Upload File : |
<?php
namespace Apex;
use Core\HttpClient;
class ApexInfoModel {
private $base_url;
private $api_username;
private $api_password;
private $program_id;
private $user_pinfl;
private $p_series;
private $p_number;
private $birth_date;
public function __construct($data) {
$program_id = $data['program_id'] ?? null;
$user_pinfl = $data['user_pinfl'] ?? null;
$p_series = $data['series'] ?? null;
$p_number = $data['number'] ?? null;
$birth_date = $data['birthday'] ?? null;
if($program_id !== null) {
$this->setProgramId($program_id);
}
if ($user_pinfl !== null) {
$this->setUserPinfl($user_pinfl);
}
if ($p_series !== null) {
$this->setPSeries($p_series);
}
if ($p_number !== null) {
$this->setPNumber($p_number);
}
if ($birth_date !== null) {
$this->setBirthDate($birth_date);
}
$this->base_url = $_ENV['APEX_API_URL'];
$this->api_username = $_ENV['APEX_USERNAME'];
$this->api_password = $_ENV['APEX_PASSWORD'];
}
public function setProgramId($program_id) {
if (filter_var($program_id, FILTER_VALIDATE_INT) !== false) {
$this->program_id = (int) $program_id;
} else {
throw new \Exception("Invalid program id format");
}
}
public function setUserPinfl($user_pinfl) {
$this->user_pinfl = filter_var($user_pinfl, FILTER_UNSAFE_RAW, FILTER_FLAG_STRIP_LOW | FILTER_FLAG_STRIP_HIGH);
}
public function setPSeries($p_series) {
$this->p_series = filter_var($p_series, FILTER_UNSAFE_RAW, FILTER_FLAG_STRIP_LOW | FILTER_FLAG_STRIP_HIGH);
}
public function setPNumber($p_number) {
$this->p_number = filter_var($p_number, FILTER_UNSAFE_RAW, FILTER_FLAG_STRIP_LOW | FILTER_FLAG_STRIP_HIGH);
}
public function setBirthDate($birth_date) {
$this->birth_date = filter_var($birth_date, FILTER_UNSAFE_RAW, FILTER_FLAG_STRIP_LOW | FILTER_FLAG_STRIP_HIGH);
}
public function getProgramDetails() {
$url = $this->base_url . ApexEndpoints::PROGRAM_DETAILS;
$data = [
'program_id' => $this->program_id,
];
$result = HttpClient::postWithAuth($url, $data, $this->api_username, $this->api_password);
return $result;
}
public function calculateTravel() {
$url = $this->base_url . ApexEndpoints::CALCULATE;
$programIds = [
ApexPrograms::SILVER,
ApexPrograms::GOLD,
ApexPrograms::PLATINUM,
ApexPrograms::STOPVIRUS1,
ApexPrograms::STOPVIRUS2
];
$results = [];
foreach ($programIds as $programId) {
$data = [
'travel_info' => [
'start_date' => $this->start_date,
'end_date' => $this->end_date,
'country' => $this->country,
'program_id' => $programId,
'purpose_id' => $this->purpose_id,
'group_id' => $this->group_id,
],
'person_info' => $this->person_info,
];
$result = HttpClient::postWithAuth($url, $data, $this->api_username, $this->api_password);
if(isset($result->result) && $result->result === 0) {
// $results[] = $result;
$results[] = [
'program_id' => $programId,
'program_name' => $result->program_name,
'price_usd' => $result->stoimost_USD,
'price_uzs' => $result->stoimost_UZS,
];
} else {
$results[] = [
'program_id' => $programId,
'error' => $result->result_message,
];
}
}
return $results;
}
public function getRegions() {
$regions_res = HttpClient::getWithAuth($this->base_url . ApexEndpoints::REGIONS, $this->api_username, $this->api_password);
$districts_res = HttpClient::getWithAuth($this->base_url . ApexEndpoints::DISTRICTS . "?limit=500", $this->api_username, $this->api_password);
$regions = $regions_res->items;
$districts = $districts_res->items;
return [
'regions' => $regions,
'districts' => $districts
];
}
public function getPersonInfo() {
$url = $this->base_url . ApexEndpoints::PERSON_INFO;
$data = [
'user_id' => $_ENV['APEX_USER_ID'],
'user_pinfl' =>$_ENV['APEX_ROOT_PINFL'],
'series' => $this->p_series,
'number' => $this->p_number,
'birthday' => $this->birth_date
];
$result = HttpClient::postWithAuth($url, $data, $this->api_username, $this->api_password);
return $result;
}
}