allow vendord
All checks were successful
Build, Push and Deploy / build-and-push (push) Successful in 3m3s
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 16s
Build, Push and Deploy / deploy-staging (push) Successful in 32s
Build, Push and Deploy / deploy-production (push) Has been skipped
Build, Push and Deploy / cleanup (push) Successful in 1s

This commit is contained in:
2026-03-30 14:54:57 +07:00
parent 66aed7c4e8
commit b5e3a778ce
21316 changed files with 2777892 additions and 13 deletions

View File

@@ -0,0 +1,50 @@
<?php
namespace Twilio;
use Twilio\Exceptions\RestException;
use Twilio\Exceptions\RestExceptionV1;
use Twilio\Exceptions\TwilioException;
use Twilio\Http\Response;
class ApiV1Version extends Version {
protected $apiVersion;
/**
* @param Domain $domain
* @param ?string $version
*/
public function __construct(Domain $domain, ?string $version) {
parent::__construct($domain);
$this->version = $version;
$this->apiVersion = "V1";
}
/**
* Create the best possible exception for the response as per Twilio API Standard V1.
*
* Attempts to parse the response for Twilio Standard error as defined in Twilio API Standards V1
* and use those to populate the exception, falls back to generic error message and
* HTTP status code.
*
* @param Response $response Error response
* @param string $header Header for exception message
* @return TwilioException
*/
protected function exception(Response $response, string $header): TwilioException {
$message = '[HTTP ' . $response->getStatusCode() . '] ' . $header;
$content = $response->getContent();
if (\is_array($content)) {
$message .= isset($content['message']) ? ': ' . $content['message'] : '';
$code = $content['code'] ?? $response->getStatusCode();
$httpStatusCode = $content['httpStatusCode'] ?? $response->getStatusCode();
$params = $content['params'] ?? [];
$userError = $content['userError'] ?? false;
return new RestExceptionV1($code, $message, $httpStatusCode, $params, $userError);
}
return new RestExceptionV1($response->getStatusCode(), $message, $response->getStatusCode());
}
}