<?php

namespace Shm\ShmAdmin\AdminRPC;

use Shm\Shm;
use Shm\ShmAddons\EventTicketAddon\Types\HallType\HallElements;
use Shm\ShmAdmin\AdminPanel;
use Shm\ShmAuth\Auth;
use Shm\ShmRPC\ShmRPC;


class AdminRPCHall
{
    public static function rpc()
    {

        return ShmRPC::lazy(function () {

            return [
                'type' => Shm::arrayOf(HallElements::structure()),
                'args' => [
                    'hallUUID' => Shm::nonNull(Shm::string()),
                ],
                'resolve' => function ($root, $args) {

                    Auth::authenticateOrThrow(...AdminPanel::$authStructures);


                    return HallElements::_collection()->find(['hallUUID' => $args['hallUUID']]);
                }

            ];
        });
    }
}
