Passage.php 768 字节
<?php

namespace Lackoxygen\TiktokShop\Passage;

use Lackoxygen\TiktokShop\Attribute\Config;
use Lackoxygen\TiktokShop\Exception\ClientException;
use Lackoxygen\TiktokShop\Transmit\Builder;
use Psr\Http\Message\ResponseInterface;

abstract class Passage
{
    protected Config $config;

    protected Builder $builder;

    /**
     * @param Config $config
     * @param string $method
     */
    public function __construct(Config $config, string $method)
    {
        $this->config = $config;
        $this->builder = Builder::create($config, get_class($this), $method);
    }

    /**
     * @return ResponseInterface
     * @throws ClientException
     */
    public function __invoke(): ResponseInterface
    {
        return $this->builder->request();
    }
}