<?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_review.class%" shortName="ProductReview">

        <attribute name="validation_groups">sylius</attribute>

        <collectionOperations>
            <collectionOperation name="admin_get">
                <attribute name="method">GET</attribute>
                <attribute name="path">/admin/product-reviews</attribute>
                <attribute name="filters">
                    <attribute>sylius.api.product_review_status_filter</attribute>
                </attribute>
                <attribute name="normalization_context">
                    <attribute name="groups">
                        <attribute>admin:product_review:index</attribute>
                        <attribute>sylius:admin:product_review:index</attribute>
                    </attribute>
                </attribute>
            </collectionOperation>

            <collectionOperation name="shop_post">
                <attribute name="method">POST</attribute>
                <attribute name="path">/shop/product-reviews</attribute>
                <attribute name="messenger">input</attribute>
                <attribute name="input">Sylius\Bundle\ApiBundle\Command\Catalog\AddProductReview</attribute>
                <attribute name="denormalization_context">
                    <attribute name="groups">
                        <attribute>shop:product_review:create</attribute>
                        <attribute>sylius:shop:product_review:create</attribute>
                    </attribute>
                </attribute>
                <attribute name="normalization_context">
                    <attribute name="groups">
                        <attribute>shop:product_review:show</attribute>
                        <attribute>sylius:shop:product_review:show</attribute>
                    </attribute>
                </attribute>
            </collectionOperation>

            <collectionOperation name="shop_get">
                <attribute name="method">GET</attribute>
                <attribute name="path">/shop/product-reviews</attribute>
                <attribute name="filters">
                    <attribute>sylius.api.product_review_product_filter</attribute>
                    <attribute>sylius.api.product_review_date_filter</attribute>
                </attribute>
                <attribute name="normalization_context">
                    <attribute name="groups">
                        <attribute>shop:product_review:index</attribute>
                        <attribute>sylius:shop:product_review:index</attribute>
                    </attribute>
                </attribute>
            </collectionOperation>
        </collectionOperations>

        <itemOperations>
            <itemOperation name="admin_get">
                <attribute name="method">GET</attribute>
                <attribute name="path">/admin/product-reviews/{id}</attribute>
                <attribute name="normalization_context">
                    <attribute name="groups">
                        <attribute>admin:product_review:show</attribute>
                        <attribute>sylius:admin:product_review:show</attribute>
                    </attribute>
                </attribute>
            </itemOperation>

            <itemOperation name="shop_get">
                <attribute name="method">GET</attribute>
                <attribute name="path">/shop/product-reviews/{id}</attribute>
                <attribute name="normalization_context">
                    <attribute name="groups">
                        <attribute>shop:product_review:show</attribute>
                        <attribute>sylius:shop:product_review:show</attribute>
                    </attribute>
                </attribute>
            </itemOperation>

            <itemOperation name="admin_delete">
                <attribute name="method">DELETE</attribute>
                <attribute name="path">/admin/product-reviews/{id}</attribute>
                <attribute name="denormalization_context">
                    <attribute name="groups">
                        <attribute>admin:product_review:update</attribute>
                        <attribute>sylius:admin:product_review:update</attribute>
                    </attribute>
                </attribute>
            </itemOperation>

            <itemOperation name="admin_put">
                <attribute name="method">PUT</attribute>
                <attribute name="path">/admin/product-reviews/{id}</attribute>
                <attribute name="denormalization_context">
                    <attribute name="groups">
                        <attribute>admin:product_review:update</attribute>
                        <attribute>sylius:admin:product_review:update</attribute>
                    </attribute>
                </attribute>
                <attribute name="normalization_context">
                    <attribute name="groups">
                        <attribute>admin:product_review:show</attribute>
                        <attribute>sylius:admin:product_review:show</attribute>
                    </attribute>
                </attribute>
            </itemOperation>

            <itemOperation name="admin_accept">
                <attribute name="method">PATCH</attribute>
                <attribute name="path">/admin/product-reviews/{id}/accept</attribute>
                <attribute name="input">false</attribute>
                <attribute name="controller">Sylius\Bundle\ApiBundle\Applicator\ProductReviewStateMachineTransitionApplicatorInterface::accept</attribute>
                <attribute name="openapi_context">
                    <attribute name="summary">Accepts Product Review.</attribute>
                </attribute>
                <attribute name="normalization_context">
                    <attribute name="groups">
                        <attribute>admin:product_review:show</attribute>
                        <attribute>sylius:admin:product_review:show</attribute>
                    </attribute>
                </attribute>
            </itemOperation>

            <itemOperation name="admin_reject">
                <attribute name="method">PATCH</attribute>
                <attribute name="path">/admin/product-reviews/{id}/reject</attribute>
                <attribute name="input">false</attribute>
                <attribute name="controller">Sylius\Bundle\ApiBundle\Applicator\ProductReviewStateMachineTransitionApplicatorInterface::reject</attribute>
                <attribute name="openapi_context">
                    <attribute name="summary">Rejects Product Review.</attribute>
                </attribute>
                <attribute name="normalization_context">
                    <attribute name="groups">
                        <attribute>admin:product_review:show</attribute>
                        <attribute>sylius:admin:product_review:show</attribute>
                    </attribute>
                </attribute>
            </itemOperation>
        </itemOperations>

        <property name="id" identifier="true" writable="false" />
        <property name="createdAt" writable="false" />
        <property name="updatedAt" writable="false" />
        <property name="title" required="true" readable="true" writable="true" />
        <property name="rating" readable="true" writable="true" />
        <property name="comment" readable="true" writable="true" />
        <property name="author" readable="true" writable="true" />
        <property name="status" readable="true" writable="true" />
        <property name="reviewSubject" readable="true" writable="true" />
    </resource>
</resources>
