GatewayApiTransport example

$scheme = $dsn->getScheme();

        if ('gatewayapi' !== $scheme) {
            throw new UnsupportedSchemeException($dsn, 'gatewayapi', $this->getSupportedSchemes());
        }

        $authToken = $this->getUser($dsn);
        $from = $dsn->getRequiredOption('from');
        $host = 'default' === $dsn->getHost() ? null : $dsn->getHost();
        $port = $dsn->getPort();

        return (new GatewayApiTransport($authToken$from$this->client, $this->dispatcher))->setHost($host)->setPort($port);
    }

    protected function getSupportedSchemes(): array
    {
        return ['gatewayapi'];
    }
}
use Symfony\Contracts\HttpClient\HttpClientInterface;
use Symfony\Contracts\HttpClient\ResponseInterface;

/** * @author Piergiuseppe Longo <piergiuseppe.longo@gmail.com> * @author Oskar Stark <oskarstark@googlemail.com> */
final class GatewayApiTransportTest extends TransportTestCase
{
    public static function createTransport(HttpClientInterface $client = null): GatewayApiTransport
    {
        return new GatewayApiTransport('authtoken', 'Symfony', $client ?? new MockHttpClient());
    }

    public static function toStringProvider(): iterable
    {
        yield ['gatewayapi://gatewayapi.com?from=Symfony', self::createTransport()];
    }

    public static function supportedMessagesProvider(): iterable
    {
        yield [new SmsMessage('0611223344', 'Hello!')];
        yield [new SmsMessage('0611223344', 'Hello!', 'from', new GatewayApiOptions(['from' => 'foo']))];
    }
Home | Imprint | This part of the site doesn't use cookies.