You’re reading the v0.1 development preview. APIs may change.
~ 1 min readUpdated 2026-10-30

Integrate a partner API safely

Prerequisite: routes, JSON and validation. Goal: read stock with a bounded timeout and verify the response without contacting the partner.

Use the HTTP example below, then inject Client in the real controller. Keep a fixed server-configured URL and a private token. Try a 503 followed by 200 with FakeTransport::sequence; confirm that GET retries while POST does not retry by default.

use Elang\Http\Client\{Client, FakeTransport, Response};

$fake = (new FakeTransport())->when(
    'https://partner.example.test/stock*',
    new Response(200, '{"data":{"quantity":12}}'),
);
$http = new Client($fake);
$quantity = $http->baseUrl('https://partner.example.test')
    ->timeout(10)->retry(3, 100)
    ->get('/stock', ['sku' => 'A-100'])
    ->throw()->json('data.quantity'); // 12
$fake->assertSentCount(1);

You are done when the quantity is 12, exactly one fake request is recorded, and an unregistered fake URL fails locally. Read the HTTP client chapter before enabling a real integration.

Next step

Need a hand?

Check the troubleshooting guide, look up a term in the glossary, or work through the complete task board project.

Search Elang documentation

Start typing to find your next step.