Configuration

Set up the client with your API key, retries and timeouts.

The client reads its settings once, when you make it. Make one and share it across your app, such as a singleton in your container.

Options

use Goomzo\Goomzo;

$goomzo = new Goomzo(
    apiKey: getenv('GOOMZO_API_KEY'),
    maxRetries: 2,
    timeout: 60.0,
);
OptionDescriptionDefault
apiKeystring. Your API key's secret.GOOMZO_API_KEY
maxRetriesint. How many times a failed request is tried again.2
timeoutfloat. Seconds to wait for each try.60.0
baseUrlstring. Where the API is.https://api.goomzo.africa
httpClientGuzzleHttp\ClientInterface. Your own Guzzle client, such as for a proxy or tests.A new one

Important: Keep the API key on your server, such as in .env. Never put it in code that runs in a browser or an app.

In Laravel

app/Providers/AppServiceProvider.php
use Goomzo\Goomzo;

public function register(): void
{
    $this->app->singleton(Goomzo::class, fn () => new Goomzo(apiKey: config('services.goomzo.key')));
}

Idempotency keys

Every method that creates something takes idempotencyKey, so a retry from your side isn't done twice. Left out, one is made for each call.

$goomzo->messages->sendOne(
    ['to' => '+255712345678', 'channel' => 'sms', 'content' => ['text' => 'Your order is ready.']],
    idempotencyKey: 'order-1042-ready',
);

API version

The SDK sends the Goomzo-Version it was written for, as Goomzo::API_VERSION.

Next steps

Last updated