feat(vikon): extract API URL from hardcoded to integration_credentials
- Rename ViconApiToken → ViconApiConfig with token() and apiUrl() - Replace 9 hardcoded db-nica.ru URLs with dynamic apiUrl() - Payload now stores both token and api_url with fallback
This commit is contained in:
@@ -4,14 +4,14 @@ namespace App\Services\Vicon\DirectionStudy;
|
||||
|
||||
use App\Jobs\CreateDirectionStudy;
|
||||
use App\Jobs\CreateEducationalProgram;
|
||||
use App\Services\Vicon\ViconApiToken;
|
||||
use App\Services\Vicon\ViconApiConfig;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class AdmissionPlanService
|
||||
{
|
||||
public function __construct(
|
||||
private readonly ViconApiToken $viconApiToken,
|
||||
private readonly ViconApiConfig $viconApiConfig,
|
||||
) {}
|
||||
public function getLevelEducationCodes(object $campaign) : array
|
||||
{
|
||||
@@ -31,8 +31,8 @@ class AdmissionPlanService
|
||||
{
|
||||
try {
|
||||
$response = $this->callAPI(
|
||||
"https://db-nica.ru/api/v1/campaigns",
|
||||
$this->viconApiToken->get()
|
||||
"{$this->viconApiConfig->apiUrl()}/campaigns",
|
||||
$this->viconApiConfig->token()
|
||||
);
|
||||
if (!is_array($response)) {
|
||||
Log::channel('app')->warning('Unexpected response type in getCampaigns', [
|
||||
@@ -55,8 +55,8 @@ class AdmissionPlanService
|
||||
{
|
||||
try {
|
||||
$response = $this->callAPI(
|
||||
"https://db-nica.ru/api/v1/planPriema/$campaign_levels_code",
|
||||
$this->viconApiToken->get()
|
||||
"{$this->viconApiConfig->apiUrl()}/planPriema/$campaign_levels_code",
|
||||
$this->viconApiConfig->token()
|
||||
);
|
||||
|
||||
if (!is_object($response)) {
|
||||
|
||||
@@ -2,14 +2,14 @@
|
||||
|
||||
namespace App\Services\Vicon\DirectionStudy;
|
||||
|
||||
use App\Services\Vicon\ViconApiToken;
|
||||
use App\Services\Vicon\ViconApiConfig;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class DirectionStudyService
|
||||
{
|
||||
public function __construct(
|
||||
private readonly ViconApiToken $viconApiToken,
|
||||
private readonly ViconApiConfig $viconApiConfig,
|
||||
) {}
|
||||
const EDU_LEVELS = [1, 2, 3, 4, 5, 6];
|
||||
|
||||
@@ -44,31 +44,31 @@ class DirectionStudyService
|
||||
|
||||
public function getNaprs(int $edu_level): object
|
||||
{
|
||||
$data = $this->callAPI("https://db-nica.ru/api/v1/naprs?perPage=200&filter_edu_level=$edu_level", $this->viconApiToken->get());
|
||||
$data = $this->callAPI("{$this->viconApiConfig->apiUrl()}/naprs?perPage=200&filter_edu_level=$edu_level", $this->viconApiConfig->token());
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function getNapr(string $uuid): object
|
||||
{
|
||||
$data = $this->callAPI("https://db-nica.ru/api/v1/napr/$uuid", $this->viconApiToken->get());
|
||||
$data = $this->callAPI("{$this->viconApiConfig->apiUrl()}/napr/$uuid", $this->viconApiConfig->token());
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function getPrograms(int $edu_level): object
|
||||
{
|
||||
$data = $this->callAPI("https://db-nica.ru/api/v1/programs?filter_edu_level=$edu_level&perPage=200", $this->viconApiToken->get());
|
||||
$data = $this->callAPI("{$this->viconApiConfig->apiUrl()}/programs?filter_edu_level=$edu_level&perPage=200", $this->viconApiConfig->token());
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function getProgram(string $uuid): object
|
||||
{
|
||||
$data = $this->callAPI("https://db-nica.ru/api/v1/program/$uuid", $this->viconApiToken->get());
|
||||
$data = $this->callAPI("{$this->viconApiConfig->apiUrl()}/program/$uuid", $this->viconApiConfig->token());
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function getProgramDocs(string $uuid): object
|
||||
{
|
||||
$data = $this->callAPI("https://db-nica.ru/api/v1/program/$uuid/edu-docs?perPage=200", $this->viconApiToken->get());
|
||||
$data = $this->callAPI("{$this->viconApiConfig->apiUrl()}/program/$uuid/edu-docs?perPage=200", $this->viconApiConfig->token());
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user