<?php
declare (strict_types=1);

namespace App\Controller\Admin\API\Store;

use App\Controller\Admin\Base;
use App\Interceptor\Admin;
use App\Interceptor\PostDecrypt;
use App\Service\Store\Http;
use Kernel\Annotation\Inject;
use Kernel\Annotation\Interceptor;
use Kernel\Context\Interface\Response;
use Kernel\Exception\JSONException;
use Kernel\Exception\RuntimeException;

#[Interceptor(class: [PostDecrypt::class, Admin::class], type: Interceptor::API)]
class Withdrawal extends Base
{
    #[Inject]
    private Http $http;


    /**
     * @return Response
     * @throws JSONException
     * @throws RuntimeException
     * @throws \ReflectionException
     */
    public function get(): Response
    {
        $http = $this->http->request("/user/withdrawal/get", $this->request->post(), $this->getStoreAuth());
        return $this->json(data: $http->data);
    }


    /**
     * @return Response
     * @throws JSONException
     * @throws RuntimeException
     * @throws \ReflectionException
     */
    public function apply(): Response
    {
        $this->http->request("/user/withdrawal/apply", $this->request->post(), $this->getStoreAuth());
        return $this->json();
    }

}