InfobipApiTransport example

                if (isset($options['body']) && $options['body'] instanceof \Generator) {
                    $body = '';
                    foreach ($options['body'] as $data) {
                        $body .= $data;
                    }
                    $options['body'] = $body;
                }

                return parent::request($method$url$options);
            }
        };
        $this->transport = new InfobipApiTransport(self::KEY, $this->httpClient);
        $this->transport->setHost('99999.api.infobip.com');
    }

    protected function tearDown(): void
    {
        unset($this->response, $this->httpClient, $this->transport);
    }

    public function testToString()
    {
        $this->assertSame('infobip+api://99999.api.infobip.com', (string) $this->transport);
    }
new Dsn('infobip+smtp', 'example.com'),
            true,
        ];
    }

    public static function createProvider(): iterable
    {
        $logger = new NullLogger();

        yield [
            new Dsn('infobip+api', 'example.com', self::PASSWORD),
            (new InfobipApiTransport(self::PASSWORD, new MockHttpClient(), null, $logger))->setHost('example.com'),
        ];

        yield [
            new Dsn('infobip', 'default', self::PASSWORD),
            new InfobipSmtpTransport(self::PASSWORD, null, $logger),
        ];

        yield [
            new Dsn('infobip+smtp', 'default', self::PASSWORD),
            new InfobipSmtpTransport(self::PASSWORD, null, $logger),
        ];

        
public function create(Dsn $dsn): TransportInterface
    {
        $schema = $dsn->getScheme();
        $apiKey = $this->getUser($dsn);

        if ('infobip+api' === $schema) {
            $host = $dsn->getHost();
            if ('default' === $host) {
                throw new IncompleteDsnException('Infobip mailer for API DSN must contain a host.');
            }

            return (new InfobipApiTransport($apiKey$this->client, $this->dispatcher, $this->logger))
                ->setHost($host)
            ;
        }

        if (\in_array($schema['infobip+smtp', 'infobip+smtps', 'infobip'], true)) {
            return new InfobipSmtpTransport($apiKey$this->dispatcher, $this->logger);
        }

        throw new UnsupportedSchemeException($dsn, 'infobip', $this->getSupportedSchemes());
    }

    
Home | Imprint | This part of the site doesn't use cookies.