SDK de PHPVista previa
Cliente para PHP 8.2 con Guzzle o curl.
Terminal
composer require tinkay/tinkay-phpUso
PHP
<?phpuse Tinkay\Client;$tinkay = new Client(getenv("TINKAY_API_KEY"));$contact = $tinkay->contacts()->create([ "name" => "Camila Rodríguez", "email" => "[email protected]", "company" => "Kipu Pagos",]);$tinkay->tickets()->create([ "subject" => "Error 500 al exportar", "description" => "Reportado desde el panel interno.", "contact_id" => $contact["id"], "priority" => "high",]);Sin SDK
TinkayClient.php
<?phpfinal class TinkayClient{ private const BASE = "https://api.tinkay.app/v1"; public function __construct(private readonly string $apiKey) {} public function request(string $method, string $path, ?array $body = null): array { $ch = curl_init(self::BASE . $path); curl_setopt_array($ch, [ CURLOPT_CUSTOMREQUEST => $method, CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 15, CURLOPT_HTTPHEADER => [ "Authorization: Bearer {$this->apiKey}", "Content-Type: application/json", ], ...($body ? [CURLOPT_POSTFIELDS => json_encode($body)] : []), ]); $raw = curl_exec($ch); $status = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); $decoded = json_decode($raw, true) ?? []; if ($status >= 400) { throw new RuntimeException("Tinkay {$status}: " . ($decoded["error"]["message"] ?? "error")); } return $decoded; } public function createContact(array $fields): array { return $this->request("POST", "/contacts", $fields)["data"]; }}