- Add Metered and ConvexSol (CoTURN) provider drivers with response validation and caching - Add IceCandidateManager with automatic failover and structured logging - Add IceCandidateProviderInterface and DTOs conforming to RTCIceServer format
41 lines
1.1 KiB
PHP
41 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Resources\Interview;
|
|
|
|
use App\DTOs\IceCandidateDto;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
class IceCandidateResource extends JsonResource
|
|
{
|
|
/**
|
|
* Disable the default "data" wrapper.
|
|
*
|
|
* @var string|null
|
|
*/
|
|
public static $wrap = null;
|
|
|
|
/**
|
|
* Transform the resource into an array.
|
|
*
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function toArray(Request $request): array
|
|
{
|
|
if ($this->resource instanceof IceCandidateDto) {
|
|
return $this->resource->toArray();
|
|
}
|
|
|
|
if (is_array($this->resource)) {
|
|
return array_filter([
|
|
'urls' => $this->resource['urls'] ?? $this->resource['url'] ?? null,
|
|
'username' => $this->resource['username'] ?? null,
|
|
'credential' => $this->resource['credential'] ?? $this->resource['password'] ?? null,
|
|
'credentialType' => $this->resource['credentialType'] ?? null,
|
|
], fn ($value) => $value !== null);
|
|
}
|
|
|
|
return (array) $this->resource;
|
|
}
|
|
}
|