<?php

declare(strict_types=1);

namespace PortalPeople\datadash\controllers\api;

use OpenApi\Annotations as OA;
use PortalPeople\datadash\Module;
use Yii;
use yii\rest\Controller;
use yii\filters\VerbFilter;

/**
 * @OA\Tag(
 *   name="DataDashServices",
 *   description="Tour Operator data feeds: SLT, SOH, SOD, STA, SLA"
 * )
 */
class DataServicesController extends Controller
{
    /**
     * @inheritdoc
     */
    public function behaviors(): array
    {
        return array_merge(parent::behaviors(), [
            'verbs' => [
                'class'   => VerbFilter::class,
                'actions' => [
                    'slt' => ['GET'],
                    'soh' => ['GET'],
                    'sod' => ['GET'],
                    'sta' => ['GET'],
                    'sla' => ['GET'],
                ],
            ],
        ]);
    }

    /** @return \PortalPeople\datadash\Module */
    private function module(): Module
    {
        return Yii::$app->getModule('ngauge-datadash');
    }

    /**
     * @OA\Get(path="/df/data-services/slt", tags={"DataDashServices"})
     */
    public function actionSlt(): array
    {
        return $this->module()->getDataServicesService()->slt(
            Yii::$app->request->getQueryParams()
        );
    }

    /**
     * @OA\Get(path="/df/data-services/soh", tags={"DataDashServices"})
     */
    public function actionSoh(): array
    {
        return $this->module()->getDataServicesService()->soh(
            Yii::$app->request->getQueryParams()
        );
    }

    /**
     * @OA\Get(path="/df/data-services/sod", tags={"DataDashServices"})
     */
    public function actionSod(): array
    {
        return $this->module()->getDataServicesService()->sod(
            Yii::$app->request->getQueryParams()
        );
    }

    /**
     * @OA\Get(path="/df/data-services/sta", tags={"DataDashServices"})
     */
    public function actionSta(): array
    {
        return $this->module()->getDataServicesService()->sta(
            Yii::$app->request->getQueryParams()
        );
    }

    /**
     * @OA\Get(path="/df/data-services/sla", tags={"DataDashServices"})
     */
    public function actionSla(): array
    {
        return $this->module()->getDataServicesService()->sla(
            Yii::$app->request->getQueryParams()
        );
    }
}
