41 lines
1.9 KiB
PHP
41 lines
1.9 KiB
PHP
|
<?php
|
||
|
|
||
|
namespace App\Http\Controllers\ThirdPartyServices;
|
||
|
|
||
|
use App\Http\Controllers\Controller;
|
||
|
use App\Http\Controllers\ThirdPartyServices\NextcloudService;
|
||
|
use App\Http\Controllers\ThirdPartyServices\OpenProjectService;
|
||
|
use App\Http\Controllers\ThirdPartyServices\EmailService;
|
||
|
|
||
|
class ThirdPartyServices extends Controller
|
||
|
{
|
||
|
private $third_party_integrations_nextcloud;
|
||
|
private $third_party_integrations_open_project;
|
||
|
|
||
|
public function __construct()
|
||
|
{
|
||
|
$this->third_party_integrations_nextcloud = env('THIRD_PARTY_INTEGRATIONS_NEXTCLOUD', false);
|
||
|
$this->third_party_integrations_open_project = env('THIRD_PARTY_INTEGRATIONS_OPEN_PROJECT', false);
|
||
|
$this->email_send_allow = env('EMAIL_SEND_ALLOW', false);
|
||
|
$this->nextcloud_service = new \App\Http\Controllers\ThirdPartyServices\NextcloudService();
|
||
|
$this->open_project_service = new \App\Http\Controllers\ThirdPartyServices\OpenProjectService();
|
||
|
$this->email_service = new \App\Http\Controllers\ThirdPartyServices\EmailService();
|
||
|
$this->calculate_agent_cost = env('GITEA_CALCULATE_AGENT_COST', false);
|
||
|
}
|
||
|
|
||
|
function handle_third_party_services(string $file_name, string $file_path, array $issues, array $company_agents, string $from_date, string $to_date)
|
||
|
{
|
||
|
$nextcloud_res = $open_project_res = $email_res = false;
|
||
|
if ($this->third_party_integrations_nextcloud) {
|
||
|
$nextcloud_res = $this->nextcloud_service->nextcloud_upload_csv($file_name, $file_path);
|
||
|
}
|
||
|
if ($this->third_party_integrations_open_project && $this->calculate_agent_cost) {
|
||
|
$open_project_res = $this->open_project_service->open_project_add_task_to_agent($issues, $company_agents, $from_date, $to_date);
|
||
|
}
|
||
|
if($this->email_send_allow) {
|
||
|
$email_res = $this->email_service->send_export_via_email($from_date, $to_date, $file_name);
|
||
|
}
|
||
|
return [$nextcloud_res, $open_project_res, $email_res];
|
||
|
}
|
||
|
}
|