| Server IP : 95.46.96.79 / Your IP : 216.73.216.84 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/api/src/Models/Apex/ |
Upload File : |
<?php
namespace Apex;
use Core\HttpClient;
// class ApexPolicyModel {
// private $transaction_info;
// private $base_url;
// private $api_username;
// private $api_password;
// private $activity_id;
// private $applicant;
// private $countries;
// private $start_date;
// private $end_date;
// private $day;
// private $program_id;
// private $group_id;
// private $type_id;
// private $multi_id;
// private $date_reg;
// private $insured;
// private $total_days;
// public function __construct(
// $applicant = null,
// $insured = null,
// $start_date = null,
// $end_date = null,
// $day = 1,
// $program_id = 0,
// $activity_id = 0,
// $group_id = 0,
// $type_id = 0,
// $multi_id = 0,
// $date_reg = null,
// $date_births = [],
// $countries = [],
// ) {
// $this->setApplicant($applicant);
// $this->setInsured($insured);
// $this->setStartDate($start_date ?? (new \DateTime())->format('d.m.Y'));
// $this->setEndDate($end_date ?? (new \DateTime('tomorrow'))->format('d.m.Y'));
// $this->setProgramId($program_id);
// $this->setActivityId($activity_id);
// $this->setGroupId($group_id);
// $this->setTypeId($type_id);
// $this->setMultiId($multi_id);
// $this->setDateReg($date_reg ?? (new \DateTime())->format('d.m.Y'));
// // $this->setDateBirths($date_births);
// $this->setCountries($countries);
// $this->total_days = $this->calculateTotalDays($this->start_date, $this->end_date);
// $this->base_url = $_ENV['APEX_API_URL'];
// $this->api_username = $_ENV['APEX_USERNAME'];
// $this->api_password = $_ENV['APEX_PASSWORD'];
// }
// private function validateApplicant($applicant) {
// return true;
// }
// private function setApplicant($applicant) {
// if ($this -> validateApplicant($applicant)) {
// $this->applicant = $applicant;
// } else {
// throw new \Exception("Applicant data is not correct");
// }
// }
// private function validateInsured($insured) {
// return true;
// }
// private function setInsured($insured) {
// if ($this -> validateInsured($insured)) {
// $this->insured = $insured;
// } else {
// throw new \Exception("Insured data is not correct");
// }
// }
// public function setStartDate($start_date) {
// if ($this->validateDate($start_date)) {
// $this->start_date = $start_date;
// } else {
// throw new \Exception("Invalid start_date format");
// }
// }
// public function setEndDate($end_date) {
// if ($this->validateDate($end_date)) {
// $this->end_date = $end_date;
// } else {
// throw new \Exception("Invalid end_date format");
// }
// }
// public function setProgramId($program_id) {
// if (is_int($program_id)) {
// $this->program_id = $program_id;
// } else {
// throw new \Exception("Invalid program_id format");
// }
// }
// public function setActivityId($activity_id) {
// if (is_int($activity_id)) {
// $this->activity_id = $activity_id;
// } else {
// throw new \Exception("Invalid activity_id format");
// }
// }
// public function setGroupId($group_id) {
// if (is_int($group_id)) {
// $this->group_id = $group_id;
// } else {
// throw new \Exception("Invalid group_id format");
// }
// }
// public function setTypeId($type_id) {
// if (is_int($type_id)) {
// $this->type_id = $type_id;
// } else {
// throw new \Exception("Invalid type_id format");
// }
// }
// public function setMultiId($multi_id) {
// if (is_int($multi_id)) {
// $this->multi_id = $multi_id;
// } else {
// throw new \Exception("Invalid multi_id format");
// }
// }
// public function setDateReg($date_reg) {
// if ($this->validateDate($date_reg)) {
// $this->date_reg = $date_reg;
// } else {
// throw new \Exception("Invalid date_reg format");
// }
// }
// public function setCountries($countries) {
// if (is_array($countries)) {
// $this->countries = $countries;
// } else {
// throw new \Exception("Countries must be an array");
// }
// }
// private function validateDate($date) {
// $d = \DateTime::createFromFormat('d.m.Y', $date);
// return $d && $d->format('d.m.Y') === $date;
// }
// public function getStartDate() {
// return $this->start_date;
// }
// public function getEndDate() {
// return $this->end_date;
// }
// public function getDay() {
// return $this->day;
// }
// public function getActivityId() {
// return $this->activity_id;
// }
// public function getTypeId() {
// return $this->type_id;
// }
// public function getCountries() {
// return $this->countries;
// }
// public function getMultiId() {
// return $this->multi_id;
// }
// public function getDateReg() {
// return $this->date_reg;
// }
// public function getProgramId() {
// return $this->program_id;
// }
// public function getGroupId() {
// return $this->group_id;
// }
// public function calculateTotalDays($start_date, $end_date) {
// $start = \DateTime::createFromFormat('d.m.Y', $start_date);
// $end = \DateTime::createFromFormat('d.m.Y', $end_date);
// if (!$start || !$end) {
// throw new \Exception("Invalid date format. Dates should be in 'd.m.Y' format.");
// }
// $interval = $start->diff($end);
// return $interval->days + 1; // Including the start date
// }
// public function createPolicy($request) {
// $url = $this->base_url . KapitalEndpoints::CREATE_POLICY;
// $data = [
// 'activity_id' => $this->activity_id,
// 'applicant' => $this->applicant,
// 'countries' => $this->countries,
// 'date_reg' => $this->date_reg,
// 'days' => $this->total_days,
// 'end_date' => $this->end_date,
// 'start_date' => $this->start_date,
// 'group_id' => $this -> group_id,
// 'program_id' => $this->program_id,
// 'type_id' => $this->type_id,
// 'multi_id' => $this->multi_id,
// 'insured' => $this->insured
// ];
// $result = HttpClient::postWithAuth($url, $data, $this->api_username, $this->api_password);
// return $result;
// }
// }
class ApexPolicyModel
{
public $transaction_info;
public $insurance_info;
public $travel_info;
public $person_info = [];
public function __construct($transaction_info, $insurance_info, $travel_info, $person_info)
{
$this->transaction_info = new TransactionInfo($transaction_info['tr_id'], $transaction_info['user_id']);
$this->insurance_info = new InsuranceInfo(
$insurance_info['resident_s'],
$insurance_info['country_s'],
$insurance_info['region_s'],
$insurance_info['district_s'],
$insurance_info['address_s'],
$insurance_info['gender_s'],
$insurance_info['surname_s'],
$insurance_info['name_s'],
$insurance_info['middle_s'],
$insurance_info['birthday_s'],
$insurance_info['phone_s'],
$insurance_info['email_s'],
new PassportInfo($insurance_info['passport_s']['pinfl_s'], $insurance_info['passport_s']['series_s'], $insurance_info['passport_s']['number_s'])
);
$this->travel_info = new TravelInfo(
$travel_info['start_date'],
$travel_info['end_date'],
array_map(function($country) {
return new CountryInfo($country['iso']);
}, $travel_info['country']),
$travel_info['program_id'],
$travel_info['purpose_id'],
$travel_info['group_id']
);
foreach ($person_info as $person) {
$this->person_info[] = new PersonInfo(
$person['resident_p'],
$person['country_p'],
$person['region_p'],
$person['district_p'],
$person['address_p'],
$person['gender_p'],
$person['surname_p'],
$person['name_p'],
$person['middle_p'],
$person['birthday_p'],
$person['phone_p'],
$person['email_p'],
new PassportInfo($person['passport_p']['pinfl_p'], $person['passport_p']['series_p'], $person['passport_p']['number_p'])
);
}
}
}
class TransactionInfo
{
public $tr_id;
public $user_id;
public function __construct($tr_id, $user_id)
{
$this->tr_id = $tr_id;
$this->user_id = $user_id;
}
}
class InsuranceInfo
{
public $resident_s;
public $country_s;
public $region_s;
public $district_s;
public $address_s;
public $gender_s;
public $surname_s;
public $name_s;
public $middle_s;
public $birthday_s;
public $phone_s;
public $email_s;
public $passport_s;
public function __construct($resident_s, $country_s, $region_s, $district_s, $address_s, $gender_s, $surname_s, $name_s, $middle_s, $birthday_s, $phone_s, $email_s, $passport_s)
{
$this->resident_s = $resident_s;
$this->country_s = $country_s;
$this->region_s = $region_s;
$this->district_s = $district_s;
$this->address_s = $address_s;
$this->gender_s = $gender_s;
$this->surname_s = $surname_s;
$this->name_s = $name_s;
$this->middle_s = $middle_s;
$this->birthday_s = $birthday_s;
$this->phone_s = $phone_s;
$this->email_s = $email_s;
$this->passport_s = $passport_s;
}
}
class PassportInfo
{
public $pinfl_s;
public $series_s;
public $number_s;
public function __construct($pinfl_s, $series_s, $number_s)
{
$this->pinfl_s = $pinfl_s;
$this->series_s = $series_s;
$this->number_s = $number_s;
}
}
class TravelInfo
{
public $start_date;
public $end_date;
public $country;
public $program_id;
public $purpose_id;
public $group_id;
public function __construct($start_date, $end_date, $country, $program_id, $purpose_id, $group_id)
{
$this->start_date = $start_date;
$this->end_date = $end_date;
$this->country = $country;
$this->program_id = $program_id;
$this->purpose_id = $purpose_id;
$this->group_id = $group_id;
}
}
class CountryInfo
{
public $iso;
public function __construct($iso)
{
$this->iso = $iso;
}
}
class PersonInfo
{
public $resident_p;
public $country_p;
public $region_p;
public $district_p;
public $address_p;
public $gender_p;
public $surname_p;
public $name_p;
public $middle_p;
public $birthday_p;
public $phone_p;
public $email_p;
public $passport_p;
public function __construct($resident_p, $country_p, $region_p, $district_p, $address_p, $gender_p, $surname_p, $name_p, $middle_p, $birthday_p, $phone_p, $email_p, $passport_p)
{
$this->resident_p = $resident_p;
$this->country_p = $country_p;
$this->region_p = $region_p;
$this->district_p = $district_p;
$this->address_p = $address_p;
$this->gender_p = $gender_p;
$this->surname_p = $surname_p;
$this->name_p = $name_p;
$this->middle_p = $middle_p;
$this->birthday_p = $birthday_p;
$this->phone_p = $phone_p;
$this->email_p = $email_p;
$this->passport_p = $passport_p;
}
}