}> */ public function getCategoryAspects(string $categoryId): array { $cacheKey = 'ebay_aspects_'.md5($this->marketplaceId.$categoryId); return $this->cache->get($cacheKey, function (ItemInterface $item) use ($categoryId): array { $item->expiresAfter(86400 * 7); $token = $this->oauthClient->getAccessToken(); $response = $this->httpClient->request( 'GET', $this->apiBaseUrl.'/commerce/taxonomy/v1/category_tree/'.$this->getTreeId().'/get_item_aspects_for_category', [ 'headers' => [ 'Authorization' => 'Bearer '.$token, 'X-EBAY-C-MARKETPLACE-ID' => $this->marketplaceId, ], 'query' => ['category_id' => $categoryId], ], ); /** @var array{aspects?: list}>} $data */ $data = $response->toArray(); $aspects = []; foreach ($data['aspects'] ?? [] as $aspect) { $aspects[] = [ 'name' => $aspect['localizedAspectName'], 'required' => (bool) ($aspect['aspectConstraint']['aspectRequired'] ?? false), 'usage' => $aspect['aspectConstraint']['aspectUsage'] ?? 'OPTIONAL', 'values' => array_column($aspect['aspectValues'] ?? [], 'localizedValue'), ]; } return $aspects; }); } private function getTreeId(): string { return match ($this->marketplaceId) { 'EBAY_DE' => '77', 'EBAY_US' => '0', 'EBAY_UK' => '3', default => '77', }; } }