<?xml version="1.0" ?>

<!--

 This file is part of the Sylius package.

 (c) Sylius Sp. z o.o.

 For the full copyright and license information, please view the LICENSE
 file that was distributed with this source code.

-->

<resources xmlns="https://api-platform.com/schema/metadata"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="https://api-platform.com/schema/metadata https://api-platform.com/schema/metadata/metadata-2.0.xsd"
>
    <resource class="%sylius.model.product.class%" shortName="Product">
        <attribute name="validation_groups">sylius</attribute>

        <attribute name="order">
            <attribute name="code">ASC</attribute>
        </attribute>

        <collectionOperations>
            <collectionOperation name="admin_get">
                <attribute name="method">GET</attribute>
                <attribute name="path">/admin/products</attribute>
                <attribute name="filters">
                    <attribute>sylius.api.product_name_filter</attribute>
                    <attribute>sylius.api.product_order_filter</attribute>
                    <attribute>sylius.api.product_taxon_code_filter</attribute>
                    <attribute>Sylius\Bundle\ApiBundle\Filter\Doctrine\ChannelsAwareChannelFilter</attribute>
                    <attribute>Sylius\Bundle\ApiBundle\Filter\Doctrine\TranslationOrderNameAndLocaleFilter</attribute>
                </attribute>
                <attribute name="normalization_context">
                    <attribute name="groups">
                        <attribute>admin:product:index</attribute>
                        <attribute>sylius:admin:product:index</attribute>
                    </attribute>
                </attribute>
                <attribute name="openapi_context">
                    <attribute name="parameters">
                        <attribute>
                            <attribute name="name">imageFilter</attribute>
                            <attribute name="in">query</attribute>
                            <attribute name="description">Provide one of supported image liip imagine filters</attribute>
                            <attribute name="schema">
                                <attribute name="type">string</attribute>
                            </attribute>
                        </attribute>
                    </attribute>
                </attribute>
            </collectionOperation>

            <collectionOperation name="shop_get">
                <attribute name="method">GET</attribute>
                <attribute name="path">/shop/products</attribute>
                <attribute name="filters">
                    <attribute>sylius.api.product_name_filter</attribute>
                    <attribute>sylius.api.product_order_filter</attribute>
                    <attribute>sylius.api.product_taxon_code_filter</attribute>
                    <attribute>Sylius\Bundle\ApiBundle\Filter\Doctrine\ProductPriceOrderFilter</attribute>
                    <attribute>Sylius\Bundle\ApiBundle\Filter\Doctrine\TranslationOrderNameAndLocaleFilter</attribute>
                    <attribute>Sylius\Bundle\ApiBundle\Filter\Doctrine\TaxonFilter</attribute>
                </attribute>
                <attribute name="normalization_context">
                    <attribute name="groups">
                        <attribute>shop:product:index</attribute>
                        <attribute>sylius:shop:product:index</attribute>
                    </attribute>
                </attribute>
                <attribute name="openapi_context">
                    <attribute name="parameters">
                        <attribute>
                            <attribute name="name">imageFilter</attribute>
                            <attribute name="in">query</attribute>
                            <attribute name="description">Provide one of supported image liip imagine filters</attribute>
                            <attribute name="schema">
                                <attribute name="type">string</attribute>
                            </attribute>
                        </attribute>
                    </attribute>
                </attribute>
            </collectionOperation>

            <collectionOperation name="admin_post">
                <attribute name="method">POST</attribute>
                <attribute name="path">/admin/products</attribute>
                <attribute name="denormalization_context">
                    <attribute name="groups">
                        <attribute>admin:product:create</attribute>
                        <attribute>sylius:admin:product:create</attribute>
                    </attribute>
                </attribute>
                <attribute name="normalization_context">
                    <attribute name="groups">
                        <attribute>admin:product:show</attribute>
                        <attribute>sylius:admin:product:show</attribute>
                    </attribute>
                </attribute>
            </collectionOperation>
        </collectionOperations>

        <itemOperations>
            <itemOperation name="admin_get">
                <attribute name="method">GET</attribute>
                <attribute name="path">/admin/products/{code}</attribute>
                <attribute name="openapi_context">
                    <attribute name="summary">Use code to retrieve a product resource.</attribute>
                </attribute>
                <attribute name="normalization_context">
                    <attribute name="groups">
                        <attribute>admin:product:show</attribute>
                        <attribute>sylius:admin:product:show</attribute>
                    </attribute>
                </attribute>
                <attribute name="openapi_context">
                    <attribute name="parameters">
                        <attribute>
                            <attribute name="name">imageFilter</attribute>
                            <attribute name="in">query</attribute>
                            <attribute name="description">Provide one of supported image liip imagine filters</attribute>
                            <attribute name="schema">
                                <attribute name="type">string</attribute>
                            </attribute>
                        </attribute>
                    </attribute>
                </attribute>
            </itemOperation>

            <itemOperation name="shop_get">
                <attribute name="method">GET</attribute>
                <attribute name="path">/shop/products/{code}</attribute>
                <attribute name="openapi_context">
                    <attribute name="summary">Use code to retrieve a product resource.</attribute>
                </attribute>
                <attribute name="normalization_context">
                    <attribute name="groups">
                        <attribute>shop:product:show</attribute>
                        <attribute>sylius:shop:product:show</attribute>
                    </attribute>
                </attribute>
                <attribute name="openapi_context">
                    <attribute name="parameters">
                        <attribute>
                            <attribute name="name">imageFilter</attribute>
                            <attribute name="in">query</attribute>
                            <attribute name="description">Provide one of supported image liip imagine filters</attribute>
                            <attribute name="schema">
                                <attribute name="type">string</attribute>
                            </attribute>
                        </attribute>
                    </attribute>
                </attribute>
            </itemOperation>

            <itemOperation name="shop_get_by_slug">
                <attribute name="method">GET</attribute>
                <attribute name="path">/shop/products-by-slug/{slug}</attribute>
                <attribute name="controller">Sylius\Bundle\ApiBundle\Controller\GetProductBySlugAction</attribute>
                <attribute name="read">false</attribute>
                <attribute name="openapi_context">
                    <attribute name="summary">Use slug to retrieve a product resource.</attribute>
                    <attribute name="parameters">
                        <attribute>
                            <attribute name="name">slug</attribute>
                            <attribute name="in">path</attribute>
                            <attribute name="required">true</attribute>
                            <attribute name="schema">
                                <attribute name="type">string</attribute>
                            </attribute>
                        </attribute>
                        <attribute>
                            <attribute name="name">imageFilter</attribute>
                            <attribute name="in">query</attribute>
                            <attribute name="description">Provide one of supported image liip imagine filters</attribute>
                            <attribute name="schema">
                                <attribute name="type">string</attribute>
                            </attribute>
                        </attribute>
                    </attribute>
                </attribute>
                <attribute name="normalization_context">
                    <attribute name="groups">
                        <attribute>shop:product:show</attribute>
                        <attribute>sylius:shop:product:show</attribute>
                    </attribute>
                </attribute>
            </itemOperation>

            <itemOperation name="admin_put">
                <attribute name="method">PUT</attribute>
                <attribute name="path">/admin/products/{code}</attribute>
                <attribute name="denormalization_context">
                    <attribute name="groups">
                        <attribute>admin:product:update</attribute>
                        <attribute>sylius:admin:product:update</attribute>
                    </attribute>
                </attribute>
                <attribute name="normalization_context">
                    <attribute name="groups">
                        <attribute>admin:product:show</attribute>
                        <attribute>sylius:admin:product:show</attribute>
                    </attribute>
                </attribute>
            </itemOperation>

            <itemOperation name="admin_delete">
                <attribute name="method">DELETE</attribute>
                <attribute name="path">/admin/products/{code}</attribute>
            </itemOperation>
        </itemOperations>

        <subresourceOperations>
            <subresourceOperation name="images_get_subresource">
                <attribute name="method">GET</attribute>
                <attribute name="path">/admin/products/{code}/images</attribute>
                <attribute name="openapi_context">
                    <attribute name="parameters">
                        <attribute>
                            <attribute name="name">imageFilter</attribute>
                            <attribute name="in">query</attribute>
                            <attribute name="description">Provide one of supported image liip imagine filters</attribute>
                            <attribute name="schema">
                                <attribute name="type">string</attribute>
                            </attribute>
                        </attribute>
                    </attribute>
                </attribute>
            </subresourceOperation>

            <subresourceOperation name="attributes_get_subresource">
                <attribute name="method">GET</attribute>
                <attribute name="path">/shop/products/{code}/attributes</attribute>
            </subresourceOperation>
        </subresourceOperations>

        <property name="id" identifier="false" writable="false" />
        <property name="code" identifier="true" required="true" />
        <property name="createdAt" writable="false" />
        <property name="updatedAt" writable="false" />
        <property name="translations" readable="true" writable="true">
            <attribute name="openapi_context">
                <attribute name="type">object</attribute>
                <attribute name="example">
                    <attribute name="en_US">
                        <attribute name="name">string</attribute>
                        <attribute name="slug">string</attribute>
                        <attribute name="description">string</attribute>
                        <attribute name="shortDescription">string</attribute>
                        <attribute name="metaKeywords">string</attribute>
                        <attribute name="metaDescription">string</attribute>
                    </attribute>
                </attribute>
            </attribute>
        </property>
        <property name="productTaxons" readable="true" writable="true" />
        <property name="reviews" required="false" />
        <property name="options" required="false" />
        <property name="channels" required="false" />
        <property name="images" required="false" />
        <property name="mainTaxon" required="false" />
        <property name="variants" readable="true"/>
        <property name="averageRating" readable="true" />
        <property name="description" readable="true" />
        <property name="slug" readable="true" />
        <property name="shortDescription" readable="true" />
        <property name="name" readable="true" />
        <property name="associations" readable="true" />
        <property name="attributes" readable="true" writable="true">
            <subresource resourceClass="%sylius.model.product_attribute_value.class%" collection="true" />
        </property>
        <property name="images" writable="false" required="false">
            <subresource resourceClass="%sylius.model.product_image.class%" collection="true" />
        </property>
    </resource>
</resources>
