DarhimLabs API
PHP SDK
Oficjalny pakiet Packagist darhimlabs/php-sdk: resources, iteratory, idempotency i webhook verify.
PHP SDK
darhimlabs/php-sdk jest oficjalnym SDK dla PHP 8.2+. Pakiet ma PSR-4 autoloading, resource classes, retry/backoff, idempotency support i timing-safe webhook signature verification.
Instalacja
composer require darhimlabs/php-sdk
Pierwszy call
<?php
use DarhimLabs\Client;
$client = new Client([
"api_key" => $_ENV["DARHIMLABS_API_KEY"],
]);
$page = $client->inbox->conversations->list([
"status" => "open",
"limit" => 10,
]);
foreach ($page["data"] as $conversation) {
echo $conversation["id"] . PHP_EOL;
}
Auto-pagination
foreach ($client->inbox->conversations->iterate(["status" => "open"]) as $conversation) {
echo $conversation["id"] . PHP_EOL;
}
Send message z idempotency
$message = $client->inbox->conversations->sendMessage(
"conv_123",
["content" => "Czesc! Czym moge pomoc?"],
["idempotency_key" => "message_123"]
);
Webhook verification
$event = $client->webhooks->verifySignature([
"payload" => $rawBody,
"signatureHeader" => $_SERVER["HTTP_DL_STATUS_SIGNATURE"],
"secret" => $_ENV["DARHIMLABS_WEBHOOK_SECRET"],
]);
Generowane typy
DarhimLabs\\Types\\OpenApi jest generowany z specs/openapi.json:
npm run build:openapi
npm run sdk:types
Klasa zawiera VERSION, OPERATION_IDS, SCHEMA_NAMES i OPERATIONS.
Release
Tag sdk-php-v0.1.0 uruchamia walidacje Composera. Packagist pobiera release przez Git tag webhook.