Passage.php 769 字节
<?php

namespace Lackoxygen\TiktokShop\Passage;

use Lackoxygen\TiktokShop\Attribute\Config;
use Lackoxygen\TiktokShop\Exception\ClientException;
use Lackoxygen\TiktokShop\Transmit\Builder;

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 \Psr\Http\Message\ResponseInterface
     * @throws ClientException
     */
    public function __invoke(): \Psr\Http\Message\ResponseInterface
    {
        return $this->builder->request();
    }
}