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,
);| Option | Description | Default |
|---|---|---|
apiKey | string. Your API key's secret. | GOOMZO_API_KEY |
maxRetries | int. How many times a failed request is tried again. | 2 |
timeout | float. Seconds to wait for each try. | 60.0 |
baseUrl | string. Where the API is. | https://api.goomzo.africa |
httpClient | GuzzleHttp\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
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