Files
pricebuddy/app/Http/Resources/MetaExtractionResource.php
JeremyandClaude Opus 4.8 96540da6e8 feat: add meta extraction API endpoint
Port the stateless POST /api/meta-extraction endpoint from the dev
branch onto current main. Extracts title/price/image from a product URL
without persisting anything, auto-matching a store by domain and
accepting an optional store override to test custom scrape strategies.

The service is reimplemented against main's current ScrapeUrl/Store APIs
(uses the existing domainFilter scope rather than dev's findByDomain
helper chain) so it stays decoupled from dev's competing scraper refactor.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-13 13:40:03 +10:00

33 lines
906 B
PHP

<?php
namespace App\Http\Resources;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
/**
* @property array $resource
*/
class MetaExtractionResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @return array<string, mixed>
*/
public function toArray(Request $request): array
{
$store = data_get($this->resource, 'store');
return [
'title' => data_get($this->resource, 'title'),
'price' => data_get($this->resource, 'price'),
'image' => data_get($this->resource, 'image'),
'description' => data_get($this->resource, 'description'),
'availability' => data_get($this->resource, 'availability'),
/** @var array<string, StoreResource> */
'store' => $store ? new StoreResource($store) : (object) [],
];
}
}