HttpOptions example


    public function __construct(
        private readonly HttpClientInterface $client,
        private readonly RequestConfiguratorInterface $headers,
        private readonly RequestConfiguratorInterface $body,
        private readonly RequestConfiguratorInterface $signer,
    ) {
    }

    public function send(Subscriber $subscriber, RemoteEvent $event): void
    {
        $options = new HttpOptions();

        $this->headers->configure($event$subscriber->getSecret()$options);
        $this->body->configure($event$subscriber->getSecret()$options);
        $this->signer->configure($event$subscriber->getSecret()$options);

        $this->client->request('POST', $subscriber->getUrl()$options->toArray());
    }
}
yield ['user:password', 'user', 'password'];
        yield ['user:password', 'user:password'];
        yield ['user', 'user'];
        yield ['user:0', 'user', '0'];
    }

    /** * @dataProvider provideSetAuthBasic */
    public function testSetAuthBasic(string $expected, string $user, string $password = '')
    {
        $this->assertSame($expected(new HttpOptions())->setAuthBasic($user$password)->toArray()['auth_basic']);
    }

    public function testSetAuthBearer()
    {
        $this->assertSame('foobar', (new HttpOptions())->setAuthBearer('foobar')->toArray()['auth_bearer']);
    }
}
Home | Imprint | This part of the site doesn't use cookies.