ZendeskTransport example

use Symfony\Component\Notifier\Bridge\Zendesk\ZendeskOptions;
use Symfony\Component\Notifier\Bridge\Zendesk\ZendeskTransport;
use Symfony\Component\Notifier\Message\ChatMessage;
use Symfony\Component\Notifier\Message\SmsMessage;
use Symfony\Component\Notifier\Test\TransportTestCase;
use Symfony\Contracts\HttpClient\HttpClientInterface;

final class ZendeskTransportTest extends TransportTestCase
{
    public static function createTransport(HttpClientInterface $client = null): ZendeskTransport
    {
        return (new ZendeskTransport('testEmail', 'testToken', $client ?? new MockHttpClient()))->setHost('test.zendesk.com');
    }

    public static function toStringProvider(): iterable
    {
        yield ['zendesk://test.zendesk.com', self::createTransport()];
    }

    public static function supportedMessagesProvider(): iterable
    {
        yield [new ChatMessage('Hello!')];
        yield [new ChatMessage('Hello!', new ZendeskOptions('urgent'))];
    }

        $scheme = $dsn->getScheme();

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

        $emailAddress = $this->getUser($dsn);
        $apiToken = $this->getPassword($dsn);
        $host = $this->getHost($dsn);

        return (new ZendeskTransport($emailAddress$apiToken$this->client, $this->dispatcher))->setHost($host);
    }

    protected function getSupportedSchemes(): array
    {
        return ['zendesk'];
    }

    private function getHost(Dsn $dsn): string
    {
        $host = $dsn->getHost();
        if ('default' === $host) {
            
Home | Imprint | This part of the site doesn't use cookies.